Part II (A startup lesson on using FxCop)
In the previous article (FxCop Part I – Introduction), we saw the basics of FxCop
, its definition, download path, comparison with other Code analysis tools, a
simple demo for doing a analysis,etc.
In this article (Part II -A startup lesson on using FxCop), we are going to see the
usage of FxCop at a beginner’s level.
As we saw in the previous article two things are required for doing any analysis
in FxCop, they are:
· Assembly ( either a .exe or .dll)
A brief explanation about the windows and menus in FxCop
Run FxCop by clicking , Start > All Programs > Microsoft FxCop > Microsoft
After the FxCop window was opened,
Click File > New Project.
The following Figure 1.0 shows the FxCop tool,
Panes in FxCop
There are 3 panes in the tool, they are:
· Main Pane
· Messages Pane
· Output Pane
Figure 1.1 shows the Main Pane,
It will have 2 tabs in it, they are
These two tabs serve the respective purpose of showing and managing targets and Rules
in the current project.
This Pane shows the messages that are generated by the FxCop tool after doing the
Code analysis and it will be of various categories.
Figure 1.2 shows the Messages pane.
It will have 4 tabs in it they are,
· Exclude in Project
· Exclude in Source
The usage of these we will see in the later articles.
This will show the properties in code format when an item is clicked on the Main
Figure 1.3 shows the Output Pane,
For the initial level, it is enough to know about the 3 menus in the tool. They are
1. File > New Project
It is used to create a new project.
2. Project > Add Targets
It is used to add assemblies from the Project on which you want to do the analysis.
3. Project > Analyze
To start the analysis, you need to click this or press F5 or click Analyze button
on the toolbar.
A simple analysis:
1. Run FxCop.
Start > All Programs > Microsoft FxCop > Microsoft FxCop 1.36
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).
For example, I am selecting here a .net application (Which was downloaded from internet)
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 or Click
Analyze from toolbar.
6. Analyzing with introspection Engine dialog box will appear when the analysis is under
7. Then it will display list of messages in the right pane.
The resultant window is what is shown in the Figure 1.0. The messages shown will
be of the following categories, they are:
· Critical error
This means that it is an major issue and need to be corrected.
This means it’s just a warning and not that much serious, but if corrected the it
will be good.
More details about the messages:
Double click on the respective message, then Message Details window will appear,
which gives a detailed explanation about the message along with other options.
That window will have 5 tabs in it which elaborates about he message and its dependencies.
Figure 2.0 shows the Message Details window,
Stopping the Analysis
Click the Cancel button on the Analyzing with introspection Engine dialog box to
cancel the Analysis in the middle.
Viewing a summary of the Analysis
Click Project > Analysis Summary, it will display a summary of the analysis done.
Figure 2.1 shows the Analysis Summary window,
Saving the Project
After the analysis is over , save the project before saving the Message XML file
otherwise it will throw an error.
Moreover save the Project file in the same directory of the Assembly for which the
code analysis is done.
To save the project click,
File > Save Project.
Saving the Report
After saving the Project file, you a save the report file wherever you want.
To save the Report click,
File > Save Report
This might have given a basic idea about the usage and components of FxCop. We shall
see more in the coming Chapters.