In this chapter and the next, we describe the code analysis features included with Visual Studio Team System. These tools can quickly and easily inspect your code to find common mistakes, suggestions for improvements, and even violations of standards.
In this chapter, we'll focus on analyzing managed code, such as C# and VB.NET. If you're working with C or unmanaged C++, turn to Chapter 9, where you will learn how to analyze native code.
We begin by discussing the origins of the Static Code Analysis tool. We'll introduce Microsoft's .NET Design Guidelines for Class Library Developers and describe how it is related to the tools.
Then we will describe the tool itself and how to take advantage of its full integration with Team System. This includes enabling Static Code Analysis review for your projects, selecting rules to apply, and working with the results of the analysis.
However, using the IDE is not always an option and sometimes you need additional flexibility. The Static Code Analysis tool is available to you from the command line. You will also learn how to use the command line for code analysis and how to include code analysis with your automated builds.
The Static Code Analysis rules that ship with Team System will probably not be sufficient for the specific standards and practices of your own projects. To address this, we will also describe how you can create and integrate new custom rules. We begin by describing the mechanics of rules, introducing the new Introspection engine. You will then create an example rule using introspection and call it from the Visual Studio IDE.