4

I have the following Code Analysis error:

enter image description here

Which says:

CA1704 Correct the spelling of 'Img' in member name 'Default.ImgLogo' or remove it entirely if it represents any sort of Hungarian notation.

I have this in my Code Analysis dictionary:

<Word>Img</Word><!-- asp.net image -->

As per this it is because it's in the global unrecognised list in the dictionary in \Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop

Is there away around having to manually do this on each Developer PC and Build Agent?
Beyond not using Img, of course.

This is with Visual Studio 2015, TFS 2015

Ohad Schneider
  • 36,600
  • 15
  • 168
  • 198
NikolaiDante
  • 18,469
  • 14
  • 77
  • 117

2 Answers2

1

There is no easy way to do this. Really the simplest way is probably to use a "true word" and expand DefaultImg to DefaultImage.

The only way I can think of is to place the Code Analysis tools themselves under source control and then override the CodeAnalysisPath variable when calling MsBuild. You can set this path in the system/user environment or pass it to MsBuild as a commandline parameter.

In this source controlled directory you can override the default dictionary.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
1

Apologies if I'm stating the obvious, but you could also just suppress it in code:

using System.Diagnostics.CodeAnalysis;

[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Img")]
public const string ImgLogo= "logo";
Ohad Schneider
  • 36,600
  • 15
  • 168
  • 198