<PackageReference Include="Google.Protobuf" Version="3.35.1" />

Google.Protobuf.Reflection.FieldDescriptor

Descriptor for a field or extension within a message in a .proto file.
public IFieldAccessor Accessor { get; }

Returns the accessor for this field.

Returns the oneof containing this field, or null if it is not part of a oneof.

Get the field's containing message type, or null if it is a field defined at the top level of a file as an extension.

public CustomOptions CustomOptions { get; }

The (possibly empty) set of custom options for this field.

public EnumDescriptor EnumType { get; }

For enum fields, returns the field's type.

For extension fields, returns the extended type

public Extension Extension { get; }

An extension identifier for this field, or null if this field isn't an extension.

public int FieldNumber { get; }

Returns the field number declared in the proto file.

public FieldType FieldType { get; }

Returns the type of the field.

public bool HasPresence { get; }

Indicates whether this field supports presence, either implicitly (e.g. due to it being a message type field) or explicitly via Has/Clear members. If this returns true, it is safe to call Clear and HasValue on this field's accessor with a suitable message.

public bool IsExtension { get; }

Returns true if this field extends another message type; false otherwise.

public bool IsMap { get; }

Returns true if this field is a map field; false otherwise.

public bool IsPacked { get; }

Returns true if this field is a packed, repeated field; false otherwise.

public bool IsRepeated { get; }

Returns true if this field is a repeated field; false otherwise.

public bool IsRequired { get; }

Returns true if this field is a required field; false otherwise.

public string JsonName { get; }

The effective JSON name for this field. This is usually the lower-camel-cased form of the field name, but can be overridden using the json_name option in the .proto file.

For embedded message and group fields, returns the field's type.

public string PropertyName { get; }

The name of the property in the ContainingType.ClrType class.

Returns the oneof containing this field if it's a "real" oneof, or null if either this field is not part of a oneof, or the oneof is synthetic.

public int CompareTo(FieldDescriptor other)

Compares this descriptor with another one, ordering in "canonical" order which simply means ascending order by field number. other must be a field of the same type, i.e. the ContainingType of both fields must be the same.

public T GetOption<T>(Extension<FieldOptions, T> extension)

Gets a single value field option for this descriptor

Gets a repeated value field option for this descriptor

The FieldOptions, defined in descriptor.proto. If the options message is not present (i.e. there are no options), null is returned. Custom options can be retrieved as extensions of the returned message. NOTE: A defensive copy is created each time this property is retrieved.

Returns a clone of the underlying FieldDescriptorProto describing this field. Note that a copy is taken every time this method is called, so clients using it frequently (and not modifying it) may want to cache the returned value.