Scott Dorman

ephemeral segment

  Home  |   Contact  |   Syndication    |   Login
  603 Posts | 10 Stories | 862 Comments | 51 Trackbacks

News


Post Categories

Image Galleries


Microsoft Store


Creative Commons License



Locations of visitors to this page

Subscribers to this feed

TwitterCounter for @sdorman

View blog authority

Add to Technorati Favorites

Windows Live Alerts

AddThis Social Bookmark Button

LinkedIn profile

Community Credit profile

The Code Project

Follow me on Twitter

Get Free Shots from Snap.com

Community Credit Hall of Fame

Get Feedghost

Xobni outlook add-in for your inbox



Support This Site

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

As many of you know, I'm a big proponent of code styles and standards. As part of that, I'm always on the lookout for new tools that help enforce (or at least report) those standards.

Some of you may have heard about a tool called StyleCop. In fact, there are references to StyleCop in some of the MSDN articles and other blogs. Since it was an internal tool, we could only imagine what features it provided and hope to find a copy of it somewhere. Well, imagine no longer. Earlier this week, Microsoft released StyleCop as Source Analysis for C#.

I think the tool is still a little rough around the edges and doesn't have a lot of supporting documentation around the rules it checks, but it's a good first start. It installs into Visual Studio and allows you to run analysis on a solution, project, or file.

Source Analysis is different from static analysis (FxCop) since it analyzes the source code directly not a compiled binary. As a result, source analysis focuses on more design (or style) issues such as layout, readability and documentation. There are some interesting future directions, including the ability to fix many of the violations automatically.

There are a few things that I think Microsoft needs to address now that we have both FxCop and StyleCop available. First is the issue of names. The "FxCop" and "StyleCop" names are fine, however the names "Source Analysis" (StyleCop) and "Code Analysis" (FxCop) are way too similar and are going to lead to a lot of confusion. The better choice is to call everything source analysis (or code analysis, pick one and stick with it) as the overall technology/process concept and then create individual tools (and names) underneath that.

Second, the rules documentation for StyleCop really should be following the same pattern as FxCop. Again, these are very similar tools and really should provide a consistent experience. Along those lines, I'd really love to see the integrated static "Code" analysis ripped back out of Visual Studio and put directly into a stand-alone version of FxCop (that can integrate with both Visual Studio and MSBuild). This is how StyleCop works and I think it's a great model since it keeps these tools free for all developers and helps reinforce the idea that this type of analysis is important to the community as a whole, not just the small portion that can afford the more expensive Team Suite editions of Visual Studio.

Continuing the Visual Studio integration idea, the StyleCop settings really should be integrated with the project properties in the same way as the static code analysis. (This also means that if/when the code analysis becomes separate again (see the previous paragraph) that we don't loose that level of integration.)

I like the fact that StyleCop can integrate with MSBuild, but it would also be nice if I could get this integration directly through Visual Studio so I can make it part of my every day builds if I want. (Again, this is similar to the integrated static code analysis).

All of that aside, I think this is a good first start that should become part of your every day builds, particularly if you have any type of automated build environment. Be sure to download it from Code Gallery.

posted on Sunday, May 25, 2008 10:13 AM

Feedback

# re: Source Analysis 5/30/2008 10:12 AM Don
Be wary of this add-on. When I added it to my Windows Server 2008 dev system for VS 2008, when I went into Project properties a couple of days later, I received an error message "COM object that has been separated from its underlying RCW cannot be used" and nothing showed up on any of the Properties pages! I un-installed this add-on and the problem went away.

Not worth the hassle, besides I too got a bunch of really un-useful reports. Very hard to find the gems in all the fluff.

# re: Source Analysis 5/30/2008 9:34 PM Scott
Don, keep in mind that this is really a v1.0 release and the first time it's been seen outside of Microsoft. There is definately a lot of room for improvement, but now that it's in the hands of the community I'm sure there will be more improvements to come.

As far as the rules "noise", it's not too much different from FxCop in that regard. You do have the option of customizing what rules are run, but currently no way to add your own.

The COM error you mention isn't specific to this add-in as I've seen other add-ins generate it as well.

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