-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rule: MA0006 Use String.Equals instead of equality operator #24
Comments
What Besides that, I agree that it does NOT improve readability. |
This documentation from Microsoft also speaks against using == for comparison so I think we should keep it. |
Please red comment from cjacobsen. |
As far as I understand using In my mind, this way of comparing strings are by far the most commonly used, so applying the MA0006 rule in general would add a lot of clutter. In most cases I think it would be very obvious if you need to compare using case-insensitivity or the CurrentCulture, and then use the |
That's surprising to me @rickykaare, but you are right, at least if we read the latest string.cs code. Here we see that That takes the performance concern out of the equation for me. The question that is left is whether we want to be explicit in our code about our intentions, e.g. signaling that, yes, we have thought about culture and this is what we want. |
ROOT=NONE, because in most cases we are only doing ordinal comparisons anyway, and == leads to cleaner code. Exception to this rule when working on an application that is multi cultured. |
Rule summary
What is the problem
This does not improve readability as the rules description claims.
Suggestion
disable this rule in root .editorconfig with dotnet_diagnostic.MA0006.severity = none
The text was updated successfully, but these errors were encountered: