Code Analysis - CA1704: Correct the spelling of &#

2019-02-10 02:34发布

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?

2条回答
我命由我不由天
2楼-- · 2019-02-10 03:11

"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 -->
查看更多
疯言疯语
3楼-- · 2019-02-10 03:13

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.

查看更多
登录 后发表回答