Creating a custom rule in FxCop

2019-01-12 01:30发布

问题:

I want to create extra rules in FXCop. Custom Rules to help ensure specific best practices like checking against inline sql.

I'm really looking for good resources and examples. Thanks!

回答1:

This tutorial seems really comprehensive.



回答2:

The tutorial above is pretty good. I knocked together a sample VS project that also might be useful, since I couldn't find any example projects http://www.doogal.co.uk/files/FxCopRules.zip



回答3:

You can also use the commercial tool NDepend to write your custom code rules over LINQ queries (CQLinq). Disclaimer: I am one of the developers of the tool

More than 200 code rules are proposed by default.

The strength of CQLinq over FxCop API or other tools, is that it is straightforward to write a code rule, and get immediately results. Facilities are proposed to browse matched code elements. For example: