Эх сурвалжийг харах

Added FieldDescriptor.IsExtension and sealed ExtensionCollection

Sydney Acksman 6 жил өмнө
parent
commit
8e917d1688

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

@@ -39,7 +39,7 @@ namespace Google.Protobuf.Reflection
     /// <summary>
     /// <summary>
     /// A collection to simplify retrieving the descriptors of extensions in a descriptor for a message
     /// A collection to simplify retrieving the descriptors of extensions in a descriptor for a message
     /// </summary>
     /// </summary>
-    public class ExtensionCollection
+    public sealed class ExtensionCollection
     {
     {
         private IDictionary<MessageDescriptor, IList<FieldDescriptor>> extensionsByTypeInDeclarationOrder;
         private IDictionary<MessageDescriptor, IList<FieldDescriptor>> extensionsByTypeInDeclarationOrder;
         private IDictionary<MessageDescriptor, IList<FieldDescriptor>> extensionsByTypeInNumberOrder;
         private IDictionary<MessageDescriptor, IList<FieldDescriptor>> extensionsByTypeInNumberOrder;

+ 5 - 0
csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs

@@ -203,6 +203,11 @@ namespace Google.Protobuf.Reflection
         /// </summary>
         /// </summary>
         public bool IsPacked => File.Proto.Syntax == "proto2" ? Proto.Options?.Packed ?? false : !Proto.Options.HasPacked || Proto.Options.Packed;
         public bool IsPacked => File.Proto.Syntax == "proto2" ? Proto.Options?.Packed ?? false : !Proto.Options.HasPacked || Proto.Options.Packed;
 
 
+        /// <summary>
+        /// Returns <c>true</c> if this field extends another message type; <c>false</c> otherwise.
+        /// </summary>
+        public bool IsExtension => Proto.HasExtendee;
+
         /// <summary>
         /// <summary>
         /// Returns the type of the field.
         /// Returns the type of the field.
         /// </summary>
         /// </summary>