CA1702: Compound words should be cased correctly
Item | Value |
---|---|
RuleId | CA1702 |
Category | Microsoft.Naming |
Breaking change | Breaking- when fired on assemblies. Non-breaking - when fired on type parameters. |
Cause
The name of an identifier contains multiple words, and at least one of the words appears to be a compound word that is not cased correctly.
Note
This rule has been deprecated. For more information, see Deprecated rules.
Rule description
The name of the identifier is split into words that are based on the casing. Each contiguous two-word combination is checked by the Microsoft spelling checker library. If it is recognized, the identifier produces a violation of the rule. Examples of compound words that cause a violation are "CheckSum" and "MultiPart", which should be cased as "Checksum" and "Multipart", respectively. Due to previous common usage, several exceptions are built into the rule, and several single words are flagged, such as "Toolbar" and "Filename", that should be cased as two distinct words (in this case, "ToolBar" and "FileName").
Naming conventions provide a common look for libraries that target the common language runtime. This reduces the learning curve that is required for new software libraries, and increases customer confidence that the library was developed by someone who has expertise in developing managed code.
How to fix violations
Change the name so that it is cased correctly.
Language
The spell checker currently checks only against English-based culture dictionaries. You can change the culture of your project in the project file, by adding the CodeAnalysisCulture element.
For example:
<Project ...>
<PropertyGroup>
<CodeAnalysisCulture>en-AU</CodeAnalysisCulture>
Important
If you set the culture to anything other than an English-based culture, this code analysis rule is silently disabled.
When to suppress warnings
It is safe to suppress a warning from this rule if both parts of the compound word are recognized by the spelling dictionary, and the intent is to use two words.
Related rules
- CA1701: Resource string compound words should be cased correctly
- CA1709: Identifiers should be cased correctly
- CA1708: Identifiers should differ by more than case