Home > Microsoft .Net Development Tips > C# Development
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

C# DEVELOPMENT

Let Microsoft StyleCop tame your wild C#


Ed Tittel
09.10.2008
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


The SDK documentation for StyleCop 4.3 recently became available for download on the MSDN Web pages. StyleCop analyzes C# source code to enforce a set of style and consistency rules, according to author and StyleCop creator Jason Allor. He has provided a detailed discussion on "How to integrate the StyleCop tool into an MSBuild based build environment." In fact, StyleCop can be run from inside of Visual Studio or integrated into an MS Build project.

To be more specific, StyleCop is really a rules-definition and processing environment that can apply what's in its rules base to C# source code to which it is applied. To be sure, you will also find a sizable pre-defined set of rules for C# from Allor and others that are ready to be put to work, including:

›Enforce a sort order on C# directives
›Require standard summary text for constructors and destructors
›Require explicit parentheses in arithmetic and comparison expressions to add clarity
›Require String.Empty rather than using the empty "" expression
›Require explanation message text in debug asserts
›Require justification text in Code Analysis suppressions
›Enforce use of built-in type aliases for int, string, float, and so forth
›Require a blank line between elements
›Disallos blank lines at the top or bottom of documentation headers
›Disallow empty static constructors; and
›Disallow empty unsafe, lock, checked, and unchecked statements.

In addition, StyleCop provides facilities to allow developers to define and apply their own style rules, and to manage code presentation and layout. StyleCop is NOT part of the Visual Studio Code Analysis suite, and its focus is on code style and consistency rather than syntax and semantics.

The SDK documentation is where you'll find the extensibility interface for StyleCop defines, along with examples of custom rules. These documents also explain how to plug StyleCop into the processing chain for command-line based build tools of various kinds. And finally, you can download a compiled help file (.chm) that documents all the default rules built into StyleCop, to help you understand in detail what's already available, and what kinds of changes or additions you might wish to make.

Anybody who's working with C# will probably find StyleCop of at least academic interest, if not an immediate candidate for their development toolset. This goes double for those building C# constructions inside Visual Studio.

Related StyleCop Info
StyleCop SDK documentation - StyleCop SDK documentation - Code.MSDN
How to integrate the StyleCop tool into an MSBuild based build environment - MSDN

Ed Tittel is a writer and trainer whose interests include XML and development topics, along with IT Certification and information security.


Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
C# Development
Picking a .NET smart client communications technology
LINQ beyond queries: Strong-typed refection
Book excerpt: An introduction to DSL tools
Assembly versioning in the .NET Framework 2.0
Book excerpt: Creating graphical output using the .NET Compact Framework
On Extension Methods in C# and .NET Framework 3.5
Generate RSA public and private keys, export to XML
Book excerpt: Upgrading to Visual Studio 2005
Learning .NET: Tips for getting started with .NET development
Book excerpt: Code snippets in Visual Studio 2005

Visual Basic and C# development skills
Compose XML more quickly using Visual Basic 9
Virtualization keeps Legacy Apps alive
VB 9 Anonymous Types help create flexible objects
Book Excerpt: Sams Teach Yourself Visual Basic 2008 in 24 Hours -- Complete Starter Kit
Microsoft delivers Office for Mac SP1 - will bring back VBA
Visual Basic and C# development skills Research

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts