FxCop – Part I (Introduction)
It is a code analysis tool which analyzes the code and gives suggestions to improve coding.
It analyzes programming elements in targets, and provides an informational report that contains messages about the targets;
It can analyze either a dll or an exe.
They are nothing but managed assemblies.
Messages include suggestions about how to improve the source code used to generate them.
A rule is a code which analyses and finds defects and informs about it.
For analysis 2 things are required,
1. Target assemblies
· From GUI
After installation, you will have shortcut in Programs menu; you can start FxCop by clicking the link.
· Command Line
You can run FxCop.exe with respective command line arguments to start it from command line.
Using FxCop you can do the following:
· Manage Rules (decide which rules need to be applied to which assembly)
· Apply Styles to Reports.
· Filter and save messages.
· And also you can save and reuse application settings.
Similar Code Analysis tools:
StyleCop is another tool which does code analysis.
Difference between FxCop and StyleCop:
FxCop does code analysis over the binaries, whereas StyleCop does code analysis over the source code itself.
FxCop : ver. 1.36
StyleCop : ver. 188.8.131.52
Steps to do an analysis:
1. Run FxCop.
2. File > New Project.
3. Project > Add Targets.
4. Select the desired assembly you want to analyze(it can either be a dll or an exe).
5. If you have selected multiple assemblies then select any one of them ( the one you want to analyze first) and then click Project > Analyze or press F5.
6. Then it will display list of messages in the right pane.