diff options
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs index b6351d36..1c22c460 100644 --- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs @@ -40,6 +40,20 @@ namespace Google.Protobuf.Reflection /// </summary> public sealed class MessageDescriptor : DescriptorBase { + private static readonly HashSet<string> WellKnownTypeNames = new HashSet<string> + { + "google/protobuf/any.proto", + "google/protobuf/api.proto", + "google/protobuf/duration.proto", + "google/protobuf/empty.proto", + "google/protobuf/wrappers.proto", + "google/protobuf/timestamp.proto", + "google/protobuf/field_mask.proto", + "google/protobuf/source_context.proto", + "google/protobuf/struct.proto", + "google/protobuf/type.proto", + }; + private readonly DescriptorProto proto; private readonly MessageDescriptor containingType; private readonly IList<MessageDescriptor> nestedTypes; @@ -79,6 +93,17 @@ namespace Google.Protobuf.Reflection internal DescriptorProto Proto { get { return proto; } } + /// <summary> + /// Returns whether this message is one of the "well known types" which may have runtime/protoc support. + /// </summary> + internal bool IsWellKnownType + { + get + { + return File.Package == "google.protobuf" && WellKnownTypeNames.Contains(File.Name); + } + } + /// <value> /// If this is a nested type, get the outer descriptor, otherwise null. /// </value> |