Show / Hide Table of Contents

Class FieldDescriptor

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

Inheritance
System.Object
DescriptorBase
FieldDescriptor
Implements
IDescriptor
System.IComparable<FieldDescriptor>
Inherited Members
DescriptorBase.Index
DescriptorBase.FullName
DescriptorBase.File
DescriptorBase.Declaration
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Protobuf.Reflection
Assembly: Google.Protobuf.dll
Syntax
public sealed class FieldDescriptor : DescriptorBase, IDescriptor, IComparable<FieldDescriptor>

Properties

Accessor

Returns the accessor for this field.

Declaration
public IFieldAccessor Accessor { get; }
Property Value
Type Description
IFieldAccessor
Remarks

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.

In descriptors for generated code, 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.

In dynamically loaded descriptors, the value returned by this property will current be null; if and when dynamic messages are supported, it will return a suitable accessor to work with them.

ContainingOneof

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

Declaration
public OneofDescriptor ContainingOneof { get; }
Property Value
Type Description
OneofDescriptor

ContainingType

Get the field's containing message type.

Declaration
public MessageDescriptor ContainingType { get; }
Property Value
Type Description
MessageDescriptor

CustomOptions

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

Declaration
public CustomOptions CustomOptions { get; }
Property Value
Type Description
CustomOptions

EnumType

For enum fields, returns the field's type.

Declaration
public EnumDescriptor EnumType { get; }
Property Value
Type Description
EnumDescriptor

FieldNumber

Returns the field number declared in the proto file.

Declaration
public int FieldNumber { get; }
Property Value
Type Description
System.Int32

FieldType

Returns the type of the field.

Declaration
public FieldType FieldType { get; }
Property Value
Type Description
FieldType

IsMap

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

Declaration
public bool IsMap { get; }
Property Value
Type Description
System.Boolean

IsPacked

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

Declaration
public bool IsPacked { get; }
Property Value
Type Description
System.Boolean

IsRepeated

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

Declaration
public bool IsRepeated { get; }
Property Value
Type Description
System.Boolean

IsRequired

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

Declaration
public bool IsRequired { get; }
Property Value
Type Description
System.Boolean

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.

Declaration
public string JsonName { get; }
Property Value
Type Description
System.String

MessageType

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

Declaration
public MessageDescriptor MessageType { get; }
Property Value
Type Description
MessageDescriptor

Name

The brief name of the descriptor's target.

Declaration
public override string Name { get; }
Property Value
Type Description
System.String
Overrides
DescriptorBase.Name

Methods

CompareTo(FieldDescriptor)

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.

Declaration
public int CompareTo(FieldDescriptor other)
Parameters
Type Name Description
FieldDescriptor other
Returns
Type Description
System.Int32
Implements
System.IComparable<T>.CompareTo(T)
Back to top