From 0d32ab37fa94134427478d6776108e7cdb3e5e15 Mon Sep 17 00:00:00 2001 From: alien Date: Thu, 17 Mar 2016 15:19:04 +0300 Subject: csharp: add support for the json_name option Conflicts: csharp/src/Google.Protobuf/JsonFormatter.cs --- csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs | 6 ++++++ csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs | 2 ++ 2 files changed, 8 insertions(+) (limited to 'csharp/src/Google.Protobuf/Reflection') diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs index c6caaec6..8cfdb779 100644 --- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs @@ -90,6 +90,12 @@ namespace Google.Protobuf.Reflection /// public override string Name { get { return proto.Name; } } + + /// + /// The json_name option of the descriptor's target. + /// + public string JsonName { get { return proto.JsonName; } } + internal FieldDescriptorProto Proto { get { return proto; } } /// diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs index f5798d1e..63f168ca 100644 --- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs @@ -104,6 +104,8 @@ namespace Google.Protobuf.Reflection { map[JsonFormatter.ToCamelCase(field.Name)] = field; map[field.Name] = field; + if (!string.IsNullOrEmpty(field.JsonName)) + map[field.JsonName] = field; } return new ReadOnlyDictionary(map); } -- cgit v1.2.3