Commit 05712c67 authored by Sydney Acksman's avatar Sydney Acksman

Reapply custom option accessors from previous PR along with CustomOptions accessor deprecations

parent 4be03946
...@@ -41,6 +41,8 @@ using static UnitTest.Issues.TestProtos.ComplexOptionType2.Types; ...@@ -41,6 +41,8 @@ using static UnitTest.Issues.TestProtos.ComplexOptionType2.Types;
using static UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types; using static UnitTest.Issues.TestProtos.DummyMessageContainingEnum.Types;
using static Google.Protobuf.Test.Reflection.CustomOptionNumber; using static Google.Protobuf.Test.Reflection.CustomOptionNumber;
#pragma warning disable CS0618
namespace Google.Protobuf.Test.Reflection namespace Google.Protobuf.Test.Reflection
{ {
// Internal enum to allow us to use "using static" for convenience. // Internal enum to allow us to use "using static" for convenience.
......
...@@ -128,17 +128,16 @@ namespace Google.Protobuf.Reflection ...@@ -128,17 +128,16 @@ namespace Google.Protobuf.Reflection
/// <summary> /// <summary>
/// The (possibly empty) set of custom options for this enum. /// The (possibly empty) set of custom options for this enum.
/// </summary> /// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")] [Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary> /// <summary>
/// Gets a single value enum option for this descriptor /// Gets a single value enum option for this descriptor
/// </summary> /// </summary>
public T GetOption<T>(Extension<EnumOptions, T> extension) public T GetOption<T>(Extension<EnumOptions, T> extension)
{ {
var value = Proto.Options.GetExtension(extension); var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value; return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
} }
/// <summary> /// <summary>
...@@ -148,6 +147,5 @@ namespace Google.Protobuf.Reflection ...@@ -148,6 +147,5 @@ namespace Google.Protobuf.Reflection
{ {
return Proto.Options.GetExtension(extension).Clone(); return Proto.Options.GetExtension(extension).Clone();
} }
*/
} }
} }
\ No newline at end of file
...@@ -73,17 +73,16 @@ namespace Google.Protobuf.Reflection ...@@ -73,17 +73,16 @@ namespace Google.Protobuf.Reflection
/// <summary> /// <summary>
/// The (possibly empty) set of custom options for this enum value. /// The (possibly empty) set of custom options for this enum value.
/// </summary> /// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")] [Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary> /// <summary>
/// Gets a single value enum option for this descriptor /// Gets a single value enum option for this descriptor
/// </summary> /// </summary>
public T GetOption<T>(Extension<EnumValueOptions, T> extension) public T GetOption<T>(Extension<EnumValueOptions, T> extension)
{ {
var value = Proto.Options.GetExtension(extension); var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value; return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
} }
/// <summary> /// <summary>
...@@ -93,7 +92,6 @@ namespace Google.Protobuf.Reflection ...@@ -93,7 +92,6 @@ namespace Google.Protobuf.Reflection
{ {
return Proto.Options.GetExtension(extension).Clone(); return Proto.Options.GetExtension(extension).Clone();
} }
*/
} }
} }
\ No newline at end of file
...@@ -277,17 +277,16 @@ namespace Google.Protobuf.Reflection ...@@ -277,17 +277,16 @@ namespace Google.Protobuf.Reflection
/// <summary> /// <summary>
/// The (possibly empty) set of custom options for this field. /// The (possibly empty) set of custom options for this field.
/// </summary> /// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")] [Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary> /// <summary>
/// Gets a single value enum option for this descriptor /// Gets a single value enum option for this descriptor
/// </summary> /// </summary>
public T GetOption<T>(Extension<FieldOptions, T> extension) public T GetOption<T>(Extension<FieldOptions, T> extension)
{ {
var value = Proto.Options.GetExtension(extension); var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value; return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
} }
/// <summary> /// <summary>
...@@ -297,7 +296,6 @@ namespace Google.Protobuf.Reflection ...@@ -297,7 +296,6 @@ namespace Google.Protobuf.Reflection
{ {
return Proto.Options.GetExtension(extension).Clone(); return Proto.Options.GetExtension(extension).Clone();
} }
*/
/// <summary> /// <summary>
/// Look up and cross-link all field types etc. /// Look up and cross-link all field types etc.
......
...@@ -504,17 +504,16 @@ namespace Google.Protobuf.Reflection ...@@ -504,17 +504,16 @@ namespace Google.Protobuf.Reflection
/// <summary> /// <summary>
/// The (possibly empty) set of custom options for this file. /// The (possibly empty) set of custom options for this file.
/// </summary> /// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")] [Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary> /// <summary>
/// Gets a single value enum option for this descriptor /// Gets a single value enum option for this descriptor
/// </summary> /// </summary>
public T GetOption<T>(Extension<FileOptions, T> extension) public T GetOption<T>(Extension<FileOptions, T> extension)
{ {
var value = Proto.Options.GetExtension(extension); var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value; return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
} }
/// <summary> /// <summary>
...@@ -524,7 +523,6 @@ namespace Google.Protobuf.Reflection ...@@ -524,7 +523,6 @@ namespace Google.Protobuf.Reflection
{ {
return Proto.Options.GetExtension(extension).Clone(); return Proto.Options.GetExtension(extension).Clone();
} }
*/
/// <summary> /// <summary>
/// Performs initialization for the given generic type argument. /// Performs initialization for the given generic type argument.
......
...@@ -243,17 +243,16 @@ namespace Google.Protobuf.Reflection ...@@ -243,17 +243,16 @@ namespace Google.Protobuf.Reflection
/// <summary> /// <summary>
/// The (possibly empty) set of custom options for this message. /// The (possibly empty) set of custom options for this message.
/// </summary> /// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")] [Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary> /// <summary>
/// Gets a single value enum option for this descriptor /// Gets a single value enum option for this descriptor
/// </summary> /// </summary>
public T GetOption<T>(Extension<MessageOptions, T> extension) public T GetOption<T>(Extension<MessageOptions, T> extension)
{ {
var value = Proto.Options.GetExtension(extension); var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value; return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
} }
/// <summary> /// <summary>
...@@ -263,7 +262,6 @@ namespace Google.Protobuf.Reflection ...@@ -263,7 +262,6 @@ namespace Google.Protobuf.Reflection
{ {
return Proto.Options.GetExtension(extension).Clone(); return Proto.Options.GetExtension(extension).Clone();
} }
*/
/// <summary> /// <summary>
/// Looks up and cross-links all fields and nested types. /// Looks up and cross-links all fields and nested types.
......
...@@ -73,17 +73,16 @@ namespace Google.Protobuf.Reflection ...@@ -73,17 +73,16 @@ namespace Google.Protobuf.Reflection
/// <summary> /// <summary>
/// The (possibly empty) set of custom options for this method. /// The (possibly empty) set of custom options for this method.
/// </summary> /// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")] [Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary> /// <summary>
/// Gets a single value enum option for this descriptor /// Gets a single value enum option for this descriptor
/// </summary> /// </summary>
public T GetOption<T>(Extension<MethodOptions, T> extension) public T GetOption<T>(Extension<MethodOptions, T> extension)
{ {
var value = Proto.Options.GetExtension(extension); var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value; return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
} }
/// <summary> /// <summary>
...@@ -93,7 +92,6 @@ namespace Google.Protobuf.Reflection ...@@ -93,7 +92,6 @@ namespace Google.Protobuf.Reflection
{ {
return Proto.Options.GetExtension(extension).Clone(); return Proto.Options.GetExtension(extension).Clone();
} }
*/
internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file, internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file,
ServiceDescriptor parent, int index) ServiceDescriptor parent, int index)
......
...@@ -94,17 +94,16 @@ namespace Google.Protobuf.Reflection ...@@ -94,17 +94,16 @@ namespace Google.Protobuf.Reflection
/// <summary> /// <summary>
/// The (possibly empty) set of custom options for this service. /// The (possibly empty) set of custom options for this service.
/// </summary> /// </summary>
//[Obsolete("CustomOptions are obsolete. Use GetOption")] [Obsolete("CustomOptions are obsolete. Use GetOption")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber); public CustomOptions CustomOptions => new CustomOptions(Proto.Options._extensions?.ValuesByNumber);
/* // uncomment this in the full proto2 support PR
/// <summary> /// <summary>
/// Gets a single value enum option for this descriptor /// Gets a single value enum option for this descriptor
/// </summary> /// </summary>
public T GetOption<T>(Extension<ServiceOptions, T> extension) public T GetOption<T>(Extension<ServiceOptions, T> extension)
{ {
var value = Proto.Options.GetExtension(extension); var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> clonable ? clonable.Clone() : value; return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
} }
/// <summary> /// <summary>
...@@ -114,7 +113,6 @@ namespace Google.Protobuf.Reflection ...@@ -114,7 +113,6 @@ namespace Google.Protobuf.Reflection
{ {
return Proto.Options.GetExtension(extension).Clone(); return Proto.Options.GetExtension(extension).Clone();
} }
*/
internal void CrossLink() internal void CrossLink()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment