简体   繁体   English

使用现有Fxcop规则整合自定义Fxcop规则

[英]Inetgrating custom Fxcop rule with existing Fxcop rule

I have developed some Fxcop custom rule and I want to create seperate project just like 'Design Rules','Globalization Rules' etc which will contain custom rule which was designed by me and some selected existing Miscrosoft Fxcop Rules. 我已经开发了一些Fxcop自定义规则,我想创建一个单独的项目,例如“设计规则”,“全球化规则”等,其中将包含我设计的自定义规则以及一些现有的Miscrosoft Fxcop规则。 I want to know whether it is possible to do so. 我想知道是否可以这样做。 If possible ,How ? 如果可能,如何?

You would have to place the custom rule dll-file in your correct FxCop-rulelocation: 您必须将custom rule dll-file放置在正确的FxCop-rulelocation中:

This can be C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Team Tools\\Static Analysis Tools\\FxCop\\Rules for example. 例如,这可以是C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Team Tools\\Static Analysis Tools\\FxCop\\Rules Find your location and place it in there. 找到您的位置并将其放在那里。

What you want to do next is create a Code Analysis Ruleset . 接下来要做的是创建一个Code Analysis Ruleset

There is a Microsoft tutorial on creating Code Analysis Rulesets here . 有关于创建代码分析规则集微软的教程在这里

To open an empty rule set file in the rule set editor On the File menu of Visual Studio, point to New and then click File. 在规则集编辑器中打开空规则集文件的步骤在Visual Studio的“文件”菜单上,指向“新建”,然后单击“文件”。 In the New File dialog box, click General in the Installed Templates list, and then select Code Analysis Rule Set. 在“新建文件”对话框中,在“已安装的模板”列表中单击“常规”,然后选择“代码分析规则集”。 The rule set editor appears. 出现规则集编辑器。 No rules are selected in the editor list. 在编辑器列表中未选择任何规则。

What you see next is the Rule Set Editor . 接下来,您将看到“ Rule Set Editor Here you can select existing rules and also your own, custommade rules. 在这里,您可以选择现有规则,也可以选择自己的定制规则。

Working with the ruleset editor is explained here . 这里说明与规则集编辑器一起使用的过程。

There is a step-by-step guide available at http://blogs.msdn.com/b/codeanalysis/archive/2010/03/26/how-to-write-custom-static-code-analysis-rules-and-integrate-them-into-visual-studio-2010.aspx for authoring rules and adding them to .ruleset files. http://blogs.msdn.com/b/codeanalysis/archive/2010/03/26/how-to-write-custom-static-code-analysis-rules-and上有分步指南-将其集成到visual-studio-2010.aspx中以编写规则并将其添加到.ruleset文件。 To figure out where the problem is originating, it would be best to follow all the recommended steps, including verifying that the rule can be executed by the fxcopcmd.exe command line tool. 为了弄清楚问题的fxcopcmd.exe ,最好遵循所有建议的步骤,包括验证该规则可以由fxcopcmd.exe命令行工具执行。

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

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