diff options
author | Jon Skeet <jonskeet@google.com> | 2015-11-13 20:04:03 +0000 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-11-19 08:50:28 +0000 |
commit | 2a15051a1e101ea58d7d2e262aa79c7c21f23266 (patch) | |
tree | 29793eb4d5c1c58004d79b64ef19fb70c5f1f4a4 /csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs | |
parent | c581acb562fad93c4eb7b125cc31b64fa6f51868 (diff) | |
download | protobuf-2a15051a1e101ea58d7d2e262aa79c7c21f23266.tar.gz protobuf-2a15051a1e101ea58d7d2e262aa79c7c21f23266.tar.bz2 protobuf-2a15051a1e101ea58d7d2e262aa79c7c21f23266.zip |
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/Reflection/MessageDescriptor.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs index e599998e..65040e42 100644 --- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs @@ -67,11 +67,13 @@ namespace Google.Protobuf.Reflection private readonly IList<OneofDescriptor> oneofs; // CLR representation of the type described by this descriptor, if any. private readonly Type generatedType; + private readonly MessageParser parser; internal MessageDescriptor(DescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int typeIndex, GeneratedCodeInfo generatedCodeInfo) : base(file, file.ComputeFullName(parent, proto.Name), typeIndex) { this.proto = proto; + parser = generatedCodeInfo == null ? null : generatedCodeInfo.Parser; generatedType = generatedCodeInfo == null ? null : generatedCodeInfo.ClrType; containingType = parent; @@ -123,6 +125,15 @@ namespace Google.Protobuf.Reflection public Type GeneratedType { get { return generatedType; } } /// <summary> + /// A parser for this message type. + /// </summary> + /// <remarks> + /// As <see cref="MessageDescriptor"/> is not generic, this cannot be statically + /// typed to the relevant type, but if <see cref="GeneratedType"/> returns a non-null value, the parser returned + /// </remarks> + public MessageParser Parser { get { return parser; } } + + /// <summary> /// Returns whether this message is one of the "well known types" which may have runtime/protoc support. /// </summary> internal bool IsWellKnownType |