How is it possible to get the FxCop custom dictionary to work correctly?
I have tried adding words to be recognised to the file 'CustomDictionary.xml', which is kept in the same folder as the FxCop project file. This does not seem to work, as I still get the 'Identifiers should be spelled correctly' FxCop message, even after reloading and re-running FxCop. Using version 1.36.
Further to David Schmitt's answer above, you may need to alter/remove the custom dictionary that ships with FxCop from within the FxCop installation folder.
I've just installed FxCop v1.36, and couldn't get the Project specific words in my dictionary to be recognised until I removed the custom dictionary at
C:\Program Files\Microsoft FxCop 1.36\CustomDictionary.xml
.Once, I'd moved that to one side, FxCop started using the
CustomDictionary.xml
in the solution folder.This does beg the question of how to add common words to a shared custom dictionary and project/solution specific words within other custom dictionaries and actually having FxCop use both. But for now it's working....
If you use it inside Visual Studio...
From Visual Studio Code Analysis Team Blog
I didn't have to set Build Action to be CodeAnalysisDictionary. In fact, I didn't even have that as an option (using Visual Studio 2010 Professional). I'm using the FxCop Integrator extension. It allows you to right-click on the Solution and choose Code Analysis. The other option is More Tasks. Within that More Tasks menu is the ability to edit Edit FxCop Dictionary. When I performed the edit, it created a new Solution Folder called Code Analysis containing a new XML file called FxCopDictionary.xml. This XML file is set up as one would expect the CustomDictionary.xml file to look like.
Hope this helps someone out there!
To my knowledge, FxCop 1.35 and onwards use two sources for the dictionary.
The easiest way is to just call it "CustomDictionary.xml" and put it in your solution folder, where FxCop (1.36 tested here) will pick it up automatically, if you have
in your FxCop project file.
Alternatively you can specify it via the
/dictionary
command line parameter.I am running FxCopCmd.exe as part of my build process, and here I pass the dictionary command line parameter
This work with the visual studio 2010 RC version of FxCop. Don't know if it'll work with previous versions.