diff options
author | Jon Skeet <jonskeet@google.com> | 2017-01-16 11:23:32 +0000 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2017-01-19 06:46:04 +0000 |
commit | 047575f20cbdee8fb2f88d78a317ffe6133b93e6 (patch) | |
tree | 140117944c03c04c58086d451c09cad7fe2ca919 /csharp/src/Google.Protobuf/Reflection/Descriptor.cs | |
parent | eed9951991c6ee7c629b5c4252444c372f7774fd (diff) | |
download | protobuf-047575f20cbdee8fb2f88d78a317ffe6133b93e6.tar.gz protobuf-047575f20cbdee8fb2f88d78a317ffe6133b93e6.tar.bz2 protobuf-047575f20cbdee8fb2f88d78a317ffe6133b93e6.zip |
Support custom options in C#
This consists of:
- Changing the codegen for the fixed set of options protos, to parse unknown fields instead of skipping them
- Add a new CustomOptions type in the C# support library
- Expose CustomOptions properties from the immutable proto wrappers in the support library
Only single-value options are currently supported, and fetching options values requires getting the type right
and knowing the field number. Both of these can be addressed at a later time.
Fixes #2143, at least as a first pass.
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection/Descriptor.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/Reflection/Descriptor.cs | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index d743e516..ceab9b06 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -2779,6 +2779,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FileOptions() { OnConstruction(); @@ -3299,7 +3301,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 10: { JavaPackage = input.ReadString(); @@ -3411,6 +3413,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageOptions() { OnConstruction(); @@ -3646,7 +3650,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 8: { MessageSetWireFormat = input.ReadBool(); @@ -3689,6 +3693,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public FieldOptions() { OnConstruction(); @@ -3980,7 +3986,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 8: { ctype_ = (global::Google.Protobuf.Reflection.FieldOptions.Types.CType) input.ReadEnum(); @@ -4062,6 +4068,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofOptions() { OnConstruction(); @@ -4147,7 +4155,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 7994: { uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec); @@ -4174,6 +4182,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumOptions() { OnConstruction(); @@ -4317,7 +4327,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 16: { AllowAlias = input.ReadBool(); @@ -4352,6 +4362,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public EnumValueOptions() { OnConstruction(); @@ -4467,7 +4479,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 8: { Deprecated = input.ReadBool(); @@ -4498,6 +4510,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ServiceOptions() { OnConstruction(); @@ -4613,7 +4627,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 264: { Deprecated = input.ReadBool(); @@ -4644,6 +4658,8 @@ namespace Google.Protobuf.Reflection { get { return Descriptor; } } + internal CustomOptions CustomOptions{ get; private set; } = CustomOptions.Empty; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MethodOptions() { OnConstruction(); @@ -4783,7 +4799,7 @@ namespace Google.Protobuf.Reflection { while ((tag = input.ReadTag()) != 0) { switch(tag) { default: - input.SkipLastField(); + CustomOptions = CustomOptions.ReadOrSkipUnknownField(input); break; case 264: { Deprecated = input.ReadBool(); |