CA1701 / 自定义词典

CA1701 / Custom Dictionary

CustomDictionary.xml 中,我应该在哪里/如何放置条目以避免 VS2015 代码分析中的这两个警告?

Warning CA1701 In resource 'xxx.yyy.Properties.Resources.resx', referenced by name 'LoggerMustSpecifyFilename' the discrete term 'Filename' in string value 'Filename must be specified.' should be expressed as a compound word. If 'Filename' refers to an API identifier, case it as 'FileName', otherwise split it into two words separated by a space.

Warning CA1701 In resource 'xxx.yyy.Properties.Resources.resx', referenced by name 'LoggerInvalidFilename' the discrete term 'filename' in string value 'The specified filename '{0}' is invalid.' should be expressed as a compound word. If 'filename' refers to an API identifier, case it as 'fileName', otherwise split it into two words separated by a space.

我不想压制CA1701,也不想改变我的字符串大小写。我使用 CustomDictionary.xml 阻止了其他一些警告,它们都工作正常,只是无法摆脱最后两个。

问题是代码分析使用它自己的 CustomDictionary,位于 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop 或同等位置。

这些不能用你自己的字典覆盖。这个问题有一个user voice

对于 Filename 特别是,这是导致您的问题的原因:

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
  <Words>
    <Unrecognized>
      <!-- .. snip .. -->      
    </Unrecognized>
    <Recognized>
      <!-- .. snip .. -->
    </Recognized>
    <Deprecated>
      <!-- .. snip .. -->
    </Deprecated>
    <Compound>
      <!-- .. snip .. -->
      <Term CompoundAlternate="FileName">filename</Term>
      <!-- .. snip .. -->
    </Compound>
    <DiscreteExceptions>
      <!-- .. snip .. -->
    </DiscreteExceptions>
  </Words>
  <Acronyms>
    <CasingExceptions>
      <!-- .. snip .. -->
    </CasingExceptions>
  </Acronyms>
</Dictionary>

(我已经从默认字典中删除了不相关的项目,还有很多)

您可以:

  1. 隐藏消息
  2. 更改您的大小写以匹配此自定义词典
  3. 编辑这个默认词典。这特别麻烦,因为您需要在所有开发人员机器和构建服务器上保持同步。