6

I am getting the following warning from Code Analysis in VS2010

CA1704 : Microsoft.Naming : Correct the spelling of 'Ps' in member name 'MyClass.PsCalculatedAmount' or remove it entirely if it represents any sort of Hungarian notation.

Now in my codebase 'Ps' means 'Per Share' and is used heavily, so I would like to allow it as an acceptable word/acronym.

I tried adding it to my CustomDictionary.xml under

<Words>
    <Recognized>
        <Word>ps</Word>
...
    <Recognized>
<Words>

and also tried

<Acronyms>
    <CasingExceptions>
        <Acronym>Ps</Acronym>
    ...
    <CasingExceptions>
<Acronyms>

but I still get the warning.

Is there something I should be doing differently?

I noticed that there had been a bug in FXCop regarding this which is now fixed; http://social.msdn.microsoft.com/Forums/en/vstscode/thread/54e8793c-e821-49b2-80db-ea1420acf1e6

Is there a chance that this bug still exists in the version of Visual Studio i am using: V10.0.30319?

openshac
  • 4,966
  • 5
  • 46
  • 77

2 Answers2

6

It's being rejected because it's flagged as an unrecognized word in the "root" custom dictionary in Code Analysis installation folder (usually %ProgramFiles%\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop). You'll need to remove it from the root dictionary unrecognized list before adding it as a recognized word in a project-specific dictionary will take effect.

Nicole Calinoiu
  • 20,843
  • 2
  • 44
  • 49
4

"Ps" is also part of the <Unrecognized> section in my dictionary (and I never altered it). Apart from adding it to <Recognized> section, also remove it from the <Unrecognized> section.

<Dictionary>
  <Words>
    <Unrecognized>
<!--      <Word>ps</Word> -->
       ...more entries
    </Unrecognized>
    <Recognized>
-      <Word>ps</Word>
       ...more entries
    </Recognized>
    <!-- more stuff -->
Willem van Rumpt
  • 6,490
  • 2
  • 32
  • 44
  • Ah, I didn't see that, good spot. I have now removed it but unfortunately I am still getting the same warning? – openshac Jan 26 '11 at 12:19
  • @openshac: Strange, works for me. I'll edit the answer to reflect what my customdictionary.xml looks like. – Willem van Rumpt Jan 26 '11 at 12:22
  • I've got exactly the same in my CustomDictionary.xml as you. I even created a fresh test project but I am getting the same error. I have also tried putting "Ps" in the CasingExceptions section to no avail. However if I try creating variables like "Pi" and "Na" which are in the CasingException section then it works fine. Can't see why these are different. – openshac Jan 26 '11 at 13:20
  • @openshac: I'm at a loss. I just added it to the recognized section, and commented out the entry in the unrecognized section, and it works. On the fly dis- and enabling the entry in the unrecognized section makes the warning dis- and reappear, without restarts or anything. Will see if I can find more... – Willem van Rumpt Jan 26 '11 at 13:34
  • Ok, what version of vS are you using? And which rule set are you using I've got VS 10.0.30319 and am using the "Microsoft All Rules" rules set – openshac Jan 26 '11 at 14:08
  • @openshac: Identical: VS2010 (Premium) 10.0.30319.1, Microsoft All Rules. – Willem van Rumpt Jan 26 '11 at 14:11