소스 검색

Added FieldDescriptor.IsExtension and sealed ExtensionCollection

Sydney Acksman 6 년 전
부모
커밋
8e917d1688
2개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs
  2. 5 0
      csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs

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

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

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

@@ -203,6 +203,11 @@ namespace Google.Protobuf.Reflection
         /// </summary>
         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>
         /// Returns the type of the field.
         /// </summary>