1

We have developed a custom check-in policy plugin that traps the check-in events to TFS 2013 on the client. This is used to evaluate certain workflow statuses and generate a meaningful comment for the check-in. For these tasks the Work item selected / associated by the user for the check-in is inspected for validity, and values from the work item are used to generate the comment. This works perfectly in the Visual Studio realm. Until recently all check-ins to TFS were done via Visual Studio 2013. A new team joined us and they make use of XPA Magic. The standard XPA editor seems to makes use of the 32-bit MSSCCI provider for TFS 2013 to perform check outs and check-ins on TFS. When checking in code via the XPA editor, the following dialog is used to allow the user to select / associate his work item and add comments.

enter image description here

Unfortunately when checking-in via this dialog, the functionality does not work anymore. I have debugged the plugin project and when checking OUT via this route, the Evaluate() function is called and exposes the Microsoft.VisualStudio.TeamFoundation.VersionControl.PendingChanges.PendingChangesModelVS . However when checking IN, the Evaluate() function is NOT called.

Is it conceptually possible to also trap the check-in events and achieve the same (or similar) results as when checking in via Visual Studio?

Client machines have Visual Studio Premium 2013 running on Windows 7 connecting to a TFS 2013.Update3 application server.

-

-

Hey Edward,

I am not entirely sure that I am interpreting your reply correctly, but here goes :- )

The idea is to build an comment containing the details from the associated work item (Like the WI number, description and some other custom information) at check-in time. After checking in the file(s) the comment of the change set created, will then contain some useful information . The comment (strings) is generated on the check-in and then set in the following property: PendingCheckin.PendingChanges.Comment = newCheckinComment;

Full NameSpace: {Microsoft.VisualStudio.TeamFoundation.VersionControl.PendingChanges.PendingChangesModelVS}.PendingCheckin.PendingChanges.Comment

We thus need to push the comment in here during the check-in action. At check-in we also know for sure that there is at least one WI associated from where the data can be distilled, as this is enforced.

In debug I see the following events firing every time when these actions are undertaken:

  • On a Refresh within Team Explorer. (PendingCheckin.Policies.EvaluationState = Unevaluated)
  • On a Checkout via the Context menu " Team Foundation Server" in Windows Explorer. (PendingCheckin.Policies.EvaluationState = Unevaluated)

  • On a Check-in with Visual Studio (PendingCheckin.Policies.EvaluationState = Evaluated)

Seeing that we are only interested in the check-in action, the code only responds to : PendingCheckin.Policies.EvaluationState = Evaluated

    public override PolicyFailure[] Evaluate()
    {
        PolicyFailure[] failures = null;

        if (PendingCheckin.Policies.EvaluationState == PolicyEvaluationState.Evaluated)
        {
     InitConfiguration();
            failures = CheckWorkitemStatus();
            if (Util.ArePolicyFailuresOk(failures))
                failures = ComposeCheckinComment();
            if (Util.ArePolicyFailuresOk(failures)) //The setting of the comment -> PendingCheckin.PendingChanges.Comment = newCheckinComment , happen in this function.
                failures = CheckFilesToCheckin();
        }
        return failures;
    }

So as you can see the problem arises that the check-in via the Context menu " Team Foundation Server" in a Windows Explorer, never reaches the Evaluate() function, but the check-out from the same Context menu does … Hope it makes sense!

Morné Kruger
  • 309
  • 1
  • 12
  • 1
    There's no guarantee when policy evaluation will occur. What you're seeing in 2013 is an implementation detail of the UI drawing the policy decisions in Team Explorer. Why is it not appropriate to do this custom action when the policy was evaluated the first time (at checkout time) and save the result? – Edward Thomson Jan 08 '15 at 14:12
  • @EdwardThomson - I have edited the post and added some more details. I think performing these actions at check-out time will not work in our situation, but maybe I am missing something? – Morné Kruger Jan 08 '15 at 16:00
  • I'm saying that you don't know when your check-in policy will get run, only that it will get run *sometime* before check-in. Not necessarily immediately before - it will only get re-executed when the backing model changes. If it can be run *immediately* before checkin then it should also be able to be run an hour before, since the data isn't changing in the interim (or else your policy would be evaluated again). – Edward Thomson Jan 08 '15 at 16:05
  • (It's possible that I still don't entirely understand the lifecycle you're shooting for, though.) – Edward Thomson Jan 08 '15 at 16:06

0 Answers0