summaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/JsonParser.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-11-13 20:04:03 +0000
committerJon Skeet <jonskeet@google.com>2015-11-19 08:50:28 +0000
commit2a15051a1e101ea58d7d2e262aa79c7c21f23266 (patch)
tree29793eb4d5c1c58004d79b64ef19fb70c5f1f4a4 /csharp/src/Google.Protobuf/JsonParser.cs
parentc581acb562fad93c4eb7b125cc31b64fa6f51868 (diff)
downloadprotobuf-javalite-2a15051a1e101ea58d7d2e262aa79c7c21f23266.tar.gz
Introduce a Parser property into MessageDescriptor, and populate it from generated types.
Generated code coming in next commit - in a subsequent PR I want to do a bit of renaming and redocumenting around this, in anticipation of DynamicMessage.
Diffstat (limited to 'csharp/src/Google.Protobuf/JsonParser.cs')
-rw-r--r--csharp/src/Google.Protobuf/JsonParser.cs6
1 files changed, 1 insertions, 5 deletions
diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs
index 9e1c83cc..b4a35d7c 100644
--- a/csharp/src/Google.Protobuf/JsonParser.cs
+++ b/csharp/src/Google.Protobuf/JsonParser.cs
@@ -555,14 +555,10 @@ namespace Google.Protobuf
/// <summary>
/// Creates a new instance of the message type for the given field.
- /// This method is mostly extracted so we can replace it in one go when we work out
- /// what we want to do instead of Activator.CreateInstance.
/// </summary>
private static IMessage NewMessageForField(FieldDescriptor field)
{
- // TODO: Create an instance in a better way ?
- // (We could potentially add a Parser property to MessageDescriptor... see issue 806.)
- return (IMessage) Activator.CreateInstance(field.MessageType.GeneratedType);
+ return field.MessageType.Parser.CreateTemplate();
}
private static T ParseNumericString<T>(string text, Func<string, NumberStyles, IFormatProvider, T> parser, bool floatingPoint)