简体   繁体   中英

Run code analysis rule set with FxCop 10 GUI

I'm using code analysis in .NET 4, where I have a custom rule set included in the project file for my project.

I would like to run FxCop 10 GUI on the project output, using the same rules as in the custom rule set.

Is this possible with FxCop GUI (FxCop.exe)?

The FxCop 10 GUI application does not include any support for rulesets. The closest you could get with the GUI app would probably be to automate generating the contents of the Rules node of a.fxcop project file from a ruleset before loading the project in FxCop. If you decide to do this, there are APIs in the FxCop/Code Analysis assemblies that could help a bit (eg: Microsoft.VisualStudio.CodeAnalysis.RuleSets.RuleSet.LoadFromFile).

I had the same problem and although FXCop does not support rulesets you can use an undocumented commandline switch from the FXCopCmd.exe. Simply define the /rid switch for the messages you want to suppress. This switch can occure multiple times. eg:

"$(ProgramFiles)\Microsoft FxCop 10.0\FxCopCmd.exe" /console /file:"$(TargetPath)" /rid:-Microsoft.Design#CA1005 /rid:-Microsoft.Design#CA1020 

in the post build event of your VS 2008 project.

Hth Uli

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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