Welcome to MSDN Blogs Sign in | Join | Help

View This Blog In

Code Analysis Features in VS 2008

In Visual Studio 2005, we integrated a couple of internal static analysis tools - FxCop and PREfast into the product under the names Managed Code Analysis and C/C++ Code Analysis.  This helped customers write secure and quality code for managed and native platforms using the same tools that we had been using internally for years.  This is part of our philosophy of "ship what we use and use what we ship".

For Visual Studio 2008, the Code Analysis team has added some new features that I wanted to talk about today.

Code Metrics - This is a new tool window that allows you to not only get an overall view of the health (code-wise) of your application, but also gives you the ability to dig deep to find those un-maintainable and complex hotspots.  For Visual Studio 2008, Code Metrics will ship with five metrics - Cyclomatic Complexity, Depth of Inheritance, Class Coupling, Lines of Code and Maintainability Index.  The Code Analysis team has a couple of posts describing the new feature, here and here.

Code Analysis Policy improvements - Code Analysis Policy provides the ability to ensure that Code Analysis is run before every check-in.  Based on feedback from customers, the team made a few usability improvements, including better guidance and providing more control over how settings are applied from the policy to projects.

Analysis improvements - A number of improvements were made around analysis:

-          Support for analyzing anonymous methods and lambda expressions

-          Reduced noise in existing analysis and the ability to skip over tool generated code

-          New analysis, including additional rules around security, globalization, maintainability and spelling (including custom dictionary support)

-          Better support for C++/CLI and the Compact Framework

-          Performance improvements that cut analysis time over managed code by 2x, and used half as much memory than in Visual Studio 2005.

Better suppression support - Code Analysis supports suppressing an instance of a warning by right-clicking on it in the Error List and choosing Suppress Message.  This support has been extended for Visual Studio 2008, giving more control over whether a suppression applied in-source or in a separate project suppression file.  The underlying suppression format has also changed to support generic methods, C++ boxed value types and special type modifiers, such as C++s const.

Namaste!

 

Posted: Thursday, October 04, 2007 4:48 PM by Somasegar

Comments

Jason Haley said:

# October 5, 2007 10:13 AM

Steve said:

You should clarify that code analysis is only available for the Team System versions of 2005 (and 2008 I presume?).  

It's unfortunate that Code Analysis/FxCop features are no longer available to the many developers who want to deliver the highest quality code, but don't have the budget for team system.

# October 5, 2007 12:37 PM

Mike Glass said:

Microsoft has provided FxCop to the development community via the website GotDotNet. We are in the process of moving FxCop to MSDN.com where we will continue to make it available to the developers. I expect FxCop to reappear on MSDN in the tools section within two weeks. FxCop is also in the Windows SDK.

# October 5, 2007 1:55 PM

Jeff Beehler's Blog said:

Soma's writing a series of blog posts on VS2008 features in anticipation of our coming release. As part

# October 5, 2007 2:42 PM

Noticias externas said:

Soma's writing a series of blog posts on VS2008 features in anticipation of our coming release. As

# October 5, 2007 2:55 PM

Denis Pasechnik said:

Достаточно интересный обзор с линками и коментариями касающийся следующих аспектов: Code Metrics Code

# October 5, 2007 3:40 PM

Barry Gervin's Software Architecture Perspectives said:

via Soma Back in the days of fxCop, (before we had to pay for code analysis in Team Developer) if you

# October 5, 2007 4:57 PM

Gavin Greig said:

Does the "better support for ... Compact Framework" include support for the use of Suppress Message attributes in Compact Framework code? This has been a frustration for us that I haven't seen directly addressed anywhere.

# October 8, 2007 4:55 AM

Ian Ringrose said:

If this be in the normal versions of Visual Studio 2008 or just the Team System versions?

I would hope the professional version of Visual Studio 2008 included all these tool BUT only the Teem System Versions will let a manager force the programmers to use them.  

E.g. professional version == all tools for professionals

