-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-System.Globalizationbugcode-analyzerMarks an issue that suggests a Roslyn analyzerMarks an issue that suggests a Roslyn analyzer
Milestone
Description
CA1862: Prefer using 'StringComparer'/'StringComparison' to perform case-insensitive string comparisons suggestion changing semantics of the comparison
Warning: Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison
using System;
// These are both lower case Greek Sigmas
string a = "σ";
string b = "ς";
// Prints True
Console.WriteLine(a.Equals(b, StringComparison.InvariantCultureIgnoreCase));
string lowerA = a.ToLowerInvariant();
string lowerB = b.ToLowerInvariant();
// Prints False
Console.WriteLine(lowerA == lowerB);Originally posted by @MichalStrehovsky in #89630 (comment):
This is changing semantics of the comparison. Do we really have an analyzer that suggests people blindly do this?
Metadata
Metadata
Assignees
Labels
area-System.Globalizationbugcode-analyzerMarks an issue that suggests a Roslyn analyzerMarks an issue that suggests a Roslyn analyzer