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/