|
|
@ -45,7 +45,6 @@ namespace Google.Protobuf.Reflection |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public sealed class OneofDescriptor : DescriptorBase |
|
|
|
public sealed class OneofDescriptor : DescriptorBase |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly OneofDescriptorProto proto; |
|
|
|
|
|
|
|
private MessageDescriptor containingType; |
|
|
|
private MessageDescriptor containingType; |
|
|
|
private IList<FieldDescriptor> fields; |
|
|
|
private IList<FieldDescriptor> fields; |
|
|
|
private readonly OneofAccessor accessor; |
|
|
|
private readonly OneofAccessor accessor; |
|
|
@ -53,7 +52,7 @@ namespace Google.Protobuf.Reflection |
|
|
|
internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, string clrName) |
|
|
|
internal OneofDescriptor(OneofDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, string clrName) |
|
|
|
: base(file, file.ComputeFullName(parent, proto.Name), index) |
|
|
|
: base(file, file.ComputeFullName(parent, proto.Name), index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.proto = proto; |
|
|
|
this.Proto = proto; |
|
|
|
containingType = parent; |
|
|
|
containingType = parent; |
|
|
|
file.DescriptorPool.AddSymbol(this); |
|
|
|
file.DescriptorPool.AddSymbol(this); |
|
|
|
|
|
|
|
|
|
|
@ -68,7 +67,18 @@ namespace Google.Protobuf.Reflection |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// The brief name of the descriptor's target. |
|
|
|
/// The brief name of the descriptor's target. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public override string Name { get { return proto.Name; } } |
|
|
|
public override string Name => Proto.Name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Visible for testing |
|
|
|
|
|
|
|
internal OneofDescriptorProto Proto { get; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Returns a clone of the underlying <see cref="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. |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <returns>A protobuf representation of this oneof descriptor.</returns> |
|
|
|
|
|
|
|
public OneofDescriptorProto ToProto() => Proto.Clone(); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Gets the message type containing this oneof. |
|
|
|
/// Gets the message type containing this oneof. |
|
|
@ -118,7 +128,7 @@ namespace Google.Protobuf.Reflection |
|
|
|
/// The (possibly empty) set of custom options for this oneof. |
|
|
|
/// The (possibly empty) set of custom options for this oneof. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
[Obsolete("CustomOptions are obsolete. Use the GetOptions method.")] |
|
|
|
[Obsolete("CustomOptions are obsolete. Use the GetOptions method.")] |
|
|
|
public CustomOptions CustomOptions => new CustomOptions(proto.Options?._extensions?.ValuesByNumber); |
|
|
|
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// The <c>OneofOptions</c>, defined in <c>descriptor.proto</c>. |
|
|
|
/// The <c>OneofOptions</c>, defined in <c>descriptor.proto</c>. |
|
|
@ -126,7 +136,7 @@ namespace Google.Protobuf.Reflection |
|
|
|
/// Custom options can be retrieved as extensions of the returned message. |
|
|
|
/// Custom options can be retrieved as extensions of the returned message. |
|
|
|
/// NOTE: A defensive copy is created each time this property is retrieved. |
|
|
|
/// NOTE: A defensive copy is created each time this property is retrieved. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
public OneofOptions GetOptions() => proto.Options?.Clone(); |
|
|
|
public OneofOptions GetOptions() => Proto.Options?.Clone(); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Gets a single value oneof option for this descriptor |
|
|
|
/// Gets a single value oneof option for this descriptor |
|
|
@ -134,7 +144,7 @@ namespace Google.Protobuf.Reflection |
|
|
|
[Obsolete("GetOption is obsolete. Use the GetOptions() method.")] |
|
|
|
[Obsolete("GetOption is obsolete. Use the GetOptions() method.")] |
|
|
|
public T GetOption<T>(Extension<OneofOptions, T> extension) |
|
|
|
public T GetOption<T>(Extension<OneofOptions, T> extension) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var value = proto.Options.GetExtension(extension); |
|
|
|
var value = Proto.Options.GetExtension(extension); |
|
|
|
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value; |
|
|
|
return value is IDeepCloneable<T> ? (value as IDeepCloneable<T>).Clone() : value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -144,7 +154,7 @@ namespace Google.Protobuf.Reflection |
|
|
|
[Obsolete("GetOption is obsolete. Use the GetOptions() method.")] |
|
|
|
[Obsolete("GetOption is obsolete. Use the GetOptions() method.")] |
|
|
|
public RepeatedField<T> GetOption<T>(RepeatedExtension<OneofOptions, T> extension) |
|
|
|
public RepeatedField<T> GetOption<T>(RepeatedExtension<OneofOptions, T> extension) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return proto.Options.GetExtension(extension).Clone(); |
|
|
|
return Proto.Options.GetExtension(extension).Clone(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal void CrossLink() |
|
|
|
internal void CrossLink() |
|
|
|