Reputation: 15164
I work in a company that their acronym is something like XyZ
(uppercase followed by lowercase than followed by uppercase again).
This word is spread across all our namespaces. When I run FxCop against our projects it accuses IdentifiersShouldBeCasedCorrectly
(CA1709). The suggestion is to capitalize just the first letter (what I don't want).
How do I make FxCop understand that the word XyZ
is known, spelled correctly and properly cased? (In other words, that is well-written).
I added the word to the CustomDictionary.xml
file: I've added to Recognized
words; Unrecognized
words; and alsoAcronyms
with CasingExceptions
. None of these made any effect.
I also verified that FxCop is indeed reading the custom dictionary file, when I add another word in the acronym it stops reporting as a casing error as expected (but only for all caps words).
I'm using FxCop 1.36 (the GUI one) with C# projects.
Update
Adding just Xy
to casing exceptions seems to make FxCop ignore XyZ
as I want.
Still not a great solution since it will allow wrong words like XyX
or XyW
when the (only) correct one is XyZ
.
Upvotes: 2
Views: 636
Reputation: 14890
You can add XyZ
to an FxCop dictionary - see How to: Customize the Code Analysis Dictionary.
Code Analysis uses a built-in dictionary to check identifiers in your code for errors in spelling, grammatical case, and other naming conventions of the .NET Framework guidelines. You can create a custom dictionary Xml file to add, remove, or modify terms, abbreviations, and acronyms to the built-in dictionary.
Dictionary/Acronyms/CasingExceptions/Acronym
<Dictionary>
<Acronyms>
<CasingExceptions>
<Acronym>NESW</Acronym> <!-- North East South West -->
...
</CasingExceptions>
...
</Acronyms>
...
</Dictionary>
Terms in the Dictionary/Acronyms/CasingExceptions node are applied to the following code analysis rules:
CA1709: Identifiers should be cased correctly
Upvotes: 2