Short acronyms should be uppercase

TypeName

ShortAcronymsShouldBeUppercase

CheckId

CA1706

Category

Microsoft.Naming

Breaking Change

Breaking

Cause

The name of an identifier contains a two-letter acronym and the second letter is lowercase.

Rule Description

This rule splits the name into words based on the casing and checks any two-letter words against a list of common two-letter words, such as "In" or "My". If a match is not found, the word is assumed to be an acronym. For parameters, the first word is ignored due to the camel casing convention used for parameter names.

By convention, two-letter acronyms use all uppercase letters, and acronyms of three or more characters use Pascal casing. The following examples conform to this naming convention: 'DB', 'CR', 'Cpa', and 'Ecma'. The following examples violate the convention: 'Io', 'XML', and 'DoD', and for non-parameter names, 'xp' and 'cpl'.

'ID' is special-cased to cause a violation of this rule. 'Id' is not an acronym but is an abbreviation for 'identification'.

Naming conventions provide a common look for libraries that target the common language runtime. This reduces the learning curve required for new software libraries, and increases customer confidence that the library was developed by someone with expertise in developing managed code.

How to Fix Violations

To fix a violation of this rule, change the second letter of the acronym to uppercase.

When to Exclude Warnings

It is safe to exclude a warning from this rule if the two letters are not an acronym but instead form a word or proper name.

Identifiers should be cased correctly

Identifiers should differ by more than case

Long acronyms should be pascal-cased