Class OneofDescriptor (3.23.0)

public sealed class OneofDescriptor : DescriptorBase, IDescriptor

Describes a "oneof" field collection in a message type: a set of fields of which at most one can be set in any particular message.

Inheritance

object > DescriptorBase > OneofDescriptor

Implements

IDescriptor

Namespace

Google.Protobuf.Reflection

Assembly

Google.Protobuf.dll

Properties

Accessor

public OneofAccessor Accessor { get; }

Gets an accessor for reflective access to the values associated with the oneof in a particular message.

Property Value
Type Description
OneofAccessor

The accessor used for reflective access.

Remarks

In descriptors for generated code, the value returned by this property will always be non-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.

ContainingType

public MessageDescriptor ContainingType { get; }

Gets the message type containing this oneof.

Property Value
Type Description
MessageDescriptor

The message type containing this oneof.

CustomOptions

[Obsolete("CustomOptions are obsolete. Use the GetOptions method.")]
public CustomOptions CustomOptions { get; }

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

Property Value
Type Description
CustomOptions

Fields

public IList<FieldDescriptor> Fields { get; }

Gets the fields within this oneof, in declaration order.

Property Value
Type Description
IListFieldDescriptor

The fields within this oneof, in declaration order.

IsSynthetic

public bool IsSynthetic { get; }

Returns true if this oneof is a synthetic oneof containing a proto3 optional field; false otherwise.

Property Value
Type Description
bool

Name

public override string Name { get; }

The brief name of the descriptor's target.

Property Value
Type Description
string
Overrides

Methods

GetOption<T>(Extension<OneofOptions, T>)

[Obsolete("GetOption is obsolete. Use the GetOptions() method.")]
public T GetOption<T>(Extension<OneofOptions, T> extension)

Gets a single value oneof option for this descriptor

Parameter
Name Description
extension ExtensionOneofOptions
Returns
Type Description
T
Type Parameter
Name Description
T

GetOption<T>(RepeatedExtension<OneofOptions, T>)

[Obsolete("GetOption is obsolete. Use the GetOptions() method.")]
public RepeatedField<T> GetOption<T>(RepeatedExtension<OneofOptions, T> extension)

Gets a repeated value oneof option for this descriptor

Parameter
Name Description
extension RepeatedExtensionOneofOptions
Returns
Type Description
RepeatedField
Type Parameter
Name Description
T

GetOptions()

public OneofOptions GetOptions()

The OneofOptions, 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
Type Description
OneofOptions

ToProto()

public OneofDescriptorProto ToProto()

Returns a clone of the underlying OneofDescriptorProto describing this oneof. 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.

Returns
Type Description
OneofDescriptorProto

A protobuf representation of this oneof descriptor.