Google.Protobuf.Reflection.FileDescriptor

Describes a .proto file, including everything defined within.

Summary

IDescriptor is implemented such that the File property returns this descriptor, and the FullName is the same as the Name.

Inheritance

Inherits from: Google.Protobuf.Reflection.IDescriptor

Properties

Dependencies
IList< FileDescriptor >
Unmodifiable list of this file's dependencies (imports).
DescriptorPool
DescriptorPool
Pool containing symbol descriptors.
DescriptorProtoFileDescriptor
FileDescriptor
Returns the file descriptor for descriptor.proto.
EnumTypes
IList< EnumDescriptor >
Unmodifiable list of top-level enum types declared in this file.
MessageTypes
IList< MessageDescriptor >
Unmodifiable list of top-level message types declared in this file.
Proto
FileDescriptorProto
The descriptor in its protocol message representation.
PublicDependencies
IList< FileDescriptor >
Unmodifiable list of this file's public dependencies (public imports).
SerializedData
ByteString
The original serialized binary form of this descriptor.
Services
IList< ServiceDescriptor >
Unmodifiable list of top-level services declared in this file.

Public attributes

Name => Proto.Name
string
The file name.
Package => Proto.Package
string
The package as declared in the .proto file.

Public functions

FindTypeByName< T >(String name)
T
Finds a type (message, enum, service or extension) in the file by name.
ToString()
override string
Returns a System.String that represents this instance.

Public static functions

FromGeneratedCode(byte[] descriptorData, FileDescriptor[] dependencies, GeneratedClrTypeInfo generatedCodeInfo)
FileDescriptor
Creates a descriptor for generated code.

Properties

Dependencies

IList< FileDescriptor > Dependencies

Unmodifiable list of this file's dependencies (imports).

DescriptorPool

DescriptorPool DescriptorPool

Pool containing symbol descriptors.

DescriptorProtoFileDescriptor

FileDescriptor DescriptorProtoFileDescriptor

Returns the file descriptor for descriptor.proto.

This is used for protos which take a direct dependency on descriptor.proto, typically for annotations. While descriptor.proto is a proto2 file, it is built into the Google.Protobuf runtime for reflection purposes. The messages are internal to the runtime as they would require proto2 semantics for full support, but the file descriptor is available via this property. The C# codegen in protoc automatically uses this property when it detects a dependency on descriptor.proto.

The file descriptor for descriptor.proto.

EnumTypes

IList< EnumDescriptor > EnumTypes

Unmodifiable list of top-level enum types declared in this file.

MessageTypes

IList< MessageDescriptor > MessageTypes

Unmodifiable list of top-level message types declared in this file.

Proto

FileDescriptorProto Proto

The descriptor in its protocol message representation.

PublicDependencies

IList< FileDescriptor > PublicDependencies

Unmodifiable list of this file's public dependencies (public imports).

SerializedData

ByteString SerializedData

The original serialized binary form of this descriptor.

Services

IList< ServiceDescriptor > Services

Unmodifiable list of top-level services declared in this file.

Public attributes

Name

string Name => Proto.Name

The file name.

Package

string Package => Proto.Package

The package as declared in the .proto file.

This may or may not be equivalent to the .NET namespace of the generated classes.

Public functions

FindTypeByName< T >

T FindTypeByName< T >(
  String name
)

Finds a type (message, enum, service or extension) in the file by name.

Does not find nested types.

Details
Parameters
name
The unqualified type name to look for.
Template Parameters
T
The type of descriptor to look for
Returns
The type's descriptor, or null if not found.

ToString

override string ToString()

Returns a System.String that represents this instance.

Details
Returns
A System.String that represents this instance.

Public static functions

FromGeneratedCode

FileDescriptor FromGeneratedCode(
  byte[] descriptorData,
  FileDescriptor[] dependencies,
  GeneratedClrTypeInfo generatedCodeInfo
)

Creates a descriptor for generated code.

This method is only designed to be used by the results of generating code with protoc, which creates the appropriate dependencies etc. It has to be public because the generated code is "external", but should not be called directly by end users.