Leon Mayne

As I noted in http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1475094&SiteID=1 I think there is a bug in EvaluateCheckin with respect to checkin notes. Even if you set a checkin note as required, EvaluateCheckin does not add to NoteFailures for it if you pass in null or an empty string.

To reproduce:

  • In a TFS project's source control properties, remove all but the 'Code Reviewer' checkin note and make this required
  • Check a file out in your workspace and make a change to it
  • Create a C# console app and paste the below code in:
Code Snippet

using System;

using System.Collections.Generic;

using System.Text;

// Microsoft.TeamFoundation.VersionControl.Client.dll

using Microsoft.TeamFoundation.VersionControl.Client;

// Microsoft.TeamFoundation.Client.dll

using Microsoft.TeamFoundation.Client;

namespace NotesTest

{

class Program

{

private static string _strWorkspaceLocation = @"C:\YourWorkspace";

private static string _strTeamFoundationServer = "http://TfsServer:8080/";

static void Main(string[] args)

{

// Get a reference to the TFS Server

TeamFoundationServer objTfsServer = new TeamFoundationServer(_strTeamFoundationServer);

// Get a reference to the version control server

VersionControlServer objVersionControl = (VersionControlServer)objTfsServer.GetService(typeof(VersionControlServer));

// Get a reference to the workspace

Workspace objWorkspace = objVersionControl.GetWorkspace(_strWorkspaceLocation);

// Create a checkin notes object to pass into EvaluateCheckin

CheckinNoteFieldValue objCheckinNoteValue = new CheckinNoteFieldValue("Code Reviewer", "");

CheckinNoteFieldValue[] objCheckinNoteValues = new CheckinNoteFieldValue[1];

objCheckinNoteValues[0] = objCheckinNoteValue;

CheckinNote objNote = new CheckinNote(objCheckinNoteValues);

// Make sure we have pending changes

if (objWorkspace.GetPendingChanges().Length == 0)

{

Console.WriteLine("No pending changes to test with");

}

else

{

// Evaluate the pending checkin

CheckinEvaluationResult objResult = objWorkspace.EvaluateCheckin(CheckinEvaluationOptions.Notes,

objWorkspace.GetPendingChanges(), objWorkspace.GetPendingChanges(),

"Test comments", objNote, null);

// See if we have any notes failure

if (objResult.NoteFailures.Length == 0)

{

Console.WriteLine("No Notes failures!");

}

else

{

Console.WriteLine("Note failure found:");

Console.WriteLine(objResult.NoteFailures[0].Message);

}

}

Console.WriteLine();

Console.WriteLine("Press return to close");

Console.ReadLine();

}

}

}

Change the location to your workspace mapping and TFS server at the top and execute the code. You can see that no checkin note failures are returned, even if you change the note's empty string value to null.

Could someone confirm this I may, of course, be going mad or doing something stupid!



Re: Team Foundation Server - Version Control Workspace.EvaluateCheckin Bug?

Michal Malecki - MSFT

Hello,

as far as I know it's up to client (not client OM) to verify that check notes have correct values. I will ask is it a bug or a feature.






Re: Team Foundation Server - Version Control Workspace.EvaluateCheckin Bug?

Leon Mayne

What's the point of using EvaluateCheckin just for the notes if it doesn't check for required values I know it checks for invalid note keys, but let's face it, this isn't going to happen through a properly designed interface is it

OK, so if I have to do all the work, how do I tell if a check in note is mandatory





Re: Team Foundation Server - Version Control Workspace.EvaluateCheckin Bug?

Michal Malecki - MSFT

This should be sufficient:

public CheckinNoteFieldDefinition[] VersionControlServer.GetCheckinNoteDefinitions(TeamProject[] teamProjects)

CheckinNoteFieldDefinition has property Required.

Hope this help






Re: Team Foundation Server - Version Control Workspace.EvaluateCheckin Bug?

Leon Mayne

OK, I wrote a quick function which returns an object array of CheckinNoteFailures. I dumped it on the community content section of the EvaluateCheckin method docs if anyone needs it:

http://msdn2.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.workspace.evaluatecheckin(VS.80).aspx