You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the very fact I am passing a CultureInfo explicitly to ToLower should be enough to tell that the actual culture is potentially meaningful for the comparison.
Moreover, the in-editor description of the rule feels verbose and very lacking in self-confidence ("keep in mind this might cause subtle changes in behavior, so make sure to conduct thorough testing") for an analysis with an automatic code fix.
Additional context
Internally Contains leverages IndexOf, which internally uses CultureInfo.CompareInfo:
Analyzer
Diagnostic ID: CA1862:
Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
Describe the improvement
The analyzer is triggered by the following code:
I think the very fact I am passing a
CultureInfo
explicitly toToLower
should be enough to tell that the actual culture is potentially meaningful for the comparison.Moreover, the in-editor description of the rule feels verbose and very lacking in self-confidence ("keep in mind this might cause subtle changes in behavior, so make sure to conduct thorough testing") for an analysis with an automatic code fix.
Additional context
Internally
Contains
leveragesIndexOf
, which internally usesCultureInfo.CompareInfo
:https://github.com/dotnet/runtime/blob/2d5f1f0165e826ac01745df9f3a390905e282ed3/src/libraries/System.Private.CoreLib/src/System/String.Searching.cs#L55
There could be value in exposing variants of
IndexOf
,Contains
and similar methods which accept aCultureInfo
or aCompareInfo
object.The text was updated successfully, but these errors were encountered: