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.
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 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eOneofDescriptor represents a collection of fields in a message type where only one field can be set at a time.\u003c/p\u003e\n"],["\u003cp\u003eIt inherits from DescriptorBase and implements IDescriptor, providing functionalities like accessing the index, full name, and file information.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAccessor\u003c/code\u003e property allows reflective access to the values of the oneof fields within a message, which is non-null in descriptors of generated code.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eContainingType\u003c/code\u003e property returns the \u003ccode\u003eMessageDescriptor\u003c/code\u003e that includes the oneof, and \u003ccode\u003eFields\u003c/code\u003e returns an ordered list of fields in the oneof.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003eGetOptions\u003c/code\u003e and \u003ccode\u003eToProto\u003c/code\u003e provide access to options and a protobuf representation of the oneof, while \u003ccode\u003eIsSynthetic\u003c/code\u003e indicates if the oneof is synthetic.\u003c/p\u003e\n"]]],[],null,["# Class OneofDescriptor (3.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [3.27.1 (latest)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.OneofDescriptor)\n- [3.23.0](/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.Reflection.OneofDescriptor)\n- [3.15.8](/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.Reflection.OneofDescriptor) \n\n public sealed class OneofDescriptor : DescriptorBase, IDescriptor\n\nDescribes a \"oneof\" field collection in a message type: a set of\nfields of which at most one can be set in any particular message. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e [DescriptorBase](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase) \\\u003e OneofDescriptor \n\nImplements\n----------\n\n[IDescriptor](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.IDescriptor) \n\nInherited Members\n-----------------\n\n[DescriptorBase.Index](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_Index) \n[DescriptorBase.FullName](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_FullName) \n[DescriptorBase.File](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_File) \n[DescriptorBase.Declaration](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_Declaration) \n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Protobuf.Reflection](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection)\n\nAssembly\n--------\n\nGoogle.Protobuf.dll\n\nProperties\n----------\n\n### Accessor\n\n public OneofAccessor Accessor { get; }\n\nGets an accessor for reflective access to the values associated with the oneof\nin a particular message.\n\n**Remarks** \n\nIn descriptors for generated code, the value returned by this property will always be non-null.\n\n\nIn dynamically loaded descriptors, the value returned by this property will current be null;\nif and when dynamic messages are supported, it will return a suitable accessor to work with\nthem.\n\n### ContainingType\n\n public MessageDescriptor ContainingType { get; }\n\nGets the message type containing this oneof.\n\n### CustomOptions\n\n [Obsolete(\"CustomOptions are obsolete. Use the GetOptions method.\")]\n public CustomOptions CustomOptions { get; }\n\nThe (possibly empty) set of custom options for this oneof.\n\n### Fields\n\n public IList\u003cFieldDescriptor\u003e Fields { get; }\n\nGets the fields within this oneof, in declaration order.\n\n### IsSynthetic\n\n public bool IsSynthetic { get; }\n\nReturns `true` if this oneof is a synthetic oneof containing a proto3 optional field;\n`false` otherwise.\n\n### Name\n\n public override string Name { get; }\n\nThe brief name of the descriptor's target.\n\n**Overrides** \n[DescriptorBase.Name](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_Name)\n\nMethods\n-------\n\n### GetOption\\\u003cT\\\u003e(Extension\\\u003cOneofOptions, T\\\u003e)\n\n [Obsolete(\"GetOption is obsolete. Use the GetOptions() method.\")]\n public T GetOption\u003cT\u003e(Extension\u003cOneofOptions, T\u003e extension)\n\nGets a single value oneof option for this descriptor\n\n### GetOption\\\u003cT\\\u003e(RepeatedExtension\\\u003cOneofOptions, T\\\u003e)\n\n [Obsolete(\"GetOption is obsolete. Use the GetOptions() method.\")]\n public RepeatedField\u003cT\u003e GetOption\u003cT\u003e(RepeatedExtension\u003cOneofOptions, T\u003e extension)\n\nGets a repeated value oneof option for this descriptor\n\n### GetOptions()\n\n public OneofOptions GetOptions()\n\nThe `OneofOptions`, defined in `descriptor.proto`.\nIf the options message is not present (i.e. there are no options), `null` is returned.\nCustom options can be retrieved as extensions of the returned message.\nNOTE: A defensive copy is created each time this property is retrieved.\n\n### ToProto()\n\n public OneofDescriptorProto ToProto()\n\nReturns a clone of the underlying [OneofDescriptorProto](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.OneofDescriptorProto) describing this oneof.\nNote that a copy is taken every time this method is called, so clients using it frequently\n(and not modifying it) may want to cache the returned value."]]