views:

35

answers:

2

We have TFS. We are moving to TFS soon, but I'd like to know if it's possible to check code against a policy that is not attached to TFS. Especially, if you can do so without having a TFS server attached to VS at all. I'd like to have the policy already TFS capable, or very easily migrated.

We are all on VS2010 ultimate.

A: 

Check-in policies is something that the TFS server executes. There's no other way to do it.

But what do you mean with "TFS capable" anyway? There are 'only' check-in policies of the kind 'There must be a check-in comment' or 'There must be an associated work item', so there is nothing you could prepare with respect to that...

Thomas

Thomas Weller
so there's no way to verify your code meets the policies or locally check your code against policies?
Maslow
The short answer is 'No'. But as I pointed out, I can't see how this would make sense anyway...
Thomas Weller
operating disconnected. I edit my code, make changes that violate check in policy. do I want to have to wait until I get reconnected or back into the office to see if my code is acceptable according to the policies?
Maslow
Yes, that's the way it is - because the policies are physically enforced on the server side...
Thomas Weller
I'm not looking for enforcement, I'm looking for validation, verification. Do I quit working on this code now? Let me run the policy verification. Oh I need a few more things before I stop.
Maslow
I don't think that it is useful to make a difference between 'enforcement' and 'validation, verification' here in this context... Policy checking on the client side is just not possible. Full stop. But anyway: What is it that you want to check, validate, enforce, whatever?
Thomas Weller
So far I've been able to check and validate that I don't inherit from System.Windows.Forms.Form, don't call MessageBox.Show, and that all dialogs use formBorderStyle Fixed by writing custom code analysis rules. This is what I've been looking for, hope they are easiliy enough translated to code check in policies on TFS.
Maslow
Are you using FxCop (aka. 'Code Analysis')? If so, this of course can easily be run at any time against your code. But this is not related to TFS...
Thomas Weller
We are not using any Code Analysis currently, but since this easily promotes to Check-in Policies I think it does exactly what I want http://msdn.microsoft.com/en-us/library/dd537629.aspx
Maslow
A: 

Custom code analysis rules fit the bill here very well.

Writing your own custom rules

How to write custom static code analysis rules and integrate them into Visual Studio 2010 - 2010.03.26

Custom Code Analysis Rules in VS2010 (and how to make them run in FxCop ... -2010.01.06

Writing custom rules for TFS 2008 Code Analysis check-in policy -2009.03.17

So code analysis/fxcop rules are now integrated into vs2010 instead of having to run a separate application, there is a build server capable command line to dump xml results for your build process/server, and the rules are easily migrated/imported to the TFS check-in policies.

How to: Synchronize Code Project Rule Sets with Team Project Check-in Policy

Maslow