From bdc6cd1d0bbe49e2b2cb3b06a71c7d9c320cdb29 Mon Sep 17 00:00:00 2001 From: Sydney Acksman Date: Tue, 13 Aug 2019 01:31:50 -0500 Subject: [PATCH] Expose Extension field in FieldDescriptor --- .../Reflection/FieldDescriptor.cs | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs index a8b9e69f44aa..dee091350269 100644 --- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs @@ -66,7 +66,10 @@ public sealed class FieldDescriptor : DescriptorBase, IComparable + /// An extension identifier for this field, or null if this field isn't an extension. + /// + public Extension Extension { get; } internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, string propertyName, Extension extension) @@ -201,19 +204,19 @@ private static FieldType GetFieldTypeFromProtoType(FieldDescriptorProto.Types.Ty /// /// Returns true if this field is a packed, repeated field; false otherwise. /// - public bool IsPacked - { - get - { - if (File.Syntax != Syntax.Proto3) - { - return Proto.Options?.Packed ?? false; - } - else - { - return !Proto.Options.HasPacked || Proto.Options.Packed; - } - } + public bool IsPacked + { + get + { + if (File.Syntax != Syntax.Proto3) + { + return Proto.Options?.Packed ?? false; + } + else + { + return !Proto.Options.HasPacked || Proto.Options.Packed; + } + } } /// @@ -393,7 +396,7 @@ internal void CrossLink() } private IFieldAccessor CreateAccessor() - { + { if (Extension != null) { return new ExtensionAccessor(this);