Partager via


CA1308: Normalize strings to uppercase

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Item Value
TypeName NormalizeStringsToUppercase
CheckId CA1308
Category Microsoft.Globalization
Breaking Change Non-breaking

Cause

An operation normalizes a string to lowercase.

Rule Description

Strings should be normalized to uppercase. A small group of characters, when they are converted to lowercase, cannot make a round trip. To make a round trip means to convert the characters from one locale to another locale that represents character data differently, and then to accurately retrieve the original characters from the converted characters.

How to Fix Violations

Change operations that convert strings to lowercase so that the strings are converted to uppercase instead. For example, change String.ToLower(CultureInfo.InvariantCulture) to String.ToUpper(CultureInfo.InvariantCulture).

When to Suppress Warnings

It is safe to suppress a warning message when you are not making security decision based on the result (for example, when you are displaying it in the UI).

See Also

Globalization Warnings