FxCop is a static analysis tool that you can use to write custom rules those need to be followed by the developers. Writing custom rules in FxCop is very easy, in the beginning you will feel it bit complex since there are no much help available on web but once if you have written a rule you will be preety much confident that you can write any rule you desire.
SInce FxCop analyses IL code from your assemblies, we should know about some of the keywords of IL to write complex rules. Use this sheet as a reference while seeing your IL code through ILDASM.
I have created a template project for Custom FxCop Rules for you which you can use and add your rules. So that you can concentrate more on Custom Rules rather than creating the project.
Download CustomFxCopRules template
If you want to add any new rule you have to follow these steps using the above template.
- Create a class and name it with the rule.
- Create a new node of that of the classname (not necessary but only for easier reference) in CustomRules.xml with desired settings
- Create a constant with the same name and value in Constants.resx file
- Write your logic in that class
And to debug the rules that you have written here is a post
http://social.msdn.microsoft.com/forums/en-US/vstscode/thread/b92a0416-bf20-40c1-88a0-8fcff07133dc/
More References:
http://www.binarycoder.net/fxcop/pdf/fxcop.pdfhttp://www.binarycoder.net/fxcop/pdf/fxcop.pdf
http://www.nmentor.com/Blog/Tutorials/1.%20How%20to%20Write%20Custom%20FxCop%20Rule.pdf
I will put some of the custom rules in coming post which willl cover all the required topics to make you understand FxCop better. If you want any specific rule, then feel free to post a comment to me and I will help you out
Happy Learning
Codingsense