Chapter 8. Managed Code Analysis and Code Metrics

WHAT'S IN THIS CHAPTER?

  • Understanding why code analysis is important

  • Enabling and running code analysis in Visual Studio 2010

  • Correcting code analysis rule violations

  • Creating a custom code analysis rule

  • Understanding code metrics and how to use them

This chapter describes the code analysis and code metric features included with Visual Studio 2010 Premium and Visual Studio 2010 Ultimate. These tools can quickly and easily inspect your code to find common mistakes, make suggestions for improvements, and even indicate violations of standards.

The discussion begins by examining the origins of the Static Code Analysis tool. You'll learn about Microsoft's .NET "Design Guidelines for Class Library Developers" and how it is related to the tools.

Then you will learn a bit about the tool itself and how to take advantage of its full integration with Visual Studio 2010. This includes enabling static code analysis review for your projects, selecting rules to apply, and working with the results of the analysis. Static code analysis is also available for database projects, but that particular use of static code analysis will not be covered in this chapter. For more information on using static code analysis with database projects, see Chapter 10.

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 learn how to use the command line ...

Get Professional Application Lifecycle Management with Visual Studio® 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.