Welcome to blogs.conchango.com Sign in | Join | Help

Welcome to blogs.conchango.com

Howard van Rooijen's Blog

StyleCop for ReSharper on CodePlex

Update: StyleCop for ReSharper is now feature complete.

While I was on holiday Microsoft released a new version of Microsoft Source Analysis for C#, in the new version - 4.3 - it has been re-branded to it's original internal Microsoft name - StyleCop. There was a bit of a backlash against the initial release of Source Analysis - a few members of the community were warned that the existing Terms and Conditions of Source Analysis for C# did not allow reverse engineering thus any custom rules or modifications. Thankfully Brian Harry (Visual Studio Team System Guru) stepped in and cleared up the confusion; which has lead to the release of an Official StyleCop 4.3 SDK - which now allows the community to extend and integrate StyleCop, without reverse engineering the assemblies. Thankfully it looks as though Jason Allor ran StyleCop against the StyleCop source code as the documentation provided in the SDK is extensive and complete!

So even though I promised myself I wouldn't do any coding while on holiday - one wet evening in Cape Town lead to me opening up my laptop and checking my RSS feeds only to discover that the StyleCop SDK had been released. I decided to re-write my prototype following the new information available in the SDK. The results can now be found on CodePlex under a new project called "StyleCop for ReSharper". Both the Source and MSI Installer are available.

Here's the initial blurb from the CodePlex page:

The Plug-in is a custom hosting environment for StyleCop which is invoked by ReSharper's IDaemonStage, IDaemonStageProcess interfaces. The StyleCop engine can, at this time, only process files rather than file contents, this leads to a particular problem when trying to achieve real-time syntax highlighting - that is, unless you constantly save the file, the contents of the code file within the IDE will become out of sync with the version on the File System that the StyleCop engine will process.

In the current version of the plug-in, a shadow copy of the current source file is created in the current users temporary files area. This shadow copy is over-written with changes as they are made. The StyleCop engine analyses this shadow copy and any resulting violations are displayed in the IDE.

The Plug-in also implements a scavenging algorithm to clean up the shadow copies to ensure that no space is wasted.

This version of the Plug-in also tries to find and use the Settings.STYLECOP file of the project currently being analysed, this allows the plugin to display violations only of the rules you have enabled. This search algorithm is quite rudimentary and can easily be updated to be made a little more robust.

I hope you find the plug-in useful.

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

Comments

 

Howard van Rooijen's Blog said:

[UPDATE] See post " StyleCop for ReSharper on CodePlex " for more info. I've worked on a couple of projects

September 14, 2008 23:31
 

Ian Shimmings said:

Nice work. Since we chatted about this I've been looking forward to seeing it in action. Just downloaded the source and will be checking it out later this week. I'll let you know how it goes.

September 16, 2008 09:35
 

David McGhee said:

This is a wonderful addition to the Style Cop tool. It works quite well. I wish that creating and implementing the custom rules were as simple as just using this tool. I guess that last comment raises a good question. Does Style Cop for Re-sharper enforce custom rules as well?

dave.9306@hotmail.com

September 18, 2008 21:23
 

Howard van Rooijen's Blog said:

It's been a while since I published StyleCop for ReSharper on CodePlex . Just after I put the project

November 6, 2008 10:12
 

Rob said:

Wow, awesome. Just what I've been looking for.

We're trying to enforce a code style (I know developers don't always like it), and with ReSharper integration, it makes it so nice and easy for them.

I have been implemented StyleCop as part of the build (it'll fail if they break any rules), but before turning that functionality on I needed an easy way of helping developers ensure they adhere to styling rules.

Hopefully this will do that. I'll give it a go this week and see how I get on.

February 5, 2009 11:46

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

Powered by Community Server (Personal Edition), by Telligent Systems