remove unnecessary cast

pull/7434/head
Jan Tattermusch 5 years ago
parent 402ce8b17f
commit 673245f212
  1. 2
      csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs
  2. 2
      csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs
  3. 2
      csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
  4. 2
      csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
  5. 2
      csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
  6. 2
      csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs
  7. 2
      csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
  8. 14
      csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs

@ -136,7 +136,7 @@ namespace Google.Protobuf.Reflection
/// 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 EnumOptions Options => (Proto.Options as IDeepCloneable<EnumOptions>)?.Clone();
public EnumOptions Options => Proto.Options?.Clone();
/// <summary>
/// Gets a single value enum option for this descriptor

@ -81,7 +81,7 @@ namespace Google.Protobuf.Reflection
/// 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 EnumValueOptions Options => (Proto.Options as IDeepCloneable<EnumValueOptions>)?.Clone();
public EnumValueOptions Options => Proto.Options?.Clone();
/// <summary>
/// Gets a single value enum value option for this descriptor

@ -312,7 +312,7 @@ namespace Google.Protobuf.Reflection
/// 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 FieldOptions Options => (Proto.Options as IDeepCloneable<FieldOptions>)?.Clone();
public FieldOptions Options => Proto.Options?.Clone();
/// <summary>
/// Gets a single value field option for this descriptor

@ -555,7 +555,7 @@ namespace Google.Protobuf.Reflection
/// 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 FileOptions Options => (Proto.Options as IDeepCloneable<FileOptions>)?.Clone();
public FileOptions Options => Proto.Options?.Clone();
/// <summary>
/// Gets a single value file option for this descriptor

@ -295,7 +295,7 @@ namespace Google.Protobuf.Reflection
/// 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 MessageOptions Options => (Proto.Options as IDeepCloneable<MessageOptions>)?.Clone();
public MessageOptions Options => Proto.Options?.Clone();
/// <summary>
/// Gets a single value message option for this descriptor

@ -81,7 +81,7 @@ namespace Google.Protobuf.Reflection
/// 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 MethodOptions Options => (Proto.Options as IDeepCloneable<MethodOptions>)?.Clone();
public MethodOptions Options => Proto.Options?.Clone();
/// <summary>
/// Gets a single value method option for this descriptor

@ -125,7 +125,7 @@ namespace Google.Protobuf.Reflection
/// 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 OneofOptions Options => (proto.Options as IDeepCloneable<OneofOptions>)?.Clone();
public OneofOptions Options => proto.Options?.Clone();
/// <summary>
/// Gets a single value oneof option for this descriptor

@ -97,6 +97,13 @@ namespace Google.Protobuf.Reflection
[Obsolete("CustomOptions are obsolete. Use the Options property.")]
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber);
/// <summary>
/// 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 ServiceOptions Options => Proto.Options?.Clone();
/// <summary>
/// Gets a single value service option for this descriptor
/// </summary>
@ -116,13 +123,6 @@ namespace Google.Protobuf.Reflection
return Proto.Options.GetExtension(extension).Clone();
}
/// <summary>
/// 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 ServiceOptions Options => (Proto.Options as IDeepCloneable<ServiceOptions>)?.Clone();
internal void CrossLink()
{
foreach (MethodDescriptor method in methods)

Loading…
Cancel
Save