A Brief Introduction to FxCop


Visual Studio 2005 introduces Team System, which is a suite of tools aimed at project managers, architects, developers, and testers, and is designed to help manage the increasingly complex Software Development Life Cycle. Team System is available in several editions, each aimed at a different role in the development process. Team Edition for Architects is aimed at architects and project managers, Team Edition for Software Developers is aimed at developers, and Team Edition for Software Testers is aimed at testers. Of particular interest to us in this chapter is Team Edition for Software Developers, which supports static analysis performed by FxCop.

FxCop has three interfaces: a GUI built into Visual Studio 2005, a stand-alone GUI (FxCop.exe), and a command-line interface (FxCopCmd.exe). This section looks at the support built into Visual Studio 2005. To follow along, create a new Windows Forms application. By default, static analysis is not included in the build process. To enable FxCop, select the project's Properties Window, select the Code Analysis tab on the left side, and check the Enable FxCop check box (see Figure 13.1).

Figure 13.1. Enabling FxCop Code Analysis in Visual Studio 2005


You can also see a list of FxCop's built-in rules in this tab. One of these that should immediately catch your eye is "Globalization Rules." As you will see later, you can add new rule assemblies to this list. To see FxCop in action, add the following enum to the Form1 class:

 public enum CheeseEnum     {SmokedAustrian, JapaneseSageDerby, VenezuelanBeaverCheese}; 


This enum represents a deliberate naming error; the enum name is suffixed with "Enum", which is contrary to Microsoft's recommended naming guidelines. When Code Analysis is enabled, FxCop is included in the build process. When you build the application, FxCop reports its errors to the Output Window just like compiler errors (see Figure 13.2).

Figure 13.2. FxCop Errors in Visual Studio 2005's Output Window


The fourth item in the list is "Rename 'WindowsApplication1.Form1+ CheeseEnum' so that it does not end in 'Enum'." When you correct the problem and rebuild the application, the error will no longer be reported.




.NET Internationalization(c) The Developer's Guide to Building Global Windows and Web Applications
.NET Internationalization: The Developers Guide to Building Global Windows and Web Applications
ISBN: 0321341384
EAN: 2147483647
Year: 2006
Pages: 213

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net