I m glad to share the world with you... ...

Tuesday, May 22, 2007

How to self-define the checking rule in VS IDE?

In VSTS, you can define or add the code checking rules in FxCop. This is the to-do list.

1. Download FxCop 1.35. The URL is http://www.gotdotnet.com/team/fxcop/.

2. Install FxCop 1.35

3. Create a class lib project in VS.

4. Insert the reference: FxCopSdk, Microsoft.Cci, you can find them in both the FxCop folder and VS setup folder.

5. Let the class be inherited from base class: Introspection.BaseIntrospectionRule.

6. Override the check functions according your rules:

Check(Microsoft.Cci.Parameter)

Check(Microsoft.Cci.Member)

Check(Microsoft.Cci.TypeNode)

Check(Microsoft.Cci.Tesource)

...

7. Add and edit the rule configure file: xxxRules.xml.

8. Edit the rules with this property:

Message level: Warning Critical Warning, Error, Critical Error and Information.

Certainty: 1--99

9. Test the rule in FxCop 1.35.

10. Reinsert the reference: FxCopSdk, Microsoft.Cci, from VS setup folder, and recompile.

11. Copy the assembly to the FxCop rules folder in the VS setup folder.

12. You can use your self-defined rules in the VS IDE.

 

Be careful:

1. Do not copy the assembly to local

2. The xml file name must be end with "Rules.xml".

3. The xml should be compiled into the resources.

 

No comments: