如何让 FxCop 自定义词典工作? [英] How to get the FxCop custom dictionary to work?

查看:29
本文介绍了如何让 FxCop 自定义词典工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让 FxCop 自定义字典正常工作?

How is it possible to get the FxCop custom dictionary to work correctly?

我尝试将要识别的单词添加到文件CustomDictionary.xml"中,该文件与 FxCop 项目文件保存在同一文件夹中.这似乎不起作用,因为即使在重新加载并重新运行 FxCop 之后,我仍然会收到标识符应拼写正确"的 FxCop 消息.使用 1.36 版.

I have tried adding words to be recognised to the file 'CustomDictionary.xml', which is kept in the same folder as the FxCop project file. This does not seem to work, as I still get the 'Identifiers should be spelled correctly' FxCop message, even after reloading and re-running FxCop. Using version 1.36.

推荐答案

如果在 Visual Studio 中使用...

If you use it inside Visual Studio...

来自 Visual Studio 代码分析团队博客

将自定义字典添加到 C# 和Visual Basic 项目很简单:

To add a custom dictionary to a C# and Visual Basic project is simple:

  1. 在解决方案资源管理器中,右键单击项目并选择添加 -> 新建项目...
  2. 在模板下,选择 XML 文件,输入字典的名称,例如作为 CodeAnalysisDictionary.xml 和点击添加
  3. 在解决方案资源管理器中,右键单击 XML 文件并选择属性
  4. 在属性"工具窗口中,在构建操作"下选择代码分析字典
  5. 在解决方案资源管理器中,双击新创建的字典以打开它
  6. 在 XML 编辑器中,粘贴以下内容,替换产品名称"和公司名称"与您的团队的等价物:

  1. In Solution Explorer, right-click on the project and choose Add -> New Item...
  2. Under Templates, select XML File, enter a name for the dictionary, such as CodeAnalysisDictionary.xml and click Add
  3. In Solution Explorer, right-click on the XML file and choose Properties
  4. In the Properties tool window, under Build Action choose CodeAnalysisDictionary
  5. In Solution Explorer, double-click on the newly created dictionary to open it
  6. In the XML editor, paste the following, replacing "productname" and "companyname" with your team's equivalents:

<Dictionary>
     <Words>
        <Recognized>
            <Word>"productname"</Word>
            <Word>"companyname"</Word>
        </Recognized>
    </Words>
</Dictionary>

您现在可以开始输入了您自己的自定义词.只需添加一个中每个单词的新元素您的项目中不存在词典.每个字都是不区分大小写,因此任何大小写词将被识别.代码分析会自动拿起自定义字典下次运行时.

You are now ready to start entering your own custom words. Simply add a new element for each word in your project that does not exist in the dictionary. Each word is case-insensitive, so any casing of the word will be recognized. Code Analysis will automatically pick up the custom dictionary the next time it is run.

这篇关于如何让 FxCop 自定义词典工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