Game Development Reference
On top of Reflection, the latest version of FxCop has exposed another method of
analyzing your assemblies using an introspection engine. This engine provides a
rich set of analysis functionality and can analyze large applications much more
quickly than the regular reflection-based engine. On top of speed, the introspection
engine also supports multithreaded application analysis. Lastly, the introspection
engine is different from the reflection engine in that it does not lock assemblies
when it performs analysis, allowing you to fix and recompile assemblies while
FxCop remains open instead of shutting down FxCop to release locked assemblies.
The purpose of this chapter is to introduce you to the wonderful world of enforced
coding policies, and the tool that makes it all possible. After reading this chapter,
you should be able to analyze your code for convention violations, design custom
violation rules, and know how to configure FxCop to suit your development pref-
The engine and SDK specification for FxCop have not yet been finalized, so the common pattern is that
each release breaks backward compatibility with existing plug-ins, forcing the developer to update
the custom rules to reflect API changes. This chapter was written using FxCop 1.32 for Whidbey
Beta 2 (.NET 2.0 Beta 2). I still felt that the information presented in this chapter is important, so I
decided to keep this chapter in the topic and present this little warning about the changing API. Hope-
fully the next release version of FxCop supports an easy migration path from the 1.32 API.
This is just a warning that you may not be able to compile the examples in this chapter straight out
of the topic; you may need to update the examples to reflect the latest API specification. With this
in mind, let's continue on to discovering what FxCop is, and how you and your code can benefit
from its use.
The first thing you need to do is install the FxCop tool; you can get the installer at the companion
Web site for this topic, or from http://www.gotdotnet.com/team/fxcop/.
There are no custom configuration options, so the installation itself is very simple.
FxCop can be accessed from either a WinForms applications or the command line
using the FxCopCMD application. You can actually integrate FxCop analysis into
your build process, which is a great idea because you can fix conformance viola-
tions as they occur, instead of letting them build up into a huge list that you have
to cull through at a later time. If you want to get as much speed as possible during