diff options
author | Jon Skeet <jonskeet@google.com> | 2015-07-20 11:48:24 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-07-20 11:48:24 +0100 |
commit | c9fd53a3b742f2a34c527cbe0833c5bc081e6ec3 (patch) | |
tree | 410dee597653917b53ff1d7646b92deb5b15ffda /csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs | |
parent | 3f5df7a74b9d6989d0ea0cb0664f0105d80767eb (diff) | |
download | protobuf-c9fd53a3b742f2a34c527cbe0833c5bc081e6ec3.tar.gz protobuf-c9fd53a3b742f2a34c527cbe0833c5bc081e6ec3.tar.bz2 protobuf-c9fd53a3b742f2a34c527cbe0833c5bc081e6ec3.zip |
First part of JSON formatting for well-known types. I think we need a reflection API rethink before doing the rest.
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> |