在Visual Studio代码分析中使用CustomDictionary.xml为花哨的标识符

den*_*nni 3 .net c# code-analysis fxcop visual-studio-2008

例如,标识符如iPhone.当我运行代码分析时,它给了我这个错误:

CA1709:Microsoft.Naming:通过将其更改为"I"来更正名称空间名称"iPhone.Example"中的"i"的大小写.

我尝试添加一个条目CustomDictionary.xml如下:

<Words>
    <Recognized>
        <Word>iphone</Word>
    </Recognized>
</Words>
Run Code Online (Sandbox Code Playgroud)

然后它仍然给了我同样的错误和一个,如下:

CA1702:Microsoft.Naming:名称空间名称"iPhone.Example"中的复合词"iPhone"作为离散术语存在.如果您的用法是单字,请将其称为"iphone".

然后我添加了一些规则如下:

<Compound>
    <Term CompoundAlternate="IPhone">iphone</Term>
</Compound>
<DiscreteExceptions>
    <Term>iphone</Term>
</DiscreteExceptions>
<Acronyms>
    <CasingExceptions>
        <Acronym>iPhone</Acronym>
    </CasingExceptions>
</Acronyms>
Run Code Online (Sandbox Code Playgroud)

但它没有任何区别.反正有没有添加这种例外?

提前致谢.

Nic*_*oiu 9

您添加到字典中的任何内容都不会避免原始的CA1709违规,因为问题与拼写无关.相反,问题在于第一个字母缺少大写,这违反了命名空间名称的Pascal大小写约定.