Monday, May 26, 2008

Source Analysis For C# Checkin Policy

It is a long weekend in US – and what do the geeks do on a holiday? They write code!

So here is my Sunday Night Live Source Analysis For C# Checkin policy (that uses Microsoft Source Analysis engine released several days ago to perform actual analysis). You can get either MSI installer or the source code. Usual caveats (both the compiled version and source code are provided AS IS with no warranties of any kind) apply.

Once you install the check-in policy using MSI above, you are set (since it includes required assemblies from Source Analysis distribution). Only prerequisite is VS 2008 with Team Explorer installed.

Now, when you define check-in policy for Team Project, you will be prompted to define Source Analysis rules to verify on check-in (in a fashion similar to Code Analysis policy). The policy will work only with C# files you check in that are part of the projects included in the active solution; if you have no solution, or the files are not part of the current solution, the policy will fail with appropriate error.

If all C# files are contained in the current solution, Source Analysis will be run on the files before check in; if it fails the policy will fail (double clicking on the failure message will display detailed dialog).

If you want to run Source Analysis on your projects with same definitions as are in the checkin policy, you will have to have Settings.SourceAnalysis file with the appropriate definitions in your project's folder. The policy does not create those files for you; however, when you check in and the policy is evaluated, the file with Source Analysis definitions will be created in the solution folder (named "<solution name>.sln.SourceAnalysis"). This file may be used to enforce same set of rules as in the policy for separate projects analysis.

I have tested the policy with stock C# projects (such as class libraries or executables); but my guess is there may be two-three bugs still hanging around the code. Drop me a line saying how helpful (or how buggy) it is at eugenez_at_attrice_dot_info.

Update: If you are wondering how I know about these Settings files, read all about it and how to use Source Analysis settings efficiently at Source Analysis team blog

1 comment:

Anonymous said...

Quality tool. Just what we needed. Thanks.