Jan Tattermusch 5 роки тому
батько
коміт
673245f212

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/EnumDescriptor.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

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs

@@ -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

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs

@@ -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

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs

@@ -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

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs

@@ -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

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs

@@ -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

+ 1 - 1
csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs

@@ -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

+ 7 - 7
csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs

@@ -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)