teem system version == can force none professionals to use the tools  (professional will choose to use them anyway)

# October 8, 2007 6:30 AM

David M. Kean said:

Gavin: SuppressMessageAttribute is now present in Compact Framework 2.0 and 3.5 (the only versions supported by Visual Studio 2008). Better support also means smarter rules that do not fire when they are not applicable.

# October 8, 2007 12:56 PM

Larry said:

Is there any work being done to make downlevel versions of Visual Studio work better under Vista?

Is there any work being done to work with cross platform libraries to compile cleanly under VS2008 out of the box? Several (Xerces and ICU stick out in my mind) don't  even compile under VS2005.

# October 9, 2007 10:59 AM

David M. Kean said:

Steve: We've actually just released a beta of FxCop 1.36. See http://blogs.msdn.com/fxcop/archive/2007/10/10/fxcop-1-36-beta-released.aspx for more information.

# October 10, 2007 4:28 PM

Walter Stiers - Academic Relations Team (BeLux) said:

Somasegar's WebLog has a entry on VC++ Performance Improvements in VS 2008 . A couple of days ago he

# October 11, 2007 4:05 AM

Kamran Shahid said:

Please Let us know that Code analysis feature will be Vs2008 team suite edition only or is provided in any other edition of VS2008 like standard or professional ?

As in VS2005 it is only integrated in the team suite edition

# November 2, 2007 8:40 AM

conorm said:

Just to clarify.  The code analysis features in Visual Studio Team System are available in the Team Developer SKU and the Team Suite SKU (naturally).  The other SKUs do not have this feature.

Microsoft continues to offer FxCop as a free standalone tool that performs many (but not all) of the same checks as visual studio team system.  This is available for download from MSDN.  To keep up to date with code analysis check out the blog: http://blogs.msdn.com/fxcop - we will soon be posting information on which rules are available in which versions of Visual Studio and FxCop.

# December 13, 2007 5:38 PM

Steve Chadwick said:

Is there a way to extract these metrics via the commandline?  If so, can you share some examples?  I would like to hit the project as part of the build process and log some of the metrics in a database for historical purposes.  I see references to commandline availability, but no examples.

Thanks,

Steve Chadwick

# December 20, 2007 6:17 PM

conorm said:

Steve: Unfortunately, at this time we don't provide the ability to gather the metrics via the command line (and thus integrate with the build process).  I posted more info about this current limitation in the code analysis blog here: http://blogs.msdn.com/fxcop/archive/2007/11/15/code-metrics-customization.aspx

This is a much asked for feature and we are considering it for a future release.  I will make sure we blog about it when we solidify our plans.

Thanks

Conor.

# January 2, 2008 6:22 PM

Andy Sicignano said:

Should code analysis be packaged with VSTS Database Edition? I'm not seeing it.

Thanks,

Andy

# March 26, 2008 4:10 PM

Somasegar said:

Thanks for the feedback Andy.  I know that the team is looking at this.

-somasegar

# March 27, 2008 2:10 AM

Jersson on Geeks·ms said:

Antes de apagar la máquina (o me corten el internet pues dicen que debo dormir, lo cual no comprendo

# May 16, 2008 3:33 AM

KenM said:

Can someone please clarify what code analysis tools are available for unmanaged C++?  For instance, static analysis, metrics, style, etc.

What is the minimum MSDN subscription level they come with?

Thanks,

Ken

# June 20, 2008 6:34 PM

jeffrey25 said:

any plans by Microsoft to include Code Metrics as part of Professional Edition down the line....???

looks like a really good utility and would be great to have inside Visual Studio Professional edition

# July 18, 2008 10:33 AM

jeffrey25 said:

any plans by Microsoft to include Code Metrics as part of Professional Edition down the line....???

looks like a really good utility and would be great to have inside Visual Studio Professional edition

Thanks

--Jeffrey

# July 18, 2008 10:33 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS


Page view tracker