expose Options property on descriptors

pull/7434/head
Jan Tattermusch 5 years ago
parent 4059c61f27
commit 944055a683
  1. 20
      csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
  2. 20
      csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs
  3. 20
      csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
  4. 20
      csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
  5. 20
      csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
  6. 20
      csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs
  7. 20
      csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
  8. 20
      csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs

@ -128,24 +128,14 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this enum.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property.")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum option for this descriptor
/// The <c>EnumOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<EnumOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<EnumOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
public EnumOptions Options => (Proto.Options as IDeepCloneable<EnumOptions>)?.Clone();
}
}

@ -73,25 +73,15 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this enum value.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value enum value option for this descriptor
/// The <c>EnumValueOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<EnumValueOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value enum value option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<EnumValueOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
public EnumValueOptions Options => (Proto.Options as IDeepCloneable<EnumValueOptions>)?.Clone();
}
}

@ -304,25 +304,15 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this field.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property.")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value field option for this descriptor
/// The <c>FieldOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<FieldOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value field option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<FieldOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
public FieldOptions Options => (Proto.Options as IDeepCloneable<FieldOptions>)?.Clone();
/// <summary>
/// Look up and cross-link all field types etc.

@ -547,25 +547,15 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this file.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property.")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value file option for this descriptor
/// The <c>FileOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<FileOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value file option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<FileOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
public FileOptions Options => (Proto.Options as IDeepCloneable<FileOptions>)?.Clone();
/// <summary>
/// Performs initialization for the given generic type argument.

@ -287,25 +287,15 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this message.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value message option for this descriptor
/// The <c>MessageOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<MessageOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value message option for this descriptor
/// </summary>
public Collections.RepeatedField<T> GetOption<T>(RepeatedExtension<MessageOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
public MessageOptions Options => (Proto.Options as IDeepCloneable<MessageOptions>)?.Clone();
/// <summary>
/// Looks up and cross-links all fields and nested types.

@ -73,25 +73,15 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this method.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property.")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value method option for this descriptor
/// The <c>MethodOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<MethodOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value method option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<MethodOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
public MethodOptions Options => (Proto.Options as IDeepCloneable<MethodOptions>)?.Clone();
internal MethodDescriptor(MethodDescriptorProto proto, FileDescriptor file,
ServiceDescriptor parent, int index)

@ -117,25 +117,15 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this oneof.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property.")]
public CustomOptions CustomOptions => new CustomOptions(proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value oneof option for this descriptor
/// The <c>OneofOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<OneofOptions, T> extension)
{
var value = proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value oneof option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<OneofOptions, T> extension)
{
return proto.Options.GetExtension(extension).Clone();
}
public OneofOptions Options => (proto.Options as IDeepCloneable<OneofOptions>)?.Clone();
internal void CrossLink()
{

@ -94,25 +94,15 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// The (possibly empty) set of custom options for this service.
/// </summary>
[Obsolete("CustomOptions are obsolete. Use GetOption")]
[Obsolete("CustomOptions are obsolete. Use the Options property.")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// Gets a single value service option for this descriptor
/// The <c>ServiceOptions</c>, defined in <c>descriptor.proto</c>.
/// Custom options can be retrieved as extensions of the returned message.
/// NOTE: A defensive copy is created each time this property is retrieved.
/// </summary>
public T GetOption<T>(Extension<ServiceOptions, T> extension)
{
var value = Proto.Options.GetExtension(extension);
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value;
}
/// <summary>
/// Gets a repeated value service option for this descriptor
/// </summary>
public RepeatedField<T> GetOption<T>(RepeatedExtension<ServiceOptions, T> extension)
{
return Proto.Options.GetExtension(extension).Clone();
}
public ServiceOptions Options => (Proto.Options as IDeepCloneable<ServiceOptions>)?.Clone();
internal void CrossLink()
{

Loading…
Cancel
Save