Sunday, October 12, 2008

StyleCop 4.3 Checkin Policy version 1.2

Since the last release of the policy, I have received several comments that required attention, and finally I was able to make changes to the code.

Version 1.2 of the policy is available as MSI installer or as zipped source code (available AS IS), and contains the following new features:

  • Ability to import settings from existing *.StyleCop settings file when creating new policy
  • Support for VS projects placed under solution folders
  • Every StyleCop analysis violation is displayed as separate check-in policy violation; summary window is still available when double clicking the policy violation

Using the occasion, I would like to touch upon some points in policy implementation detail

  1. Policy needs Visual Studio to execute, since it makes use of VS extensibility to analyze only the files contained in C# projects in currently opened solution. The idea behind it is as follows: if you have an analysis violation, you should be able to fix that and then compile the code, and that can be done easily only for the current solution
  2. Policy supports all flavours of C# projects in VS; I have tested most and am not aware of any unsupported projects at this time. Any feedback welcome!
  3. Current version of the policy displays every analysis violation as separate check-in policy failure; however, it does not support easy navigation between policy failure and source code that caused the violation. This is the big must have feature for the next release

And talking about the next release, I am hoping to move source code to CodePlex, so it would be more easily available for modifications. Right now, if you have patches be welcome to send them in.

Related posts:
- StyleCo 4.3 Checkin Policy available
- 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

11 comments:

Anonymous said...

I have a Solution containing mulitple projects. In the projects, we have stylecop settings files (and run SC regularly). After installing the StylCop Checkin policy 1.2, and adding the Style Cop check in policy, I receive "TF10139: The following check-in policies have not been satisfied". The description is "Internal error in C# Stylecop integrated check-in policy". Double clicking it generate a pop up with the statement "An item with the same key has already been added."

Any ideas? I can debug it if you provide the source.

Paul V.

eugenez said...

No, I am not aware of the problem. The sources are available (see the link in the post).

I would be happy to help if you could send me a repro.

eugenez said...

Paul,

What you see is a confirmed bug. If you have two projects in the solution with the same name (you can if you add them to solution folders), then the policy fails.

Shane Faulkner said...

I'm managing a team migrating from VB6 to C#. So I have a blend of code in VS2008 and in VB6. We use the MSCCI provider while in VB6.

When someone on my team checkins in code through the MSCCI provider out of VB6 they get

"Internal error in C# Stylecop integrated check-in policy"

Any suggestions on how to fix this?

Shane Faulkner said...

I figured out my problem trying to run this policy through MSCCI VB6. I basiclaly used a Custom Path Policy to kick off your StyleCop Checkin Policy. Works beautifully now.

Anonymous said...

Hi guys,

I'm having exactly the same problem. Can you explain how to guess what's happening? I see that Shage used the MSCCI to solve the issue? Can anybody explainme how to do so?

Cheers,
Enric

eugenez said...

Enric,

Can you please elaborate? Do you run a policy through MSSCCI?

Clem said...

Hi,

Nice to have this. I have a look at source code and debug because I have got the same error "Internal error in C# Stylecop integrated check-in policy".
But it was not because of several project files having the same name but because a same file is referenced twice in one of my project file (yes I am also surprised that VS autorizes it ?!?).

Then I fix the problem adding a try catch around the line "projectFiles.Add(item.get_[...]" in "GetProjectFilesRecursively" method. In the catch block, I make a test on projectFiles.Contains(item.get_[..]) to throw an explicit exception if true, else throw the catched exception.

Do you always plan to put it on CodePlex ? It would be great ;)

Clément

Clem said...

I got another error because my solution contains a WebDeployment project that seems to not implemente project.FileName that is used for tracing...so I remove this information from Trace. About tracing, how do you enable traces in this case ?

Clément

Clem said...

Another problem with WebSite (project type {E24C65DC-7377-472b-
9ABA-BC803B73C61A}). Why are you restricting to some types of projects ?
I deactivate the control of project type to work around.

Neil said...

Hi,

Can you explain how to enforce custom written rules on Check-In? Or is it possible?

When I create the check-in policy I choose Yes to import the settings. However my Custom rules don't appear in the settings file. When I edit the same settings file from Visual Studio by right-clicking on the project and clicking "StyleCop Settings" the custom rules are visible. Any Ideas?

Thanks,
Neil