Monday, September 01, 2008

StyleCop 4.3 Checkin Policy available

In addition to recent release of StyleCop 4.3, Jason Allor has just released the documentation for extending StyleCop with custom rules (aka StyleCop SDK). CHM file contains information on writing custom rules, integration of StyleCop into build process and API reference.

Since new version of StyleCop includes many bug fixes as well as new rules and in the spirit of documented SDK available, I have updated the check-in policy for StyleCop 4.3. The changes include mostly namespace changes (to StyleCop from SourceAnalysis) as well as couple of fixes.

Please note that version 1.1 of policy is not compatible with the previous version; you will have to uninstall old version and reconfigure the Team Projects accordingly.

You can get either MSI installer or the source code. Both the compiled version and source code are provided AS IS with no warranties of any kind.

Related posts:
- Get New Version Of StyleCop
- StyleCop Confusion Cleared
- Source Analysis For C# Checkin Policy
- Source Analysis For C#: Custom Rules And More
- Beautify Your Code With Microsoft Source Analysis


Anonymous said...

I always get the error "Some files were not found in the current solution and cannot be analyzed". I think this is because all the projects are contained in folders in the solution, none are direct decendants of the solution in the Solution Explorer tree.

If I move one of the projects out of the folder and have it directly under the solution, that project can have its source analyzed.

I tried to find a solution using the supplied source code, but don't know enough about policy development to know where to start.

Can you take a look at this?

Colin Nash said...

I love the checkin policy however there are a couple of options I would like to add.

Option to import StyleCop settings from a settings file.

Option to display each StyleCop violation as a seperate checkin failure (currently you have to close the list of failures to be able to go back to editing).

I'm assuming you don't have a problem with people extending what you've done for their own use however I was wondering if you had consider hosting this somewhere (e.g. CodePlex) to allow outside contributions.

eugenez said...

Anon, Colin,

I hear you :) Thanks for feedback!

Will try either to accomodate the requests or post the source to CodePlex. Will try to do that soonish.

steve said...

Any reason why only Windows(C#) projects are evaluated in the StyleCop check in policy? We are developing C# Web Service projects with a project type guid 1DF4D691-79FD-4E3E-B7A6-A1A5DC772BBD which does not get evaluated during check in...

eugenez said...


The reason is - that's a bug (I thought I covered all relevant GUIDs). Will fix soon.

Thanks a lot!

Fluffy said...


We're currently using OpenGauntlet to perform Gated Check-ins. I've found out that the check-in policy you supply expects a version of the IDE to be executing. Using OpenGauntlet this isn't possible - I believe it uses the series of web-services provided by TFS. Would it be possible to get the solution/project information, that the StyleCopConsole object requires, from elsewhere?



eugenez said...


Current implementation of the policy uses VS extensibility quite a lot, as it runs analysis only on files in the projects in the currently loaded solution - more or less similar to how Code Analysis policy works.

It would be relatively easy to change the implementation so it runs analysis on all files (regardless of VS project). However, I still believe that VS bound implementation is more in line with the general demand (but am willing to be convinced o/w).


Anonymous said...

Installs incorrectly if you’ll modify the install path.

Anonymous said...


I have a master solution with nearly 58 projects in subfolders. StyleCop check in emits the "These files are not part of the current open solution" during policy processing.

Let us know what sort of encouragement works best for you when trying to prioritize corrective actions ... :)

eugenez said...

Regarding "these files are not the part of the solution" message - using the last version (1.2) you should see this message only when appropriate (that is, when trying to check in files not in the context of the solution).

Please let me know if 1.2 does not work for you.