Google.Protobuf.Reflection.FieldDescriptor

Descriptor for a field or extension within a message in a .proto file.

Summary

Inheritance

Inherits from: Google.Protobuf.Reflection.DescriptorBase, IComparable< FieldDescriptor >

Properties

ContainingOneof
OneofDescriptor
Returns the oneof containing this field, or null if it is not part of a oneof.
ContainingType
MessageDescriptor
Get the field's containing message type.
EnumType
EnumDescriptor
For enum fields, returns the field's type.
JsonName
string
The effective JSON name for this field.
MessageType
MessageDescriptor
For embedded message and group fields, returns the field's type.
Proto
FieldDescriptorProto

Public attributes

Accessor => accessor
IFieldAccessor
Returns the accessor for this field.
FieldNumber => Proto.Number
int
Returns the field number declared in the proto file.
FieldType => fieldType
FieldType
Returns the type of the field.
IsMap => fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry
bool
Returns true if this field is a map field; false otherwise.
IsPacked => Proto.Options == null || Proto.Options.Packed
bool
Returns true if this field is a packed, repeated field; false otherwise.
IsRepeated => Proto.Label == FieldDescriptorProto.Types.Label.Repeated
bool
Returns true if this field is a repeated field; false otherwise.
Name => Proto.Name
override string
The brief name of the descriptor's target.

Public functions

CompareTo(FieldDescriptor other)
int
Compares this descriptor with another one, ordering in "canonical" order which simply means ascending order by field number.

Properties

ContainingOneof

OneofDescriptor ContainingOneof

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

ContainingType

MessageDescriptor ContainingType

Get the field's containing message type.

EnumType

EnumDescriptor EnumType

For enum fields, returns the field's type.

JsonName

string JsonName

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.

MessageType

MessageDescriptor MessageType

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

Proto

FieldDescriptorProto Proto

Public attributes

Accessor

IFieldAccessor Accessor => accessor

Returns the accessor for this field.

While a FieldDescriptor describes the field, it does not provide any way of obtaining or changing the value of the field within a specific message; that is the responsibility of the accessor.

The value returned by this property will be non-null for all regular fields. However, if a message containing a map field is introspected, the list of nested messages will include an auto-generated nested key/value pair message for the field. This is not represented in any generated type, and the value of the map field itself is represented by a dictionary in the reflection API. There are never instances of those "hidden" messages, so no accessor is provided and this property will return null.

FieldNumber

int FieldNumber => Proto.Number

Returns the field number declared in the proto file.

FieldType

FieldType FieldType => fieldType

Returns the type of the field.

IsMap

bool IsMap => fieldType == FieldType.Message && messageType.Proto.Options != null && messageType.Proto.Options.MapEntry

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

IsPacked

bool IsPacked => 
            
            
            
            
            Proto.Options == null || Proto.Options.Packed

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

IsRepeated

bool IsRepeated => Proto.Label == FieldDescriptorProto.Types.Label.Repeated

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

Name

override string Name => Proto.Name

The brief name of the descriptor's target.

Public functions

CompareTo

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.