views:

342

answers:

4

I ran FxCop on one of the projects that I am working on and I got a whole slew of warnings that look like the following:

CA1703 : Microsoft.Naming : In resource 'MyProject.Properties.Resources.resx', referenced by name 'MyString', correct the spelling of 'Myyyy' in string value 'Some format string: {0:dMMMyyyy}'

As Resources is a generated class, I can't simply suppress these messages using the normal mechanism. Does anyone have any bright ideas how I can get around this problem?

Edit: Just to make things clear (as I wasn't aware that this was any different with Team System), I am interested in non- Team System solutions - in particular for MS Visual Studio Pro 2008.

+1  A: 

If you don't want to have naming rules applied to resources, just turn off this rule in the project settings.

  1. Right click on the project in the project tree
  2. Click "Properties"
  3. Go to the tab "Code Analysis"
  4. Expand the branch "Naming Rules"
  5. Disable CA1703

If you just want to suppress certain resources, you can suppress them in the global suppression file. This is normally available on the right mouse key in the Error List of visual studio.

  1. Right click on the CA message(s) in the Error List
  2. Choose "Suppress Messages(s)"
  3. Choose "In Project Suppression File"
Stefan Steinegger
Could you show some examples perhaps?
jpoh
I added the steps you need to do.
Stefan Steinegger
Thanks for that. As it turns out I'm using Visual Studio Pro and not Team System so option two doesn't work so well for me. I did find this workaround though: http://geekswithblogs.net/michelotti/archive/2006/01/11/65548.aspx Do you know of any better options for Visual Studio Pro?
jpoh
+1  A: 

Instead of turning off the rule for the whole project, or manually excluding all the violations, you can turn off analysis of generated code, under:

Project > Options > Spelling & Analysis
Check Suppress analysis results against generated code
Martinho Fernandes
No, this is not the solution. It does not complain about the generated code, it complains about a resource name. There are also rules on resources.
Stefan Steinegger
You're right. That would disable *all* checks on resources. I think you're stuck with excluding the rules manually: follow Stefan's 2nd suggestion or exclude them in FxCop's project file. If this question http://stackoverflow.com/questions/353110/exclude-complete-namespace-from-fxcop-code-analysis ever gets answered correctly you could use that...
Martinho Fernandes
A: 

FxCop (stand-alone) and the integrated Code Analysis both support the use of a custom dictionary.

Create a file that is named CustomDictionary.xml. Add the following XML structure, with the new words (case insensitive) under the node.

<Dictionary>
    <Words>
        <Recognized>
               <Word>aNewWord</Word>
               <Word>AnotherNewWord</Word>
        </Recognized>
    </Words>
</Dictionary>

To use the dictionary with all projects, put the file in the FxCop install directory (usually C:\Program Files\Microsoft FxCop). For project-specific dictionaries, put the file in a separate directory together with the project file. For the words to be recognized, you must close and restart FxCop after you create or modifying the custom dictionary. You can also include the file in a Visual Studio project and set the Build Action file property to CodeAnalysisDictionary.

Scott Dorman
A: 

I ended up disabling spell-checking for resources by setting the Neutral Language of the assembly to nothing i.e. in AssemblyInfo.cs, I have this line added:

[assembly: NeutralResourcesLanguage("")]

This is as suggested here.

jpoh