aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/Reflection
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection')
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs2
-rw-r--r--csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs4
2 files changed, 2 insertions, 4 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
index 8cfdb779..6083f171 100644
--- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
@@ -94,7 +94,7 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The json_name option of the descriptor's target.
/// </summary>
- public string JsonName { get { return proto.JsonName; } }
+ public string JsonName { get { return proto.JsonName == "" ? JsonFormatter.ToCamelCase(proto.Name) : 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 63f168ca..f5a835e5 100644
--- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
@@ -102,10 +102,8 @@ namespace Google.Protobuf.Reflection
var map = new Dictionary<string, FieldDescriptor>();
foreach (var field in fields)
{
- map[JsonFormatter.ToCamelCase(field.Name)] = field;
map[field.Name] = field;
- if (!string.IsNullOrEmpty(field.JsonName))
- map[field.JsonName] = field;
+ map[field.JsonName] = field;
}
return new ReadOnlyDictionary<string, FieldDescriptor>(map);
}