advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the FxCop custom rule example.
Partners & Affiliates
advertisement
advertisement
Rate this item | 0 users have rated this item.
 Print Print
 
Monitor .NET Code Quality with FxCop and Custom Rules
You no longer have to rely solely on experience and code reviews to find code problems; FxCop can find many problems for you. It even lets you create and enforce custom rules that apply specifically to your organization's code. 

advertisement
XCop is a free code analysis tool (open source) from Microsoft that analyzes managed .NET assemblies. .NET assemblies contain metadata entries that describe the assembly and all its contained types. FXCop works by reading the assembly metadata and checking it for compliance against built-in and custom rules that describe recommended coding standards and practices.


After analyzing the assemblies, FxCop reports any rules violations in the areas of localization, performance, and security. It checks code against a set of rules and messages stored in an embedded xml file, displaying appropriate messages at runtime when rules violations occur. You can extend the built-in rules with custom rules that you create. This article discusses how to use FxCop, and how to create and apply such custom rules.

To implement the techniques discussed in the article, you'll need: FxCop Version 1.32, the .NET framework version 1.1 or higher installed, and Windows XP/2000 or a later OS.

What is FxCop?
FxCop, an abbreviation for "Framework Police," is a rules-based engine that checks managed code assemblies for conformance to Microsoft's .NET Framework design guidelines and custom guidelines. It performs tests on the assemblies by parsing the MSIL they contain, inspecting and reporting on code that fails to meet the rules. Because FxCop performs the tests on managed assemblies and not the source code, it's .NET-language neutral; in other words, you can apply it to any assembly created using any language that target the Microsoft.NET managed environment.

Why Use FxCop?
FxCop provides some immediate advantages, particularly for shops that use more than one .NET language.

  • It works with any managed assembly created by any .NET-compliant language that runs on the Microsoft.NET framework.
  • It has an extensive set of pre-defined rules.
  • It has support for creating custom rules.
  • It produces well-formatted XML test reports.
  • It's an open source tool, so you can extend or alter it as needed.
Still, at its current stage of maturity, FxCop does have some limitations:

  • It works only with assembly metadata, not source, so it can't be as specific as source code analysis tools.
  • It follows a flat rules structure that makes implementing large sets of policies tougher.
  • It does not support custom report types.
How to get FxCop?
FxCop was developed by Microsoft. It's available as a free download.

If you have problems or questions you can post messages to the FxCop team or to the MSDN forums.

  Next Page: Some Important FxCop Terminology


Page 1: IntroductionPage 3: Creating Custom Rules in FxCop
Page 2: Some Important FxCop Terminology 
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES