FxCop rules can be debugged using the debugger that is built in to Visual Studio. The key to debugging rules is to understand that you need to run the FxCop GUI application in the debugger since that application in turn loads your rules assembly. There are two basic ways to perform the debugging: by attaching to a running FxCop executable or by starting FxCop directly from your Visual Studio project.
To attach to a running FxCop executable,
start FxCop normally. Next, ensure that your
rules project is open in Visual Studio. Click
the , menu item. Highlight the
FxCop.exe process and click
. Now, perform an analysis using
FxCop. Any breakpoints that you have set in
your code will step into the debugger as they are encountered.
Alternatively, you can configure your rules class library project to
start FxCop for debugging whenever you use
Visual Studio to run your project (for example,
by clicking the toolbar button or pressing the
F5 key.) Click the ,
menu item. Go to
the page. Choose Start external
program and enter the path and filename for the
FxCop program, such as
Files\Microsoft FxCop 1.36\FxCop.exe.
To make debugging more convenient, consider developing an FxCop project that uses your rules assembly. Then, set Command line arguments in the page to the path and filename of this project. FxCop will automatically open this project when it is launched, saving you from having to perform basic setup tasks in FxCop every time you run it under the debugger.