-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
More stern warning about string culture comparison #9388
Conversation
Learn Build status updates of commit d256314: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
I don't think this change is needed. These notes basically say "This overload uses current culture implicitly, but this might be unexpected. Consider instead using overload that explicitly accepts culture." Nowhere it was implied that InvariantCulture should be used. It is not useful to add that InvariantCulture is rarely appropriate, it's too vague, and too disconnected from the preceding text. If any addition is needed here, it should be more actionable, something like "If you don't need linguistic comparison, consider using StringComparison.Ordinal instead". |
046e927
to
b3a3dbd
Compare
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.
@Smaug123 thanks for submitting the PR and updating the note. The new suggested changes LGTM.
Learn Build status updates of commit 046e927: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Learn Build status updates of commit b3a3dbd: ✅ Validation status: passed
For more details, please refer to the build report. For any questions, please:
|
Summary
Add a further warning about
InvariantCulture
in string comparison methods.It continues to be true that you need to read lots of documentation before using
String.StartsWith
and friends, and the docs continue not to tell you that this is the case. This PR elevates some more of the most critical information from Best Practices for Using Strings to the API docs.Source for "rarely appropriate" is Best Practices:
ref: #8973