简体   繁体   English

VS2013代码分析自定义词典不起作用

[英]VS2013 Code Analysis Custom Dictionary Not Working

I'm trying to use visual studio's code analysis feature. 我正在尝试使用visual studio的代码分析功能。 Unfortunately (or fortunately?), I live in Canada and the code analysis complains about my spelling of the word "colour". 不幸的是(或幸运的是?),我住在加拿大,代码分析抱怨我的拼写“颜色”这个词。 I'm trying to use a custom dictionary but VS2013 seems to be ignoring it. 我正在尝试使用自定义词典,但VS2013似乎忽略了它。

Here's the location of the dictionary relative to the project (and solution): 这是字典相对于项目(和解决方案)的位置:

在此输入图像描述

Here's the content of the dictionary file: 这是字典文件的内容:

<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>

I've also tried culling down the content of the custom dictionary to: 我也尝试剔除自定义词典的内容:

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

Does anyone know what's going on and how I can fix this? 有谁知道发生了什么以及如何解决这个问题?

You shouldn't need to use a custom dictionary for this. 您不应该为此使用自定义词典。 Instead, if you're using Canadian spellings consistently in your code base, you can use the CodeAnalysisCulture MSBuild property to specify use of en-CA as the language in which spelling rules should operate. 相反,如果您在代码库中一致地使用加拿大拼写,则可以使用CodeAnalysisCulture MSBuild属性来指定使用en-CA作为拼写规则应该运行的语言。 eg : 例如

<CodeAnalysisCulture>en-CA</CodeAnalysisCulture>

In order for Visual Studio to recognize the custom dictionary make sure you set the build action on the XML file to CodeAnalysisDictionary . 为了使Visual Studio能够识别自定义词典,请确保将XML文件上的构建操作设置为CodeAnalysisDictionary See this page for more info: To apply a custom dictionary to a project 有关详细信息,请参阅此页面: 将自定义词典应用于项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM