Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Analysis/FxCop CA1726:UsePreferredTerms showing Cancelled as Deprecated

I'm in the UK where we spell Cancelled with two L's. I want to use the Code Analysis rule "CA1726:UsePreferredTerms" but I don't want it to flag up "Cancelled" as a violation.

I have tried adding <CodeAnalysisCulture>en-GB</CodeAnalysisCulture> to the project file to encourage Code Analysis to use British Spelling

I have tried adding <Recognized><Word>Cancelled</Word></Recognized> into the projects CustomDictionary.xml

I'm not keen on adding a suppression for every time the word cancelled is used.

I want a solution which can be checked into source control for other developers to work on so I don't want to change my local C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\CustomDictionary.xml

I am using Visual Studio 2013.

Is there any way to achieve this?

like image 760
user1069816 Avatar asked May 14 '15 08:05

user1069816


1 Answers

As I suspect you already know, there's no built in way to achieve this. Overriding the built in custom dictionary has been raised before in various forms with the same conclusion, currently you can't override/reset the custom dictionary. It's a low priority item, since there is a work around, which is to edit the CustomDictionary.xml that comes with visual studio.

If you're using FxCopCmd as part of your build process to do the analysis, then one option that seems to work is to copy the "FxCop" folder into a folder (such as Tools\FxCop) that is part of your checked in project. Your build process could then use this executable, rather than the on in "program files". Since the copied folder has the default CustomDictionary.xml in it, you would then be able to edit it as part of your source controlled project. It may be possible to do a similar thing from visual studio, but I can't see an obvious way to change where it runs the code analysis from.

Depending on your work setup and approach to development, a simpler solution may simply be to rename the visual studio installed "CustomDictionary.xml" to "CustomDictionary.xml.bak" on all of your developers machines and copy the contents of it (minus the bits you don't want) into your solutions "CustomDictionary.xml". This would give you complete control. Obviously this isn't ideal because it would effect all projects you work on on the machine, so you would may have to add the custom dictionary multiple times and of course each developer would have to deal with it, however it would be possible to modify your build process to check for the presence of the default CustomDictionary and remind developers that they needed to rename it for the build to work correctly.

If you can actually get the FxCop gui to download and install (I couldn't) there may be other workarounds using a ".fxcop" project file, including SearchFxCopDir="False". However, again as I understand it this isn't going to make any difference to your Visual Studio experience.

like image 65
forsvarir Avatar answered Oct 26 '22 08:10

forsvarir