Steeltoe
Steeltoe copied to clipboard
Address Sonar rules related to lack of "CultureInfo" usage
Address existing violations of the following, related rules:
- S1449: Culture should be specified for "string" operations
- S4056: Overloads with a "CultureInfo" or an "IFormatProvider" parameter should be used
- S4058: Overloads with a "StringComparison" parameter should be used
in the codebase and set severity to Warning in Steeltoe.Debug.ruleset and Steeltoe.Release.ruleset.
To find existing violations, enable the rule (see above) and rebuild src/Steeltoe.All.sln to make them appear in the Output window.
To address the violations, choose from the following on a case-by-case basis:
- Always use
ToUpper[Invariant]instead ofToLower, this matters in Turkey. - Always pass culture information. Decide whether the call should be culture-sensitive or not
- Use the Invariant Culture to not depend on OS-level regional settings (date/time/decimal separators), typically used for import/export file formats, query languages, file paths etc.
- Never use "en-US", this still takes OS-level settings into account: lots of SpeL tests fail even when running on English Windows with Dutch regional settings.
- Use the Current Culture to take culture-specific rules into account, for example:
- "Straße" and "Strasse" are equivalent in German
- The number "1,234.56" is formatted as "1.234,56" in Dutch
- ~Suppress the violation in code using
#pragma warning disable/restore, preceded by a justification comment if not obvious~
Related to #949.