Google.Protobuf.Reflection.MessageDescriptor

Describes a message type.

Summary

Inheritance

Inherits from: Google.Protobuf.Reflection.DescriptorBase

Public attributes

Name => Proto.Name
override string
The brief name of the descriptor's target.

Properties

ClrType
Type
The CLR type used to represent message instances from this descriptor.
ContainingType
If this is a nested type, get the outer descriptor, otherwise null.
EnumTypes
IList< EnumDescriptor >
An unmodifiable list of this message type's enum types.
Fields
A collection of fields, which can be retrieved by name or field number.
NestedTypes
An unmodifiable list of this message type's nested types.
Oneofs
IList< OneofDescriptor >
An unmodifiable list of the "oneof" field collections in this message type.
Parser
A parser for this message type.
Proto
DescriptorProto

Public functions

FindDescriptor< T >(string name)
T
Finds a nested descriptor by name.
FindFieldByName(String name)
Finds a field by field name.
FindFieldByNumber(int number)
Finds a field by field number.

Classes

Google.Protobuf.Reflection.MessageDescriptor.FieldCollection

A collection to simplify retrieving the field accessor for a particular field.

Public attributes

Name

override string Name => Proto.Name

The brief name of the descriptor's target.

Properties

ClrType

Type ClrType

The CLR type used to represent message instances from this descriptor.

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, so this property will return null in such cases.

For wrapper types (Google.Protobuf.WellKnownTypes.StringValue and the like), the type returned here will be the generated message type, not the native type used by reflection for fields of those types. Code using reflection should call IsWrapperType to determine whether a message descriptor represents a wrapper type, and handle the result appropriately.

ContainingType

MessageDescriptor ContainingType

If this is a nested type, get the outer descriptor, otherwise null.

EnumTypes

IList< EnumDescriptor > EnumTypes

An unmodifiable list of this message type's enum types.

Fields

FieldCollection Fields

A collection of fields, which can be retrieved by name or field number.

NestedTypes

IList< MessageDescriptor > NestedTypes

An unmodifiable list of this message type's nested types.

Oneofs

IList< OneofDescriptor > Oneofs

An unmodifiable list of the "oneof" field collections in this message type.

Parser

MessageParser Parser

A parser for this message type.

As MessageDescriptor is not generic, this cannot be statically typed to the relevant type, but it should produce objects of a type compatible with ClrType.

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. No message parser object is created for such messages, so this property will return null in such cases.

For wrapper types (Google.Protobuf.WellKnownTypes.StringValue and the like), the parser returned here will be the generated message type, not the native type used by reflection for fields of those types. Code using reflection should call IsWrapperType to determine whether a message descriptor represents a wrapper type, and handle the result appropriately.

Proto

DescriptorProto Proto

Public functions

FindDescriptor< T >

T FindDescriptor< T >(
  string name
)

Finds a nested descriptor by name.

The is valid for fields, nested message types, oneofs and enums.

Details
Parameters
name
The unqualified name of the descriptor, e.g. "Foo"
Returns
The descriptor, or null if not found.

FindFieldByName

FieldDescriptor FindFieldByName(
  String name
)

Finds a field by field name.

Details
Parameters
name
The unqualified name of the field (e.g. "foo").
Returns
The field's descriptor, or null if not found.

FindFieldByNumber

FieldDescriptor FindFieldByNumber(
  int number
)

Finds a field by field number.

Details
Parameters
number
The field number within this message type.
Returns
The field's descriptor, or null if not found.