New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Mark GetOption API as obsolete and expose the "GetOptions()" method on descriptors instead #7434
C#: Mark GetOption API as obsolete and expose the "GetOptions()" method on descriptors instead #7434
Changes from 5 commits
944055a
9720ae4
f4ff220
062c2dc
402ce8b
673245f
ff999c9
0688883
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,12 +128,20 @@ public EnumValueDescriptor FindValueByName(string name) | |
/// <summary> | ||
/// The (possibly empty) set of custom options for this enum. | ||
/// </summary> | ||
[Obsolete("CustomOptions are obsolete. Use GetOption")] | ||
[Obsolete("CustomOptions are obsolete. Use the Options property.")] | ||
public CustomOptions CustomOptions => new CustomOptions(Proto.Options?._extensions?.ValuesByNumber); | ||
|
||
/// <summary> | ||
/// The <c>EnumOptions</c>, defined in <c>descriptor.proto</c>. | ||
/// Custom options can be retrieved as extensions of the returned message. | ||
/// NOTE: A defensive copy is created each time this property is retrieved. | ||
/// </summary> | ||
public EnumOptions Options => (Proto.Options as IDeepCloneable<EnumOptions>)?.Clone(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, removed the cast. |
||
|
||
/// <summary> | ||
/// Gets a single value enum option for this descriptor | ||
/// </summary> | ||
[Obsolete("GetOption is obsolete. Use the Options property.")] | ||
public T GetOption<T>(Extension<EnumOptions, T> extension) | ||
{ | ||
var value = Proto.Options.GetExtension(extension); | ||
|
@@ -143,6 +151,7 @@ public T GetOption<T>(Extension<EnumOptions, T> extension) | |
/// <summary> | ||
/// Gets a repeated value enum option for this descriptor | ||
/// </summary> | ||
[Obsolete("GetOption is obsolete. Use the Options property.")] | ||
public RepeatedField<T> GetOption<T>(RepeatedExtension<EnumOptions, T> extension) | ||
{ | ||
return Proto.Options.GetExtension(extension).Clone(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can null ever be returned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved the docs.