Terje Sandstrom

------ Visual Studio ALM MVP ----- (also see new blog at http://hermit.no)

  Home  |   Contact  |   Syndication    |   Login
  64 Posts | 1 Stories | 116 Comments | 0 Trackbacks

News

Subscribe

Delicious Save this on Delicious Visual Studio Feeds

¨

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Company stuff

Interesting bloggers

Interesting companies

Microsoft

Microsoft Norge

Microsoft Regional Directors

Microsoft Test

MSFT Blogs

MVP

NNUG

Other interesting stuff

TFS

Visual Studio

In Visual Studio the settings for static analysis is done on the project property page, a tab called Code Analysis. You can set which code analysis rules you want to be active.  The default in Visual Studio 2008 is to use all.   If you run with this default setting you will generate a lot of "noise", since there are a large set of rules.  You need to create a set containing the rules you and your team find are suitable for your organization and project.  This set you have to apply to every C# project in your solution.  In Visual Studio 2008 there is no easy way to do this.  At Osiris we made an Addin to Visual Studio to ease this.  We defined the set in a separate file, and used the Addin to apply that to all projects in a solution.

With Visual Studio 2010 this will be more easy, because in 2010 you can define sets of rules.  It comes with a default list of sets.   You can also define your own sets, based on any of the others.

Code Analysis page

 

To make your own rule set, just open any of the default ones, make any changes you like to it, and save it under a suitable name.  A rule set file is created, which can be checked in together with the other files of the project.  This file [rule set] can now be used by any other project you have.  So you only need to define it once.

 

image

You still have to select it for all the projects in the solution, but this has been made easier by having solution properties, where Code Analysis is one of these setting pages:

image

It's then easy to select the rule set you want for all projects within your solution.

posted on Sunday, July 12, 2009 11:41 AM

Feedback

# re: Team System 2010: Static Code Analysis, easier to set rules 2/15/2010 10:52 PM Raj Aththanayake
Nice blog. You say "To make your own rule set, just open any of the default ones, make any changes you like to it, and save it under a suitable name". Why we need to do that. Can't we create a one from the scratch?

# re: Team System 2010: Static Code Analysis, easier to set rules 2/16/2010 6:34 PM Terje
Thanks !
Not built in, but you can easily make that yourself. Make a new rule set containing no rules, save this as BlankRuleSet, and then use this. One little tip: Make sure you check the button named "ShowRules that are not enabled", it's disebaled by default.

# re: Team System 2010: Static Code Analysis, easier to set rules 5/4/2010 6:40 AM Boiler Review
Hey, does this run on mac too? Thanks!

# re: Team System 2010: Static Code Analysis, easier to set rules 5/4/2010 7:08 AM Terje
To run VS on Mac you need to run it in a VM. See the following articles : http://weblogs.asp.net/latishsehgal/archive/2009/08/15/working-with-visual-studio-on-a-mac.aspx and http://aspadvice.com/blogs/rbirkby/archive/2006/07/16/19704.aspx

Post A Comment
Title:
Name:
Email:
Comment:
Verification: