Globalization rules
Globalization rules support world-ready libraries and applications.
In this section
Rule | Description |
---|---|
CA1303: Do not pass literals as localized parameters | An externally visible method passes a string literal as a parameter to a .NET constructor or method, and that string should be localizable. |
CA1304: Specify CultureInfo | A method or constructor calls a member that has an overload that accepts a System.Globalization.CultureInfo parameter, and the method or constructor does not call the overload that takes the CultureInfo parameter. When a CultureInfo or System.IFormatProvider object is not supplied, the default value that is supplied by the overloaded member might not have the effect that you want in all locales. |
CA1305: Specify IFormatProvider | A method or constructor calls one or more members that have overloads that accept a System.IFormatProvider parameter, and the method or constructor does not call the overload that takes the IFormatProvider parameter. When a System.Globalization.CultureInfo or IFormatProvider object is not supplied, the default value that is supplied by the overloaded member might not have the effect that you want in all locales. |
CA1307: Specify StringComparison for clarity | A string comparison operation uses a method overload that does not set a StringComparison parameter. |
CA1308: Normalize strings to uppercase | Strings should be normalized to uppercase. A small group of characters cannot make a round trip when they are converted to lowercase. |
CA1309: Use ordinal StringComparison | A string comparison operation that is nonlinguistic does not set the StringComparison parameter to either Ordinal or OrdinalIgnoreCase. By explicitly setting the parameter to either StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase, your code often gains speed, becomes more correct, and becomes more reliable. |
CA1310: Specify StringComparison for correctness | A string comparison operation uses a method overload that does not set a StringComparison parameter and uses culture-specific string comparison by default. |
CA1311: Specify a culture or use an invariant version | Specify a culture or use an invariant culture to avoid implicit dependency on the current culture when calling ToUpper or ToLower . |
CA2101: Specify marshalling for P/Invoke string arguments | A platform invoke member allows for partially trusted callers, has a string parameter, and does not explicitly marshal the string. This can cause a potential security vulnerability. |
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for