Datasheet

Useful Features of Visual Studio 2010
63
In fact, the tool doesn t actually look at your source code. Instead, it uses re ection; and once your project
has been compiled, it queries the MSIL code your project generates. While this may seem surprising,
remember that this tool is looking for several best practices, which may be implemented in different ways in
your source code but will always compile in a standard manner.
Figure 1 - 43 shows the optional Code Analysis screen. Note that even when you have the code analysis tools
available, by default, they are not enabled for your project. This is because enabling code analysis signifi cantly
extends your compile time. In most cases you ll want to enable these settings for a build or two, and then
disable the checks for most of your debug builds. As you can see, to enable analysis you merely check the
Enable Code Analysis on Build check box.
Below this check box is a check box to suppress results from generated code. One of the code analysis issues for
which Microsoft was criticized after the Visual Studio 2005 release was that if you used the standard project
template to create your project and then ran Code Analysis, you would get warnings related to the generated
code. Microsoft s solution was to enable you to automatically bypass checking their generated code, which
at least enables you to avoid having to manually mark all of the issues related to the generated code as being
suppressed.
Once you have enabled the code analysis checks, you also have the option to defi ne exactly which rules
you want to apply. The checks are divided into different rule sets. Selecting a rule set such as the Microsoft
Minimum Recommended Rules, you can use the Open button to access the display shown in Figure 1 - 44.
FIGURE 1 - 43
CH001.indd 63CH001.indd 63 4/5/10 11:57:12 AM4/5/10 11:57:12 AM