diff options
author | Jos Hickson <jos.hickson@gmail.com> | 2016-05-11 09:23:46 +0100 |
---|---|---|
committer | Jos Hickson <jos.hickson@gmail.com> | 2016-05-11 09:23:46 +0100 |
commit | 2b22b611a8af9e9d06491de2ebcc5d9b962e544c (patch) | |
tree | 1d8b5a7399380da5fb3260e2f8eaa2b8cf31bec2 /csharp/src/Google.Protobuf | |
parent | 48ebb29a8ec118bf6b9ee39f6be42b57321c099a (diff) | |
parent | a1938b2aa9ca86ce7ce50c27ff9737c1008d2a03 (diff) | |
download | protobuf-2b22b611a8af9e9d06491de2ebcc5d9b962e544c.tar.gz protobuf-2b22b611a8af9e9d06491de2ebcc5d9b962e544c.tar.bz2 protobuf-2b22b611a8af9e9d06491de2ebcc5d9b962e544c.zip |
Merge remote-tracking branch 'refs/remotes/google/master'
Diffstat (limited to 'csharp/src/Google.Protobuf')
18 files changed, 452 insertions, 331 deletions
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj index ef524baf..5557612a 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj +++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj @@ -117,6 +117,7 @@ <Compile Include="Reflection\MethodDescriptor.cs" />
<Compile Include="Reflection\OneofAccessor.cs" />
<Compile Include="Reflection\OneofDescriptor.cs" />
+ <Compile Include="Reflection\OriginalNameAttribute.cs" />
<Compile Include="Reflection\PackageDescriptor.cs" />
<Compile Include="Reflection\PartialClasses.cs" />
<Compile Include="Reflection\ReflectionUtil.cs" />
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec index d5302544..2892b8bf 100644 --- a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec +++ b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec @@ -23,7 +23,6 @@ <group targetFramework="xamarin.ios" /> <group targetFramework="monotouch" /> <group targetFramework="monoandroid" /> - <!-- Dependencies for newer, more granular platforms (.NET Core etc) --> <group targetFramework="dotnet"> <dependency id="System.Collections" version="4.0.0" /> @@ -34,10 +33,12 @@ <dependency id="System.Linq.Expressions" version="4.0.0" /> <dependency id="System.ObjectModel" version="4.0.0" /> <dependency id="System.Reflection" version="4.0.0" /> + <dependency id="System.Reflection.Extensions" version="4.0.0" /> <dependency id="System.Runtime" version="4.0.0" /> <dependency id="System.Runtime.Extensions" version="4.0.0" /> <dependency id="System.Text.Encoding" version="4.0.0" /> <dependency id="System.Text.RegularExpressions" version="4.0.0" /> + <dependency id="System.Threading" version="4.0.0" /> </group> </dependencies> </metadata> @@ -49,18 +50,5 @@ <file src="bin/ReleaseSigned/Google.Protobuf.pdb" target="lib/dotnet" /> <file src="bin/ReleaseSigned/Google.Protobuf.xml" target="lib/dotnet" /> <file src="**\*.cs" target="src" /> - <file src="..\..\..\cmake\Release\protoc.exe" target="tools" /> - <file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\api.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\descriptor.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\duration.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\empty.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\field_mask.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\source_context.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\struct.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\timestamp.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\any.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\type.proto" target="tools\google\protobuf" /> - <file src="..\..\..\src\google\protobuf\wrappers.proto" target="tools\google\protobuf" /> </files> </package>
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs index eb959c9f..83772473 100644 --- a/csharp/src/Google.Protobuf/JsonFormatter.cs +++ b/csharp/src/Google.Protobuf/JsonFormatter.cs @@ -39,6 +39,7 @@ using Google.Protobuf.WellKnownTypes; using System.IO; using System.Linq; using System.Collections.Generic; +using System.Reflection; namespace Google.Protobuf { @@ -237,11 +238,13 @@ namespace Google.Protobuf { writer.Write(PropertySeparator); } - WriteString(writer, ToCamelCase(accessor.Descriptor.Name)); + + WriteString(writer, accessor.Descriptor.JsonName); writer.Write(NameValueSeparator); WriteValue(writer, value); + first = false; - } + } return !first; } @@ -418,9 +421,10 @@ namespace Google.Protobuf } else if (value is System.Enum) { - if (System.Enum.IsDefined(value.GetType(), value)) + string name = OriginalEnumValueHelper.GetOriginalName(value); + if (name != null) { - WriteString(writer, value.ToString()); + WriteString(writer, name); } else { @@ -563,7 +567,7 @@ namespace Google.Protobuf string typeUrl = (string) value.Descriptor.Fields[Any.TypeUrlFieldNumber].Accessor.GetValue(value); ByteString data = (ByteString) value.Descriptor.Fields[Any.ValueFieldNumber].Accessor.GetValue(value); - string typeName = GetTypeName(typeUrl); + string typeName = Any.GetTypeName(typeUrl); MessageDescriptor descriptor = settings.TypeRegistry.Find(typeName); if (descriptor == null) { @@ -604,17 +608,7 @@ namespace Google.Protobuf writer.Write(data.ToBase64()); writer.Write('"'); writer.Write(" }"); - } - - internal static string GetTypeName(String typeUrl) - { - string[] parts = typeUrl.Split('/'); - if (parts.Length != 2 || parts[0] != TypeUrlPrefix) - { - throw new InvalidProtocolBufferException($"Invalid type url: {typeUrl}"); - } - return parts[1]; - } + } private void WriteStruct(TextWriter writer, IMessage message) { @@ -875,5 +869,44 @@ namespace Google.Protobuf TypeRegistry = ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry)); } } + + // Effectively a cache of mapping from enum values to the original name as specified in the proto file, + // fetched by reflection. + // The need for this is unfortunate, as is its unbounded size, but realistically it shouldn't cause issues. + private static class OriginalEnumValueHelper + { + // TODO: In the future we might want to use ConcurrentDictionary, at the point where all + // the platforms we target have it. + private static readonly Dictionary<System.Type, Dictionary<object, string>> dictionaries + = new Dictionary<System.Type, Dictionary<object, string>>(); + + internal static string GetOriginalName(object value) + { + var enumType = value.GetType(); + Dictionary<object, string> nameMapping; + lock (dictionaries) + { + if (!dictionaries.TryGetValue(enumType, out nameMapping)) + { + nameMapping = GetNameMapping(enumType); + dictionaries[enumType] = nameMapping; + } + } + + string originalName; + // If this returns false, originalName will be null, which is what we want. + nameMapping.TryGetValue(value, out originalName); + return originalName; + } + + private static Dictionary<object, string> GetNameMapping(System.Type enumType) => + enumType.GetTypeInfo().DeclaredFields + .Where(f => f.IsStatic) + .ToDictionary(f => f.GetValue(null), + f => f.GetCustomAttributes<OriginalNameAttribute>() + .FirstOrDefault() + // If the attribute hasn't been applied, fall back to the name of the field. + ?.Name ?? f.Name); + } } } diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs index 80d3013d..d738ebb0 100644 --- a/csharp/src/Google.Protobuf/JsonParser.cs +++ b/csharp/src/Google.Protobuf/JsonParser.cs @@ -513,7 +513,7 @@ namespace Google.Protobuf throw new InvalidProtocolBufferException("Expected string value for Any.@type"); } string typeUrl = token.StringValue; - string typeName = JsonFormatter.GetTypeName(typeUrl); + string typeName = Any.GetTypeName(typeUrl); MessageDescriptor descriptor = settings.TypeRegistry.Find(typeName); if (descriptor == null) diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index 7de7b5fc..fa138dfe 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -80,7 +80,7 @@ namespace Google.Protobuf.Reflection { "EhMKC291dHB1dF90eXBlGAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5nb29n", "bGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFtaW5n", "GAUgASgIOgVmYWxzZRIfChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVmYWxz", - "ZSKuBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwKFGph", + "ZSKHBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwKFGph", "dmFfb3V0ZXJfY2xhc3NuYW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVfZmls", "ZXMYCiABKAg6BWZhbHNlEiwKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2FuZF9o", "YXNoGBQgASgIOgVmYWxzZRIlChZqYXZhX3N0cmluZ19jaGVja191dGY4GBsg", @@ -91,54 +91,53 @@ namespace Google.Protobuf.Reflection { "cHlfZ2VuZXJpY19zZXJ2aWNlcxgSIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl", "ZBgXIAEoCDoFZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFs", "c2USGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVz", - "cGFjZRglIAEoCRIrCh9qYXZhbmFub191c2VfZGVwcmVjYXRlZF9wYWNrYWdl", - "GCYgASgIQgIYARJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5n", + "cGFjZRglIAEoCRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5n", "b29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiI6CgxPcHRpbWl6", "ZU1vZGUSCQoFU1BFRUQQARINCglDT0RFX1NJWkUQAhIQCgxMSVRFX1JVTlRJ", - "TUUQAyoJCOgHEICAgIACIuYBCg5NZXNzYWdlT3B0aW9ucxImChdtZXNzYWdl", - "X3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9fc3RhbmRhcmRf", - "ZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl", - "ZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMKFHVuaW50ZXJw", - "cmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVy", - "cHJldGVkT3B0aW9uKgkI6AcQgICAgAIimAMKDEZpZWxkT3B0aW9ucxI6CgVj", - "dHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMuQ1R5", - "cGU6BlNUUklORxIOCgZwYWNrZWQYAiABKAgSPwoGanN0eXBlGAYgASgOMiQu", - "Z29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5cGU6CUpTX05PUk1B", - "TBITCgRsYXp5GAUgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVm", - "YWxzZRITCgR3ZWFrGAogASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29w", + "TUUQAyoJCOgHEICAgIACSgQIJhAnIuYBCg5NZXNzYWdlT3B0aW9ucxImChdt", + "ZXNzYWdlX3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9fc3Rh", + "bmRhcmRfZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoKZGVw", + "cmVjYXRlZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMKFHVu", + "aW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5V", + "bmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIimAMKDEZpZWxkT3B0aW9u", + "cxI6CgVjdHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlv", + "bnMuQ1R5cGU6BlNUUklORxIOCgZwYWNrZWQYAiABKAgSPwoGanN0eXBlGAYg", + "ASgOMiQuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5cGU6CUpT", + "X05PUk1BTBITCgRsYXp5GAUgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMg", + "ASgIOgVmYWxzZRITCgR3ZWFrGAogASgIOgVmYWxzZRJDChR1bmludGVycHJl", + "dGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnBy", + "ZXRlZE9wdGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JEEAESEAoM", + "U1RSSU5HX1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAAEg0KCUpT", + "X1NUUklORxABEg0KCUpTX05VTUJFUhACKgkI6AcQgICAgAIijQEKC0VudW1P", + "cHRpb25zEhMKC2FsbG93X2FsaWFzGAIgASgIEhkKCmRlcHJlY2F0ZWQYAyAB", + "KAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdv", + "b2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi", + "fQoQRW51bVZhbHVlT3B0aW9ucxIZCgpkZXByZWNhdGVkGAEgASgIOgVmYWxz", + "ZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJv", + "dG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACInsKDlNlcnZp", + "Y2VPcHRpb25zEhkKCmRlcHJlY2F0ZWQYISABKAg6BWZhbHNlEkMKFHVuaW50", + "ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu", + "dGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIiegoNTWV0aG9kT3B0aW9ucxIZ", + "CgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29w", "dGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9w", - "dGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JEEAESEAoMU1RSSU5H", - "X1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAAEg0KCUpTX1NUUklO", - "RxABEg0KCUpTX05VTUJFUhACKgkI6AcQgICAgAIijQEKC0VudW1PcHRpb25z", - "EhMKC2FsbG93X2FsaWFzGAIgASgIEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZh", - "bHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5w", - "cm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIifQoQRW51", - "bVZhbHVlT3B0aW9ucxIZCgpkZXByZWNhdGVkGAEgASgIOgVmYWxzZRJDChR1", - "bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYu", - "VW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACInsKDlNlcnZpY2VPcHRp", - "b25zEhkKCmRlcHJlY2F0ZWQYISABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0", - "ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJl", - "dGVkT3B0aW9uKgkI6AcQgICAgAIiegoNTWV0aG9kT3B0aW9ucxIZCgpkZXBy", - "ZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjn", - "ByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJ", - "COgHEICAgIACIp4CChNVbmludGVycHJldGVkT3B0aW9uEjsKBG5hbWUYAiAD", - "KAsyLS5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbi5OYW1l", - "UGFydBIYChBpZGVudGlmaWVyX3ZhbHVlGAMgASgJEhoKEnBvc2l0aXZlX2lu", - "dF92YWx1ZRgEIAEoBBIaChJuZWdhdGl2ZV9pbnRfdmFsdWUYBSABKAMSFAoM", - "ZG91YmxlX3ZhbHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgHIAEoDBIXCg9h", - "Z2dyZWdhdGVfdmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJbmFtZV9wYXJ0", - "GAEgAigJEhQKDGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291cmNlQ29kZUlu", - "Zm8SOgoIbG9jYXRpb24YASADKAsyKC5nb29nbGUucHJvdG9idWYuU291cmNl", - "Q29kZUluZm8uTG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBhdGgYASADKAVC", - "AhABEhAKBHNwYW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29tbWVudHMYAyAB", - "KAkSGQoRdHJhaWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVhZGluZ19kZXRh", - "Y2hlZF9jb21tZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29kZUluZm8SQQoK", - "YW5ub3RhdGlvbhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5HZW5lcmF0ZWRD", - "b2RlSW5mby5Bbm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoEcGF0aBgBIAMo", - "BUICEAESEwoLc291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4YAyABKAUSCwoD", - "ZW5kGAQgASgFQlgKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2NyaXB0b3JQ", - "cm90b3NIAVoKZGVzY3JpcHRvcqICA0dQQqoCGkdvb2dsZS5Qcm90b2J1Zi5S", - "ZWZsZWN0aW9u")); + "dGlvbioJCOgHEICAgIACIp4CChNVbmludGVycHJldGVkT3B0aW9uEjsKBG5h", + "bWUYAiADKAsyLS5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlv", + "bi5OYW1lUGFydBIYChBpZGVudGlmaWVyX3ZhbHVlGAMgASgJEhoKEnBvc2l0", + "aXZlX2ludF92YWx1ZRgEIAEoBBIaChJuZWdhdGl2ZV9pbnRfdmFsdWUYBSAB", + "KAMSFAoMZG91YmxlX3ZhbHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgHIAEo", + "DBIXCg9hZ2dyZWdhdGVfdmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJbmFt", + "ZV9wYXJ0GAEgAigJEhQKDGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291cmNl", + "Q29kZUluZm8SOgoIbG9jYXRpb24YASADKAsyKC5nb29nbGUucHJvdG9idWYu", + "U291cmNlQ29kZUluZm8uTG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBhdGgY", + "ASADKAVCAhABEhAKBHNwYW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29tbWVu", + "dHMYAyABKAkSGQoRdHJhaWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVhZGlu", + "Z19kZXRhY2hlZF9jb21tZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29kZUlu", + "Zm8SQQoKYW5ub3RhdGlvbhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5HZW5l", + "cmF0ZWRDb2RlSW5mby5Bbm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoEcGF0", + "aBgBIAMoBUICEAESEwoLc291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4YAyAB", + "KAUSCwoDZW5kGAQgASgFQlgKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2Ny", + "aXB0b3JQcm90b3NIAVoKZGVzY3JpcHRvcqICA0dQQqoCGkdvb2dsZS5Qcm90", + "b2J1Zi5SZWZsZWN0aW9u")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { @@ -152,7 +151,7 @@ namespace Google.Protobuf.Reflection { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "JavananoUseDeprecatedPackage", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null), new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null), @@ -1291,7 +1290,7 @@ namespace Google.Protobuf.Reflection { /// <summary>Field number for the "label" field.</summary> public const int LabelFieldNumber = 4; - private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL; + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_ = 0; public global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label Label { get { return label_; } set { @@ -1301,7 +1300,7 @@ namespace Google.Protobuf.Reflection { /// <summary>Field number for the "type" field.</summary> public const int TypeFieldNumber = 5; - private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE; + private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = 0; /// <summary> /// If type_name is set, this need not be set. If both this and type_name /// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. @@ -1429,8 +1428,8 @@ namespace Google.Protobuf.Reflection { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Number != 0) hash ^= Number.GetHashCode(); - if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) hash ^= Label.GetHashCode(); - if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) hash ^= Type.GetHashCode(); + if (Label != 0) hash ^= Label.GetHashCode(); + if (Type != 0) hash ^= Type.GetHashCode(); if (TypeName.Length != 0) hash ^= TypeName.GetHashCode(); if (Extendee.Length != 0) hash ^= Extendee.GetHashCode(); if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode(); @@ -1457,11 +1456,11 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(24); output.WriteInt32(Number); } - if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + if (Label != 0) { output.WriteRawTag(32); output.WriteEnum((int) Label); } - if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + if (Type != 0) { output.WriteRawTag(40); output.WriteEnum((int) Type); } @@ -1495,10 +1494,10 @@ namespace Google.Protobuf.Reflection { if (Number != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number); } - if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + if (Label != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label); } - if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + if (Type != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type); } if (TypeName.Length != 0) { @@ -1532,10 +1531,10 @@ namespace Google.Protobuf.Reflection { if (other.Number != 0) { Number = other.Number; } - if (other.Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) { + if (other.Label != 0) { Label = other.Label; } - if (other.Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) { + if (other.Type != 0) { Type = other.Type; } if (other.TypeName.Length != 0) { @@ -1624,59 +1623,59 @@ namespace Google.Protobuf.Reflection { /// 0 is reserved for errors. /// Order is weird for historical reasons. /// </summary> - TYPE_DOUBLE = 1, - TYPE_FLOAT = 2, + [pbr::OriginalName("TYPE_DOUBLE")] Double = 1, + [pbr::OriginalName("TYPE_FLOAT")] Float = 2, /// <summary> /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if /// negative values are likely. /// </summary> - TYPE_INT64 = 3, - TYPE_UINT64 = 4, + [pbr::OriginalName("TYPE_INT64")] Int64 = 3, + [pbr::OriginalName("TYPE_UINT64")] Uint64 = 4, /// <summary> /// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if /// negative values are likely. /// </summary> - TYPE_INT32 = 5, - TYPE_FIXED64 = 6, - TYPE_FIXED32 = 7, - TYPE_BOOL = 8, - TYPE_STRING = 9, + [pbr::OriginalName("TYPE_INT32")] Int32 = 5, + [pbr::OriginalName("TYPE_FIXED64")] Fixed64 = 6, + [pbr::OriginalName("TYPE_FIXED32")] Fixed32 = 7, + [pbr::OriginalName("TYPE_BOOL")] Bool = 8, + [pbr::OriginalName("TYPE_STRING")] String = 9, /// <summary> /// Tag-delimited aggregate. /// </summary> - TYPE_GROUP = 10, + [pbr::OriginalName("TYPE_GROUP")] Group = 10, /// <summary> /// Length-delimited aggregate. /// </summary> - TYPE_MESSAGE = 11, + [pbr::OriginalName("TYPE_MESSAGE")] Message = 11, /// <summary> /// New in version 2. /// </summary> - TYPE_BYTES = 12, - TYPE_UINT32 = 13, - TYPE_ENUM = 14, - TYPE_SFIXED32 = 15, - TYPE_SFIXED64 = 16, + [pbr::OriginalName("TYPE_BYTES")] Bytes = 12, + [pbr::OriginalName("TYPE_UINT32")] Uint32 = 13, + [pbr::OriginalName("TYPE_ENUM")] Enum = 14, + [pbr::OriginalName("TYPE_SFIXED32")] Sfixed32 = 15, + [pbr::OriginalName("TYPE_SFIXED64")] Sfixed64 = 16, /// <summary> /// Uses ZigZag encoding. /// </summary> - TYPE_SINT32 = 17, + [pbr::OriginalName("TYPE_SINT32")] Sint32 = 17, /// <summary> /// Uses ZigZag encoding. /// </summary> - TYPE_SINT64 = 18, + [pbr::OriginalName("TYPE_SINT64")] Sint64 = 18, } internal enum Label { /// <summary> /// 0 is reserved for errors /// </summary> - LABEL_OPTIONAL = 1, - LABEL_REQUIRED = 2, + [pbr::OriginalName("LABEL_OPTIONAL")] Optional = 1, + [pbr::OriginalName("LABEL_REQUIRED")] Required = 2, /// <summary> /// TODO(sanjay): Should we add LABEL_MAP? /// </summary> - LABEL_REPEATED = 3, + [pbr::OriginalName("LABEL_REPEATED")] Repeated = 3, } } @@ -2563,7 +2562,6 @@ namespace Google.Protobuf.Reflection { ccEnableArenas_ = other.ccEnableArenas_; objcClassPrefix_ = other.objcClassPrefix_; csharpNamespace_ = other.csharpNamespace_; - javananoUseDeprecatedPackage_ = other.javananoUseDeprecatedPackage_; uninterpretedOption_ = other.uninterpretedOption_.Clone(); } @@ -2666,7 +2664,7 @@ namespace Google.Protobuf.Reflection { /// <summary>Field number for the "optimize_for" field.</summary> public const int OptimizeForFieldNumber = 9; - private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED; + private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_ = 0; public global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode OptimizeFor { get { return optimizeFor_; } set { @@ -2790,21 +2788,6 @@ namespace Google.Protobuf.Reflection { } } - /// <summary>Field number for the "javanano_use_deprecated_package" field.</summary> - public const int JavananoUseDeprecatedPackageFieldNumber = 38; - private bool javananoUseDeprecatedPackage_; - /// <summary> - /// Whether the nano proto compiler should generate in the deprecated non-nano - /// suffixed package. - /// </summary> - [global::System.ObsoleteAttribute()] - public bool JavananoUseDeprecatedPackage { - get { return javananoUseDeprecatedPackage_; } - set { - javananoUseDeprecatedPackage_ = value; - } - } - /// <summary>Field number for the "uninterpreted_option" field.</summary> public const int UninterpretedOptionFieldNumber = 999; private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec @@ -2842,7 +2825,6 @@ namespace Google.Protobuf.Reflection { if (CcEnableArenas != other.CcEnableArenas) return false; if (ObjcClassPrefix != other.ObjcClassPrefix) return false; if (CsharpNamespace != other.CsharpNamespace) return false; - if (JavananoUseDeprecatedPackage != other.JavananoUseDeprecatedPackage) return false; if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false; return true; } @@ -2854,7 +2836,7 @@ namespace Google.Protobuf.Reflection { if (JavaMultipleFiles != false) hash ^= JavaMultipleFiles.GetHashCode(); if (JavaGenerateEqualsAndHash != false) hash ^= JavaGenerateEqualsAndHash.GetHashCode(); if (JavaStringCheckUtf8 != false) hash ^= JavaStringCheckUtf8.GetHashCode(); - if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) hash ^= OptimizeFor.GetHashCode(); + if (OptimizeFor != 0) hash ^= OptimizeFor.GetHashCode(); if (GoPackage.Length != 0) hash ^= GoPackage.GetHashCode(); if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode(); if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode(); @@ -2863,7 +2845,6 @@ namespace Google.Protobuf.Reflection { if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode(); if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode(); if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode(); - if (JavananoUseDeprecatedPackage != false) hash ^= JavananoUseDeprecatedPackage.GetHashCode(); hash ^= uninterpretedOption_.GetHashCode(); return hash; } @@ -2881,7 +2862,7 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(66); output.WriteString(JavaOuterClassname); } - if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { + if (OptimizeFor != 0) { output.WriteRawTag(72); output.WriteEnum((int) OptimizeFor); } @@ -2929,10 +2910,6 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(170, 2); output.WriteString(CsharpNamespace); } - if (JavananoUseDeprecatedPackage != false) { - output.WriteRawTag(176, 2); - output.WriteBool(JavananoUseDeprecatedPackage); - } uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec); } @@ -2953,7 +2930,7 @@ namespace Google.Protobuf.Reflection { if (JavaStringCheckUtf8 != false) { size += 2 + 1; } - if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { + if (OptimizeFor != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor); } if (GoPackage.Length != 0) { @@ -2980,9 +2957,6 @@ namespace Google.Protobuf.Reflection { if (CsharpNamespace.Length != 0) { size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace); } - if (JavananoUseDeprecatedPackage != false) { - size += 2 + 1; - } size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec); return size; } @@ -3006,7 +2980,7 @@ namespace Google.Protobuf.Reflection { if (other.JavaStringCheckUtf8 != false) { JavaStringCheckUtf8 = other.JavaStringCheckUtf8; } - if (other.OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) { + if (other.OptimizeFor != 0) { OptimizeFor = other.OptimizeFor; } if (other.GoPackage.Length != 0) { @@ -3033,9 +3007,6 @@ namespace Google.Protobuf.Reflection { if (other.CsharpNamespace.Length != 0) { CsharpNamespace = other.CsharpNamespace; } - if (other.JavananoUseDeprecatedPackage != false) { - JavananoUseDeprecatedPackage = other.JavananoUseDeprecatedPackage; - } uninterpretedOption_.Add(other.uninterpretedOption_); } @@ -3102,10 +3073,6 @@ namespace Google.Protobuf.Reflection { CsharpNamespace = input.ReadString(); break; } - case 304: { - JavananoUseDeprecatedPackage = input.ReadBool(); - break; - } case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); break; @@ -3125,15 +3092,15 @@ namespace Google.Protobuf.Reflection { /// <summary> /// Generate complete code for parsing, serialization, /// </summary> - SPEED = 1, + [pbr::OriginalName("SPEED")] Speed = 1, /// <summary> /// etc. /// </summary> - CODE_SIZE = 2, + [pbr::OriginalName("CODE_SIZE")] CodeSize = 2, /// <summary> /// Generate code using MessageLite and the lite runtime. /// </summary> - LITE_RUNTIME = 3, + [pbr::OriginalName("LITE_RUNTIME")] LiteRuntime = 3, } } @@ -3436,7 +3403,7 @@ namespace Google.Protobuf.Reflection { /// <summary>Field number for the "ctype" field.</summary> public const int CtypeFieldNumber = 1; - private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING; + private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = 0; /// <summary> /// The ctype option instructs the C++ code generator to use a different /// representation of the field than it normally would. See the specific @@ -3469,7 +3436,7 @@ namespace Google.Protobuf.Reflection { /// <summary>Field number for the "jstype" field.</summary> public const int JstypeFieldNumber = 6; - private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL; + private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = 0; /// <summary> /// The jstype option determines the JavaScript type used for values of the /// field. The option is permitted only for 64 bit integral and fixed types @@ -3591,9 +3558,9 @@ namespace Google.Protobuf.Reflection { public override int GetHashCode() { int hash = 1; - if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) hash ^= Ctype.GetHashCode(); + if (Ctype != 0) hash ^= Ctype.GetHashCode(); if (Packed != false) hash ^= Packed.GetHashCode(); - if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) hash ^= Jstype.GetHashCode(); + if (Jstype != 0) hash ^= Jstype.GetHashCode(); if (Lazy != false) hash ^= Lazy.GetHashCode(); if (Deprecated != false) hash ^= Deprecated.GetHashCode(); if (Weak != false) hash ^= Weak.GetHashCode(); @@ -3606,7 +3573,7 @@ namespace Google.Protobuf.Reflection { } public void WriteTo(pb::CodedOutputStream output) { - if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { + if (Ctype != 0) { output.WriteRawTag(8); output.WriteEnum((int) Ctype); } @@ -3622,7 +3589,7 @@ namespace Google.Protobuf.Reflection { output.WriteRawTag(40); output.WriteBool(Lazy); } - if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { + if (Jstype != 0) { output.WriteRawTag(48); output.WriteEnum((int) Jstype); } @@ -3635,13 +3602,13 @@ namespace Google.Protobuf.Reflection { public int CalculateSize() { int size = 0; - if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { + if (Ctype != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype); } if (Packed != false) { size += 1 + 1; } - if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { + if (Jstype != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype); } if (Lazy != false) { @@ -3661,13 +3628,13 @@ namespace Google.Protobuf.Reflection { if (other == null) { return; } - if (other.Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) { + if (other.Ctype != 0) { Ctype = other.Ctype; } if (other.Packed != false) { Packed = other.Packed; } - if (other.Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) { + if (other.Jstype != 0) { Jstype = other.Jstype; } if (other.Lazy != false) { @@ -3729,24 +3696,24 @@ namespace Google.Protobuf.Reflection { /// <summary> /// Default mode. /// </summary> - STRING = 0, - CORD = 1, - STRING_PIECE = 2, + [pbr::OriginalName("STRING")] String = 0, + [pbr::OriginalName("CORD")] Cord = 1, + [pbr::OriginalName("STRING_PIECE")] StringPiece = 2, } internal enum JSType { /// <summary> /// Use the default type. /// </summary> - JS_NORMAL = 0, + [pbr::OriginalName("JS_NORMAL")] JsNormal = 0, /// <summary> /// Use JavaScript strings. /// </summary> - JS_STRING = 1, + [pbr::OriginalName("JS_STRING")] JsString = 1, /// <summary> /// Use JavaScript numbers. /// </summary> - JS_NUMBER = 2, + [pbr::OriginalName("JS_NUMBER")] JsNumber = 2, } } diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs index c6caaec6..6c6f6ee0 100644 --- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs @@ -30,9 +30,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endregion -using System; -using System.Linq; using Google.Protobuf.Compatibility; +using System; namespace Google.Protobuf.Reflection { @@ -41,20 +40,35 @@ namespace Google.Protobuf.Reflection /// </summary> public sealed class FieldDescriptor : DescriptorBase, IComparable<FieldDescriptor> { - private readonly FieldDescriptorProto proto; private EnumDescriptor enumType; private MessageDescriptor messageType; - private readonly MessageDescriptor containingType; - private readonly OneofDescriptor containingOneof; private FieldType fieldType; private readonly string propertyName; // Annoyingly, needed in Crosslink. private IFieldAccessor accessor; + /// <summary> + /// Get the field's containing message type. + /// </summary> + public MessageDescriptor ContainingType { get; } + + /// <summary> + /// Returns the oneof containing this field, or <c>null</c> if it is not part of a oneof. + /// </summary> + public OneofDescriptor ContainingOneof { get; } + + /// <summary> + /// The effective JSON name for this field. This is usually the lower-camel-cased form of the field name, + /// but can be overridden using the <c>json_name</c> option in the .proto file. + /// </summary> + public string JsonName { get; } + + internal FieldDescriptorProto Proto { get; } + internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, string propertyName) : base(file, file.ComputeFullName(parent, proto.Name), index) { - this.proto = proto; + Proto = proto; if (proto.Type != 0) { fieldType = GetFieldTypeFromProtoType(proto.Type); @@ -64,7 +78,7 @@ namespace Google.Protobuf.Reflection { throw new DescriptorValidationException(this, "Field numbers must be positive integers."); } - containingType = parent; + ContainingType = parent; // OneofIndex "defaults" to -1 due to a hack in FieldDescriptor.OnConstruction. if (proto.OneofIndex != -1) { @@ -73,7 +87,7 @@ namespace Google.Protobuf.Reflection throw new DescriptorValidationException(this, $"FieldDescriptorProto.oneof_index is out of range for type {parent.Name}"); } - containingOneof = parent.Oneofs[proto.OneofIndex]; + ContainingOneof = parent.Oneofs[proto.OneofIndex]; } file.DescriptorPool.AddSymbol(this); @@ -83,14 +97,14 @@ namespace Google.Protobuf.Reflection // We could trust the generated code and check whether the type of the property is // a MapField, but that feels a tad nasty. this.propertyName = propertyName; + JsonName = Proto.JsonName == "" ? JsonFormatter.ToCamelCase(Proto.Name) : Proto.JsonName; } + /// <summary> /// The brief name of the descriptor's target. /// </summary> - public override string Name { get { return proto.Name; } } - - internal FieldDescriptorProto Proto { get { return proto; } } + public override string Name => Proto.Name; /// <summary> /// Returns the accessor for this field. @@ -110,7 +124,7 @@ namespace Google.Protobuf.Reflection /// and this property will return null. /// </para> /// </remarks> - public IFieldAccessor Accessor { get { return accessor; } } + public IFieldAccessor Accessor => accessor; /// <summary> /// Maps a field type as included in the .proto file to a FieldType. @@ -119,41 +133,41 @@ namespace Google.Protobuf.Reflection { switch (type) { - case FieldDescriptorProto.Types.Type.TYPE_DOUBLE: + case FieldDescriptorProto.Types.Type.Double: return FieldType.Double; - case FieldDescriptorProto.Types.Type.TYPE_FLOAT: + case FieldDescriptorProto.Types.Type.Float: return FieldType.Float; - case FieldDescriptorProto.Types.Type.TYPE_INT64: + case FieldDescriptorProto.Types.Type.Int64: return FieldType.Int64; - case FieldDescriptorProto.Types.Type.TYPE_UINT64: + case FieldDescriptorProto.Types.Type.Uint64: return FieldType.UInt64; - case FieldDescriptorProto.Types.Type.TYPE_INT32: + case FieldDescriptorProto.Types.Type.Int32: return FieldType.Int32; - case FieldDescriptorProto.Types.Type.TYPE_FIXED64: + case FieldDescriptorProto.Types.Type.Fixed64: return FieldType.Fixed64; - case FieldDescriptorProto.Types.Type.TYPE_FIXED32: + case FieldDescriptorProto.Types.Type.Fixed32: return FieldType.Fixed32; - case FieldDescriptorProto.Types.Type.TYPE_BOOL: + case FieldDescriptorProto.Types.Type.Bool: return FieldType.Bool; - case FieldDescriptorProto.Types.Type.TYPE_STRING: + case FieldDescriptorProto.Types.Type.String: return FieldType.String; - case FieldDescriptorProto.Types.Type.TYPE_GROUP: + case FieldDescriptorProto.Types.Type.Group: return FieldType.Group; - case FieldDescriptorProto.Types.Type.TYPE_MESSAGE: + case FieldDescriptorProto.Types.Type.Message: return FieldType.Message; - case FieldDescriptorProto.Types.Type.TYPE_BYTES: + case FieldDescriptorProto.Types.Type.Bytes: return FieldType.Bytes; - case FieldDescriptorProto.Types.Type.TYPE_UINT32: + case FieldDescriptorProto.Types.Type.Uint32: return FieldType.UInt32; - case FieldDescriptorProto.Types.Type.TYPE_ENUM: + case FieldDescriptorProto.Types.Type.Enum: return FieldType.Enum; - case FieldDescriptorProto.Types.Type.TYPE_SFIXED32: + case FieldDescriptorProto.Types.Type.Sfixed32: return FieldType.SFixed32; - case FieldDescriptorProto.Types.Type.TYPE_SFIXED64: + case FieldDescriptorProto.Types.Type.Sfixed64: return FieldType.SFixed64; - case FieldDescriptorProto.Types.Type.TYPE_SINT32: + case FieldDescriptorProto.Types.Type.Sint32: return FieldType.SInt32; - case FieldDescriptorProto.Types.Type.TYPE_SINT64: + case FieldDescriptorProto.Types.Type.Sint64: return FieldType.SInt64; default: throw new ArgumentException("Invalid type specified"); @@ -163,62 +177,32 @@ namespace Google.Protobuf.Reflection /// <summary> /// Returns <c>true</c> if this field is a repeated field; <c>false</c> otherwise. /// </summary> - public bool IsRepeated - { - get { return Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED; } - } + public bool IsRepeated => Proto.Label == FieldDescriptorProto.Types.Label.Repeated; /// <summary> /// Returns <c>true</c> if this field is a map field; <c>false</c> otherwise. /// </summary> - public bool IsMap - { - get { return fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry; } - } + public bool IsMap => fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry; /// <summary> /// Returns <c>true</c> if this field is a packed, repeated field; <c>false</c> otherwise. /// </summary> - public bool IsPacked - { + public bool IsPacked => // Note the || rather than && here - we're effectively defaulting to packed, because that *is* // the default in proto3, which is all we support. We may give the wrong result for the protos // within descriptor.proto, but that's okay, as they're never exposed and we don't use IsPacked // within the runtime. - get { return Proto.Options == null || Proto.Options.Packed; } - } - - /// <summary> - /// Get the field's containing message type. - /// </summary> - public MessageDescriptor ContainingType - { - get { return containingType; } - } - - /// <summary> - /// Returns the oneof containing this field, or <c>null</c> if it is not part of a oneof. - /// </summary> - public OneofDescriptor ContainingOneof - { - get { return containingOneof; } - } - + Proto.Options == null || Proto.Options.Packed; + /// <summary> /// Returns the type of the field. /// </summary> - public FieldType FieldType - { - get { return fieldType; } - } + public FieldType FieldType => fieldType; /// <summary> /// Returns the field number declared in the proto file. /// </summary> - public int FieldNumber - { - get { return Proto.Number; } - } + public int FieldNumber => Proto.Number; /// <summary> /// Compares this descriptor with another one, ordering in "canonical" order @@ -228,7 +212,7 @@ namespace Google.Protobuf.Reflection /// </summary> public int CompareTo(FieldDescriptor other) { - if (other.containingType != containingType) + if (other.ContainingType != ContainingType) { throw new ArgumentException("FieldDescriptors can only be compared to other FieldDescriptors " + "for fields of the same message type."); @@ -331,14 +315,14 @@ namespace Google.Protobuf.Reflection File.DescriptorPool.AddFieldByNumber(this); - if (containingType != null && containingType.Proto.Options != null && containingType.Proto.Options.MessageSetWireFormat) + if (ContainingType != null && ContainingType.Proto.Options != null && ContainingType.Proto.Options.MessageSetWireFormat) { throw new DescriptorValidationException(this, "MessageSet format is not supported."); } - accessor = CreateAccessor(propertyName); + accessor = CreateAccessor(); } - private IFieldAccessor CreateAccessor(string propertyName) + private IFieldAccessor CreateAccessor() { // If we're given no property name, that's because we really don't want an accessor. // (At the moment, that means it's a map entry message...) @@ -346,10 +330,10 @@ namespace Google.Protobuf.Reflection { return null; } - var property = containingType.ClrType.GetProperty(propertyName); + var property = ContainingType.ClrType.GetProperty(propertyName); if (property == null) { - throw new DescriptorValidationException(this, $"Property {propertyName} not found in {containingType.ClrType}"); + throw new DescriptorValidationException(this, $"Property {propertyName} not found in {ContainingType.ClrType}"); } return IsMap ? new MapFieldAccessor(property, this) : IsRepeated ? new RepeatedFieldAccessor(property, this) diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs index f5798d1e..f5a835e5 100644 --- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs @@ -102,8 +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; + map[field.JsonName] = field; } return new ReadOnlyDictionary<string, FieldDescriptor>(map); } diff --git a/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs b/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs new file mode 100644 index 00000000..27f9ab98 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs @@ -0,0 +1,58 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#endregion + +using System; + +namespace Google.Protobuf.Reflection +{ + /// <summary> + /// Specifies the original name (in the .proto file) of a named element, + /// such as an enum value. + /// </summary> + [AttributeUsage(AttributeTargets.Field)] + public class OriginalNameAttribute : Attribute + { + /// <summary> + /// The name of the element in the .proto file. + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Constructs a new attribute instance for the given name. + /// </summary> + /// <param name="name">The name of the element in the .proto file.</param> + public OriginalNameAttribute(string name) + { + Name = ProtoPreconditions.CheckNotNull(name, nameof(name)); + } + } +}
\ No newline at end of file diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs index 48cd99a1..871a383f 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs @@ -24,9 +24,10 @@ namespace Google.Protobuf.WellKnownTypes { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi", - "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQksKE2Nv", - "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAGgAQGiAgNHUEKqAh5Hb29n", - "bGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); + "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnIKE2Nv", + "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaJWdpdGh1Yi5jb20vZ29s", + "YW5nL3Byb3RvYnVmL3B0eXBlcy9hbnmgAQGiAgNHUEKqAh5Hb29nbGUuUHJv", + "dG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { @@ -38,8 +39,36 @@ namespace Google.Protobuf.WellKnownTypes { } #region Messages /// <summary> - /// `Any` contains an arbitrary serialized message along with a URL - /// that describes the type of the serialized message. + /// `Any` contains an arbitrary serialized protocol buffer message along with a + /// URL that describes the type of the serialized message. + /// + /// Protobuf library provides support to pack/unpack Any values in the form + /// of utility functions or additional generated methods of the Any type. + /// + /// Example 1: Pack and unpack a message in C++. + /// + /// Foo foo = ...; + /// Any any; + /// any.PackFrom(foo); + /// ... + /// if (any.UnpackTo(&foo)) { + /// ... + /// } + /// + /// Example 2: Pack and unpack a message in Java. + /// + /// Foo foo = ...; + /// Any any = Any.pack(foo); + /// ... + /// if (any.is(Foo.class)) { + /// foo = any.unpack(Foo.class); + /// } + /// + /// The pack methods provided by protobuf library will by default use + /// 'type.googleapis.com/full.type.name' as the type URL and the unpack + /// methods only use the fully qualified type name after the last '/' + /// in the type URL, for example "foo.bar.com/x/y.z" will yield type + /// name "y.z". /// /// JSON /// ==== @@ -102,7 +131,7 @@ namespace Google.Protobuf.WellKnownTypes { private string typeUrl_ = ""; /// <summary> /// A URL/resource name whose content describes the type of the - /// serialized message. + /// serialized protocol buffer message. /// /// For URLs which use the schema `http`, `https`, or no schema, the /// following restrictions and interpretations apply: @@ -110,6 +139,8 @@ namespace Google.Protobuf.WellKnownTypes { /// * If no schema is provided, `https` is assumed. /// * The last segment of the URL's path must represent the fully /// qualified name of the type (as in `path/google.protobuf.Duration`). + /// The name should be in a canonical form (e.g., leading "." is + /// not accepted). /// * An HTTP GET on the URL must yield a [google.protobuf.Type][] /// value in binary format, or produce an error. /// * Applications are allowed to cache lookup results based on the @@ -132,7 +163,7 @@ namespace Google.Protobuf.WellKnownTypes { public const int ValueFieldNumber = 2; private pb::ByteString value_ = pb::ByteString.Empty; /// <summary> - /// Must be valid serialized data of the above specified type. + /// Must be a valid serialized protocol buffer of the above specified type. /// </summary> public pb::ByteString Value { get { return value_; } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs index 9d43856e..f4fac738 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs @@ -36,11 +36,27 @@ namespace Google.Protobuf.WellKnownTypes { public partial class Any { + private const string DefaultPrefix = "type.googleapis.com"; + // This could be moved to MessageDescriptor if we wanted to, but keeping it here means // all the Any-specific code is in the same place. - private static string GetTypeUrl(MessageDescriptor descriptor) + private static string GetTypeUrl(MessageDescriptor descriptor, string prefix) => + prefix.EndsWith("/") ? prefix + descriptor.FullName : prefix + "/" + descriptor.FullName; + + /// <summary> + /// Retrieves the type name for a type URL. This is always just the last part of the URL, + /// after the trailing slash. No validation of anything before the trailing slash is performed. + /// If the type URL does not include a slash, an empty string is returned rather than an exception + /// being thrown; this won't match any types, and the calling code is probably in a better position + /// to give a meaningful error. + /// There is no handling of fragments or queries at the moment. + /// </summary> + /// <param name="typeUrl">The URL to extract the type name from</param> + /// <returns>The type name</returns> + internal static string GetTypeName(string typeUrl) { - return "type.googleapis.com/" + descriptor.FullName; + int lastSlash = typeUrl.LastIndexOf('/'); + return lastSlash == -1 ? "" : typeUrl.Substring(lastSlash + 1); } /// <summary> @@ -55,25 +71,37 @@ namespace Google.Protobuf.WellKnownTypes // Note: this doesn't perform as well is it might. We could take a MessageParser<T> in an alternative overload, // which would be expected to perform slightly better... although the difference is likely to be negligible. T target = new T(); - string targetTypeUrl = GetTypeUrl(target.Descriptor); - if (TypeUrl != targetTypeUrl) + if (GetTypeName(TypeUrl) != target.Descriptor.FullName) { - throw new InvalidProtocolBufferException(string.Format("Type url for {0} is {1}; Any message's type url is {2}", - target.Descriptor.Name, targetTypeUrl, TypeUrl)); + throw new InvalidProtocolBufferException( + $"Full type name for {target.Descriptor.Name} is {target.Descriptor.FullName}; Any message's type url is {TypeUrl}"); } target.MergeFrom(Value); return target; } /// <summary> - /// Packs the specified message into an Any message. + /// Packs the specified message into an Any message using a type URL prefix of "type.googleapis.com". + /// </summary> + /// <param name="message">The message to pack.</param> + /// <returns>An Any message with the content and type URL of <paramref name="message"/>.</returns> + public static Any Pack(IMessage message) => Pack(message, DefaultPrefix); + + /// <summary> + /// Packs the specified message into an Any message using the specified type URL prefix. /// </summary> /// <param name="message">The message to pack.</param> + /// <param name="typeUrlPrefix">The prefix for the type URL.</param> /// <returns>An Any message with the content and type URL of <paramref name="message"/>.</returns> - public static Any Pack(IMessage message) + public static Any Pack(IMessage message, string typeUrlPrefix) { - ProtoPreconditions.CheckNotNull(message, "message"); - return new Any { TypeUrl = GetTypeUrl(message.Descriptor), Value = message.ToByteString() }; + ProtoPreconditions.CheckNotNull(message, nameof(message)); + ProtoPreconditions.CheckNotNull(typeUrlPrefix, nameof(typeUrlPrefix)); + return new Any + { + TypeUrl = GetTypeUrl(message.Descriptor, typeUrlPrefix), + Value = message.ToByteString() + }; } } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index de7aea3a..e568a2c9 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -185,7 +185,7 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary>Field number for the "syntax" field.</summary> public const int SyntaxFieldNumber = 7; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; /// <summary> /// The source syntax of the service. /// </summary> @@ -225,7 +225,7 @@ namespace Google.Protobuf.WellKnownTypes { if (Version.Length != 0) hash ^= Version.GetHashCode(); if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); hash ^= mixins_.GetHashCode(); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode(); + if (Syntax != 0) hash ^= Syntax.GetHashCode(); return hash; } @@ -249,7 +249,7 @@ namespace Google.Protobuf.WellKnownTypes { output.WriteMessage(SourceContext); } mixins_.WriteTo(output, _repeated_mixins_codec); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { output.WriteRawTag(56); output.WriteEnum((int) Syntax); } @@ -269,7 +269,7 @@ namespace Google.Protobuf.WellKnownTypes { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); } size += mixins_.CalculateSize(_repeated_mixins_codec); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } return size; @@ -294,7 +294,7 @@ namespace Google.Protobuf.WellKnownTypes { SourceContext.MergeFrom(other.SourceContext); } mixins_.Add(other.mixins_); - if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (other.Syntax != 0) { Syntax = other.Syntax; } } @@ -458,7 +458,7 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary>Field number for the "syntax" field.</summary> public const int SyntaxFieldNumber = 7; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; /// <summary> /// The source syntax of this method. /// </summary> @@ -498,7 +498,7 @@ namespace Google.Protobuf.WellKnownTypes { if (ResponseTypeUrl.Length != 0) hash ^= ResponseTypeUrl.GetHashCode(); if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode(); hash ^= options_.GetHashCode(); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode(); + if (Syntax != 0) hash ^= Syntax.GetHashCode(); return hash; } @@ -528,7 +528,7 @@ namespace Google.Protobuf.WellKnownTypes { output.WriteBool(ResponseStreaming); } options_.WriteTo(output, _repeated_options_codec); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { output.WriteRawTag(56); output.WriteEnum((int) Syntax); } @@ -552,7 +552,7 @@ namespace Google.Protobuf.WellKnownTypes { size += 1 + 1; } size += options_.CalculateSize(_repeated_options_codec); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } return size; @@ -578,7 +578,7 @@ namespace Google.Protobuf.WellKnownTypes { ResponseStreaming = other.ResponseStreaming; } options_.Add(other.options_); - if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (other.Syntax != 0) { Syntax = other.Syntax; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index 73e221d4..f17358f4 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -25,9 +25,10 @@ namespace Google.Protobuf.WellKnownTypes { string.Concat( "Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90", "b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg", - "ASgFQlAKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAaAB", - "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv", - "dG8z")); + "ASgFQnwKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAVoq", + "Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL2R1cmF0aW9uoAEB", + "ogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90", + "bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs index 6cad4124..e08ea240 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs @@ -24,9 +24,10 @@ namespace Google.Protobuf.WellKnownTypes { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1", - "ZiIHCgVFbXB0eUJQChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", - "UAGgAQH4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw", - "ZXNiBnByb3RvMw==")); + "ZiIHCgVFbXB0eUJ5ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv", + "UAFaJ2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy9lbXB0eaAB", + "AfgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG", + "cHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs index 2ba2b96f..6f0a64d6 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs @@ -86,7 +86,7 @@ namespace Google.Protobuf.WellKnownTypes { /// operation applies to all fields (as if a FieldMask of all fields /// had been specified). /// - /// Note that a field mask does not necessarily applies to the + /// Note that a field mask does not necessarily apply to the /// top-level response message. In case of a REST get operation, the /// field mask applies directly to the response, but in case of a REST /// list operation, the mask instead applies to each individual message @@ -159,6 +159,33 @@ namespace Google.Protobuf.WellKnownTypes { /// { /// mask: "user.displayName,photo" /// } + /// + /// # Field Masks and Oneof Fields + /// + /// Field masks treat fields in oneofs just as regular fields. Consider the + /// following message: + /// + /// message SampleMessage { + /// oneof test_oneof { + /// string name = 4; + /// SubMessage sub_message = 9; + /// } + /// } + /// + /// The field mask can be: + /// + /// mask { + /// paths: "name" + /// } + /// + /// Or: + /// + /// mask { + /// paths: "sub_message" + /// } + /// + /// Note that oneof type names ("test_oneof" in this case) cannot be used in + /// paths. /// </summary> [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class FieldMask : pb::IMessage<FieldMask> { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs index 8e2ce8cf..edc8940d 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs @@ -34,9 +34,10 @@ namespace Google.Protobuf.WellKnownTypes { "ABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RW", "YWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIW", "Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W", - "QUxVRRAAQk4KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAGg", - "AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy", - "b3RvMw==")); + "QUxVRRAAQoEBChNjb20uZ29vZ2xlLnByb3RvYnVmQgtTdHJ1Y3RQcm90b1AB", + "WjFnaXRodWIuY29tL2dvbGFuZy9wcm90b2J1Zi9wdHlwZXMvc3RydWN0O3N0", + "cnVjdHBioAEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5", + "cGVzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.NullValue), }, new pbr::GeneratedClrTypeInfo[] { @@ -59,7 +60,7 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary> /// Null value. /// </summary> - NULL_VALUE = 0, + [pbr::OriginalName("NULL_VALUE")] NullValue = 0, } #endregion @@ -108,7 +109,7 @@ namespace Google.Protobuf.WellKnownTypes { = new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10); private readonly pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> fields_ = new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>(); /// <summary> - /// Map of dynamically typed values. + /// Unordered map of dynamically typed values. /// </summary> public pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> Fields { get { return fields_; } @@ -234,7 +235,7 @@ namespace Google.Protobuf.WellKnownTypes { /// Represents a null value. /// </summary> public global::Google.Protobuf.WellKnownTypes.NullValue NullValue { - get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : global::Google.Protobuf.WellKnownTypes.NullValue.NULL_VALUE; } + get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : 0; } set { kind_ = value; kindCase_ = KindOneofCase.NullValue; diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs index 318b0f61..053b88bd 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs @@ -25,9 +25,10 @@ namespace Google.Protobuf.WellKnownTypes { string.Concat( "Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv", "dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY", - "AiABKAVCVAoTY29tLmdvb2dsZS5wcm90b2J1ZkIOVGltZXN0YW1wUHJvdG9Q", - "AaABAfgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBl", - "c2IGcHJvdG8z")); + "AiABKAVCgQEKE2NvbS5nb29nbGUucHJvdG9idWZCDlRpbWVzdGFtcFByb3Rv", + "UAFaK2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy90aW1lc3Rh", + "bXCgAQH4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw", + "ZXNiBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index 8faa1d1c..657c2464 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -79,11 +79,11 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary> /// Syntax `proto2`. /// </summary> - SYNTAX_PROTO2 = 0, + [pbr::OriginalName("SYNTAX_PROTO2")] Proto2 = 0, /// <summary> /// Syntax `proto3`. /// </summary> - SYNTAX_PROTO3 = 1, + [pbr::OriginalName("SYNTAX_PROTO3")] Proto3 = 1, } #endregion @@ -188,7 +188,7 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary>Field number for the "syntax" field.</summary> public const int SyntaxFieldNumber = 6; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; /// <summary> /// The source syntax. /// </summary> @@ -226,7 +226,7 @@ namespace Google.Protobuf.WellKnownTypes { hash ^= oneofs_.GetHashCode(); hash ^= options_.GetHashCode(); if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode(); + if (Syntax != 0) hash ^= Syntax.GetHashCode(); return hash; } @@ -246,7 +246,7 @@ namespace Google.Protobuf.WellKnownTypes { output.WriteRawTag(42); output.WriteMessage(SourceContext); } - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { output.WriteRawTag(48); output.WriteEnum((int) Syntax); } @@ -263,7 +263,7 @@ namespace Google.Protobuf.WellKnownTypes { if (sourceContext_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); } - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } return size; @@ -285,7 +285,7 @@ namespace Google.Protobuf.WellKnownTypes { } SourceContext.MergeFrom(other.SourceContext); } - if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (other.Syntax != 0) { Syntax = other.Syntax; } } @@ -371,7 +371,7 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary>Field number for the "kind" field.</summary> public const int KindFieldNumber = 1; - private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = 0; /// <summary> /// The field type. /// </summary> @@ -384,7 +384,7 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary>Field number for the "cardinality" field.</summary> public const int CardinalityFieldNumber = 2; - private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN; + private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = 0; /// <summary> /// The field cardinality. /// </summary> @@ -526,8 +526,8 @@ namespace Google.Protobuf.WellKnownTypes { public override int GetHashCode() { int hash = 1; - if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) hash ^= Kind.GetHashCode(); - if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) hash ^= Cardinality.GetHashCode(); + if (Kind != 0) hash ^= Kind.GetHashCode(); + if (Cardinality != 0) hash ^= Cardinality.GetHashCode(); if (Number != 0) hash ^= Number.GetHashCode(); if (Name.Length != 0) hash ^= Name.GetHashCode(); if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode(); @@ -544,11 +544,11 @@ namespace Google.Protobuf.WellKnownTypes { } public void WriteTo(pb::CodedOutputStream output) { - if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + if (Kind != 0) { output.WriteRawTag(8); output.WriteEnum((int) Kind); } - if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + if (Cardinality != 0) { output.WriteRawTag(16); output.WriteEnum((int) Cardinality); } @@ -585,10 +585,10 @@ namespace Google.Protobuf.WellKnownTypes { public int CalculateSize() { int size = 0; - if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + if (Kind != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Kind); } - if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + if (Cardinality != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Cardinality); } if (Number != 0) { @@ -620,10 +620,10 @@ namespace Google.Protobuf.WellKnownTypes { if (other == null) { return; } - if (other.Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) { + if (other.Kind != 0) { Kind = other.Kind; } - if (other.Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) { + if (other.Cardinality != 0) { Cardinality = other.Cardinality; } if (other.Number != 0) { @@ -712,79 +712,79 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary> /// Field type unknown. /// </summary> - TYPE_UNKNOWN = 0, + [pbr::OriginalName("TYPE_UNKNOWN")] TypeUnknown = 0, /// <summary> /// Field type double. /// </summary> - TYPE_DOUBLE = 1, + [pbr::OriginalName("TYPE_DOUBLE")] TypeDouble = 1, /// <summary> /// Field type float. /// </summary> - TYPE_FLOAT = 2, + [pbr::OriginalName("TYPE_FLOAT")] TypeFloat = 2, /// <summary> /// Field type int64. /// </summary> - TYPE_INT64 = 3, + [pbr::OriginalName("TYPE_INT64")] TypeInt64 = 3, /// <summary> /// Field type uint64. /// </summary> - TYPE_UINT64 = 4, + [pbr::OriginalName("TYPE_UINT64")] TypeUint64 = 4, /// <summary> /// Field type int32. /// </summary> - TYPE_INT32 = 5, + [pbr::OriginalName("TYPE_INT32")] TypeInt32 = 5, /// <summary> /// Field type fixed64. /// </summary> - TYPE_FIXED64 = 6, + [pbr::OriginalName("TYPE_FIXED64")] TypeFixed64 = 6, /// <summary> /// Field type fixed32. /// </summary> - TYPE_FIXED32 = 7, + [pbr::OriginalName("TYPE_FIXED32")] TypeFixed32 = 7, /// <summary> /// Field type bool. /// </summary> - TYPE_BOOL = 8, + [pbr::OriginalName("TYPE_BOOL")] TypeBool = 8, /// <summary> /// Field type string. /// </summary> - TYPE_STRING = 9, + [pbr::OriginalName("TYPE_STRING")] TypeString = 9, /// <summary> /// Field type group. Proto2 syntax only, and deprecated. /// </summary> - TYPE_GROUP = 10, + [pbr::OriginalName("TYPE_GROUP")] TypeGroup = 10, /// <summary> /// Field type message. /// </summary> - TYPE_MESSAGE = 11, + [pbr::OriginalName("TYPE_MESSAGE")] TypeMessage = 11, /// <summary> /// Field type bytes. /// </summary> - TYPE_BYTES = 12, + [pbr::OriginalName("TYPE_BYTES")] TypeBytes = 12, /// <summary> /// Field type uint32. /// </summary> - TYPE_UINT32 = 13, + [pbr::OriginalName("TYPE_UINT32")] TypeUint32 = 13, /// <summary> /// Field type enum. /// </summary> - TYPE_ENUM = 14, + [pbr::OriginalName("TYPE_ENUM")] TypeEnum = 14, /// <summary> /// Field type sfixed32. /// </summary> - TYPE_SFIXED32 = 15, + [pbr::OriginalName("TYPE_SFIXED32")] TypeSfixed32 = 15, /// <summary> /// Field type sfixed64. /// </summary> - TYPE_SFIXED64 = 16, + [pbr::OriginalName("TYPE_SFIXED64")] TypeSfixed64 = 16, /// <summary> /// Field type sint32. /// </summary> - TYPE_SINT32 = 17, + [pbr::OriginalName("TYPE_SINT32")] TypeSint32 = 17, /// <summary> /// Field type sint64. /// </summary> - TYPE_SINT64 = 18, + [pbr::OriginalName("TYPE_SINT64")] TypeSint64 = 18, } /// <summary> @@ -794,19 +794,19 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary> /// For fields with unknown cardinality. /// </summary> - CARDINALITY_UNKNOWN = 0, + [pbr::OriginalName("CARDINALITY_UNKNOWN")] Unknown = 0, /// <summary> /// For optional fields. /// </summary> - CARDINALITY_OPTIONAL = 1, + [pbr::OriginalName("CARDINALITY_OPTIONAL")] Optional = 1, /// <summary> /// For required fields. Proto2 syntax only. /// </summary> - CARDINALITY_REQUIRED = 2, + [pbr::OriginalName("CARDINALITY_REQUIRED")] Required = 2, /// <summary> /// For repeated fields. /// </summary> - CARDINALITY_REPEATED = 3, + [pbr::OriginalName("CARDINALITY_REPEATED")] Repeated = 3, } } @@ -900,7 +900,7 @@ namespace Google.Protobuf.WellKnownTypes { /// <summary>Field number for the "syntax" field.</summary> public const int SyntaxFieldNumber = 5; - private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2; + private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0; /// <summary> /// The source syntax. /// </summary> @@ -936,7 +936,7 @@ namespace Google.Protobuf.WellKnownTypes { hash ^= enumvalue_.GetHashCode(); hash ^= options_.GetHashCode(); if (sourceContext_ != null) hash ^= SourceContext.GetHashCode(); - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode(); + if (Syntax != 0) hash ^= Syntax.GetHashCode(); return hash; } @@ -955,7 +955,7 @@ namespace Google.Protobuf.WellKnownTypes { output.WriteRawTag(34); output.WriteMessage(SourceContext); } - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { output.WriteRawTag(40); output.WriteEnum((int) Syntax); } @@ -971,7 +971,7 @@ namespace Google.Protobuf.WellKnownTypes { if (sourceContext_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext); } - if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (Syntax != 0) { size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax); } return size; @@ -992,7 +992,7 @@ namespace Google.Protobuf.WellKnownTypes { } SourceContext.MergeFrom(other.SourceContext); } - if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) { + if (other.Syntax != 0) { Syntax = other.Syntax; } } diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs index d6796d1a..c8867d0e 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs @@ -29,10 +29,10 @@ namespace Google.Protobuf.WellKnownTypes { "KAMiHAoLVUludDY0VmFsdWUSDQoFdmFsdWUYASABKAQiGwoKSW50MzJWYWx1", "ZRINCgV2YWx1ZRgBIAEoBSIcCgtVSW50MzJWYWx1ZRINCgV2YWx1ZRgBIAEo", "DSIaCglCb29sVmFsdWUSDQoFdmFsdWUYASABKAgiHAoLU3RyaW5nVmFsdWUS", - "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEJT", - "ChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAGgAQH4AQGi", - "AgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3Rv", - "Mw==")); + "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEJ/", + "ChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAFaKmdpdGh1", + "Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy93cmFwcGVyc6ABAfgBAaIC", + "A0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { |