
Follow the Rules with FxCop #65
Chapter 7, Help and Research
|
255
HACK
Create an FxCop Project
To use FxCop (assuming you’ve already downloaded and installed it), you’ll
first need to create a project in Visual Studio and compile that project; in
this case, I’ve created a class library project named MathLibrary. You can
create an FxCop Project by following these steps:
1. Start an instance of FxCop.
2. Click File
➝ Project ➝ Add Targets (Ctrl-Shift-A).
3. Browse to your .NET assembly, select it, and click Open. You’ll now see
your assembly listed under the Targets tab.
4. Click File
➝ Save Project (Ctrl-S).
5. In the Save As dialog box, type a name for your FxCop Project, select a
location, and click Save. Note that all FxCop Project files are saved with
an .fxcop extension; however, these are just XML files that contain all
the information needed for your project.
Analyze Your Assemblies
Now that you’ve created and saved an FxCop Project, you can use it to ana-
lyze your .NET assemblies for code and design conformance. To do this,
click Project
➝ Analyze (or press the F5 key).
Once FxCop has completed its analysis, you’ll more than likely see several
messages appear in the righthand pane of the tool, as shown in Figure 7-27.
There are a couple things to take note of in Figure 7-27. First, you can see
that FxCop assigns a certainty to each message. For instance, FxCop is 95%
certain that the class
SimpleMath ...