views:

181

answers:

1

Ok, another FxCop question for today.

I've read the arguments regarding the IdentifiersShouldBeCasedCorrectly rule, and whether or not it should be "XML" or "Xml". Well, I'm an "XML" guy and I want to stay that way. Therefore, I do not want FxCop to correct me all of the time.

I have been using the SuppressMessage attribute only for specific cases. I have also used FxCop to mark a ton of errors and copied them as "module" level SuppressMessage statements into assemblyinfo.cs. That works pretty well.

However, now I really want to globally disable this annoying IdentifiersShouldBeCasedCorrectly rule. I'm using TeamCity 5.0.3, and am not using an FxCop project file (however, I could do this). I was hoping that I could pass a parameter to FxCopCmd to tell it to ignore this error, but it doesn't look that way from the documentation.

So... is there anything I can do short of creating an FxCop project file on the TeamCity build server and using it for the FxCop build runner?

A: 

Look in the install directory of FxCop (mine is c:/program files/microsoft fxcop 1.36). There should be a CustomDictionary.xml file in that directory. You can add XML to the CasingExceptions section at the end of CustomDictionary.xml and XML casing will be ignored for all namespace and function name elements of all projects on that machine (unless CustomDictionary.xml is overridden on the command line, of course).

You can also copy CustomDictionary.xml to the project directory and add XML in the CasingExceptions secion of the project directory copy. I think that this will be found automatically, with no need of an FxCop project file and will only be used for that project.

That's what I did for our TeamCity build, but I needed an FxCop project file for another reason, so I cannot remember (and cannot check) if CustomDictionary.xml will be found automatically by FxCop.

Example:

  <Acronyms>
<CasingExceptions>
  <Acronym>Pi</Acronym>
  <Acronym>Na</Acronym>   <!-- NaN -->
  <Acronym>NESW</Acronym> <!-- North East South West -->
  <Acronym>NWSE</Acronym> <!-- North West South East -->
  <Acronym>XML</Acronym> <!-- XML -->
</CasingExceptions>

There is also a slightly different example of ignoring words at MSDN FxCop FAQ Hope this helps!

james
I've been using the FxCop customdictionary.xml file strictly for adding words that FxCop complained were misspelled, like "num" (something I like to use in my variable names). Can you please edit your answer and post a sample of exactly what you had added to your XML file to ignore casing?
Dave
ah, I see what you're referring to... I hadn't noticed that section earlier. But instead of adding every acronym, I want to globally disable the error itself, because the way I typecase words is a matter of style, and there's no telling how many more I'd have to add over time. I was hoping that I could export the error suppression from FxCop as XML and then paste it into customdictionary.xml, but what I find interesting is that I can't overwrite the file. I'll have to see if it's a Win7 permissions issue.
Dave
copying as XML from FxCop into customdictionary.xml didn't work... it was worth a shot. :)
Dave
Adding XML to the CasingExceptions area at the end of CustomDictionary.xml removed casing exceptions for namespace elements and function names. It doesn't remove them for parameter names, however. I'm still working on that one.
james
@james: I haven't worked on FxCopy/TeamCity in a while -- have you had any luck figuring out how to deal with the casing exceptions globally?
Dave
Sorry, no. I worked on it for a few hours and then I got interrupted and never got back to it. I do remember that I didn't really get anywhere...
james