.net - CA1704-Microsoft 似乎阻止了 'Multi' 一词?

标签 .net code-analysis fxcop casing

public class MultiSomething { } //CA1704:IdentifiersShouldBeSpelledCorrectly

当我运行代码分析时,我收到一个错误,因为 Microsoft 无法识别“Multi”这个词(去图他们在 IMultiValueConverter 中使用它)。所以,我为纠正这个问题所做的是添加一个 CodeAnalysisDictionary.xml 文件并按照提供的步骤 here .但是,似乎并没有解决问题,我仍然收到代码分析警告消息。

为了确保这不是识别词部分的错误,我添加了另一个类和另一个异常(exception)。
public class MultiSomething { } //CA1704:IdentifiersShouldBeSpelledCorrectly
public class MutiiSomething { } //NO WARNING

<Dictionary>
  <Words>
    <Recognized>
      <Word>Multi</Word> <-- This seems to not do anything... -->
      <Word>Mutii</Word> <-- This actually does something... -->
    </Recognized>
  </Words>
</Dictionary>

修复它的另一种方法是使用 SuppressMessage,但如果我打算到处使用这个词,这不是一个合适的解决方案。
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Multi")]
public class MultiSomething { } //NO WARNING (Suppressed)

Microsoft 是否真的阻止将“Multi”添加到已识别的单词中?

最佳答案

你可以引用这个feedback ticket .这显然是设计使然。

The behavior you are seeing is because Code Analysis ships with a pre-defined custom dictionary that always overrides any other custom dictionaries when there is a conflict. In this case “multi” is listed as an <unrecognized> word in the default FXCop dictionary.

To fix this issue, open the default dictionary %VS Install Directory%\Team Tools\Static Analysis Tools\FxCop\CustomDictionary.xml and comment out or remove the “multi” entry from the <unrecognized> words section; "multi" will no longer be flagged as a spelling error in Code Analysis.

关于.net - CA1704-Microsoft 似乎阻止了 'Multi' 一词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7854518/

相关文章:

.net - 如何使用 powershell 脚本在 IIS 中启动和停止应用程序池

sql - 将可为 Null 的列传递给函数会导致警告 SR0007 - 即使函数内部使用 COALESCE 和 ISNULL

c# - 如何抑制所有类型成员的代码分析消息?

entity-framework-5 - EF Code First 迁移导致 CA1701 和 CA1703

c# - 如果使用了特定的枚举值,如何生成警告

.net - 我应该总是指定使用哪个 IFormatProvider 吗?

c# - 将 .nupkg 文件检入源代码管理 - 如何在构建时恢复?

.net - WCF 随机返回无效 JSON

c# - 模拟硬件设备

code-analysis - 警告未使用的 using 语句的静态分析规则是什么?