Strings are compared or searched with the current culture's rules, though no StringComparison is given
What it finds
string.Compare(a, b), a.CompareTo(b), and StartsWith, EndsWith and IndexOf with a string argument use the culture of the current thread: results change between machines, and in some cultures letters compare in surprising ways. Identifiers, keys, paths and protocol text want StringComparison.Ordinal. The rule reports these calls with a string literal of more than one character and no comparison argument.
From the rule's source, culture_sensitive_comparison.rs.
using System; class Paths{ bool Hidden(string name) => name.StartsWith(".git");tx0 reports: StartsWith compares by the current culture bool Hidden2(string name) => name.StartsWith(".git", StringComparison.Ordinal);} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:culture-sensitive-comparison" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:culture-sensitive-comparison] reason="..."tx0 explain tx0/csharp:culture-sensitive-comparison shows the same in the terminal. Found a false positive? Report it.