-
Notifications
You must be signed in to change notification settings - Fork 166
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
Extensible enums should use case-sensitive comparisons (with possible opt-out) #2826
Comments
For comparison, it seems languages are inconsistent:
Talking with @JeffreyRichter, perhaps we should relax the SDK guidelines (actually write a general guideline and remove language-specific recommendations) but keep REST API guidelines as-is (services should use case-sensitive comparisons, but could be case-insensitive if they desire). To note, this is only about discriminators and LRO state. This is where it typically matters - where the SDKs themselves are doing comparisons. |
@archerzz, please help to follow up |
Given .Net SDK has a much larger user base, I'm not sure if we should do this. I think the case-insensitive comparison works fine for happy path.
However, case-insensitive comparison will provide better error tolerance when:
On the other hand, case-insensitive comparison will also hide the errors. But I think it's a benign compromise. If we change to case-sensitive comparison, we could break customers' programs, which requires fixes in either their programs or in the back-end service. The latter could take more time. The impact could be non-trivial. |
This is shared by all .net languages, since other languages are using case-sensitive comparisons it should be ok for .net, but not sure why it's insensitive now. |
I'll add you two the thread I have with architects, who are (mostly) pushing for consistent case-sensitive comparisons across the board. Note that our guidelines for .NET do say to use case-sensitive comparisons, which @KrzysztofCwalina is maintaining should be our default. |
Originating from Azure/azure-sdk-for-net#29141 and after discussions with @KrzysztofCwalina we should actually be using case-sensitive comparisons for extensible enums as exemplified in our guidelines but with the stipulation from Azure/azure-sdk#1251:
Thus, the generate should default to case-sensitive comparisons but is currently using
InvariantCultureIgnoreCase
. It should beOrdinal
as documented for performance reasons; however, we do need a way to opt into case-insensitive comparisons like needed for Azure/azure-sdk-for-net#29141.This is also consistent with our Azure REST API guidelines:
The text was updated successfully, but these errors were encountered: