Wednesday, September 23, 2009

FxCop

FxCop is a great free tool for static code analysis, which checks managed code assemblies for compliance with .NET Framework Design Guidelines. FxCop is available both as GUI and a command line tool, so it can be easily used in build process. Certain messages can be excluded from future reports if you can intentionally avoid rules. New custom rules can be created using FxCop SDK.

If you recently updated Windows SDK to version 7, the FxCop installation file can be found in the Windows SDK v7.0/Tools/ directory.

To use GUI version of FxCop just start the application, add targets i.e. assembly or assemblies which you want to check and click Analyze button. After a while, depending on the assembly size, you will get the report.


Every message should be reviewed and one of the following actions should be taken

  • If there is a code defect - fix the code
  • If rule broken intentionally – exclude message
  • If message generated is false– exclude message

After you fix the code for all other messages rebuild the assembly and analyze the code again.

FxCop is great tool for all .NET developers, especially for these who are not familiar with .NET Framework Design Guidelines. FxCop can help you write robust and easily maintainable .NET Framework code.

No comments: