c# - VS2013 代码分析自定义字典不工作

标签 c# visual-studio-2013 code-analysis

我正在尝试使用 visual studio 的代码分析功能。不幸的是(或者幸运的是?),我住在加拿大,代码分析提示我拼写了“颜色”这个词。我正在尝试使用 custom dictionary但 VS2013 似乎忽略了它。

这是字典相对于项目(和解决方案)的位置:

enter image description here

字典文件的内容如下:

<Dictionary>
  <Words>
    <Unrecognized>
      <Word></Word>
    </Unrecognized>
    <Recognized>
      <Word>colour</Word>
    </Recognized>
    <Deprecated>
      <Term PreferredAlternate=""></Term>
    </Deprecated>
    <Compound>
      <Term CompoundAlternate=""></Term>
    </Compound>
    <DiscreteExceptions>
      <Term></Term>
    </DiscreteExceptions>
  </Words>
  <Acronyms>
    <CasingExceptions>
      <Acronym></Acronym>
    </CasingExceptions>
  </Acronyms>
</Dictionary>

我还尝试将自定义词典的内容剔除为:

<Dictionary>
  <Words>
    <Recognized>
      <Word>colour</Word>
    </Recognized>
  </Words>
</Dictionary>

有谁知道这是怎么回事,我该如何解决?

最佳答案

您不需要为此使用自定义词典。相反,如果您在代码库中始终使用加拿大拼写,则可以使用 CodeAnalysisCulture MSBuild property指定使用 en-CA 作为拼写规则运行的语言。 例如:

<CodeAnalysisCulture>en-CA</CodeAnalysisCulture>

为了让 Visual Studio 识别自定义字典,请确保将 XML 文件的构建操作设置为 CodeAnalysisDictionary。有关详细信息,请参阅此页面:To apply a custom dictionary to a project

关于c# - VS2013 代码分析自定义字典不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23146029/

相关文章:

c# - 代码分析和 SupressMessage - 是否应该用 #if DEBUG 包装属性

c# - 为什么 "Analyze designer files"是 StyleCop 的默认值?

c# - 使用 C# 将连续的结构化数据写入二进制文件

c# - 获取仍在编辑的 Excel 单元格的值

c# - 如果配置在字符串中,是否使用 new ChannelFactory<TChannel>(string)?

c# - 在多个连接的情况下是延迟加载、急切加载还是显式加载?

c++ - 如何在 ASM 中创建循环?

asp.net-mvc - app.UseOAuthBearerTokens 与 ASP.NET Identity 2.0 的 DbContext 中间件?

c# - dirs.proj 是如何使用的?

c# - C# 的 Lint