"); " /> "); " /> "); "/>

How to use TfvcHttpClient to find all checked out files (i.e. items with pending changes)?

58 views Asked by At

Consider the following code, which uses the Microsoft.TeamFoundationServer.Client NuGet package:

var tfsServerUri = new Uri("<REDACTED SERVER URL>");
var credentials  = new VssCredentials(); // Default = current user account.

using var connection     = new VssConnection(tfsServerUri, credentials);
using var projectClient  = await connection.GetClientAsync<ProjectHttpClient>();
using var versionControl = await connection.GetClientAsync<TfvcHttpClient>();

var rootProject = await projectClient.GetProject("Root");

var items = await versionControl.GetItemsAsync(rootProject.Id, scopePath: "$/Root", VersionControlRecursionType.Full);

foreach (var item in items)
{
    if (item.IsPendingChange)
    {
        ... Do something with item.
        

This does correctly iterate over all the VSS items under "$/Root", and I can print out the paths.

However, IsPendingChange is always false regardless of whether the item is actually checked-out (i.e. has a pending change).

Is this a bug, or do I just misunderstand what IsPendingChange is supposed to be?

The documentation for TfvcItem.IsPendingChange is completely unhelpful.

The documentation for the Javascript version of isPendingChange states that it is:

True if there is a change pending.

so I was hoping that applied to the C# version too. But alas, it seems not...

Does anyone know of a way to use TfvcHttpClient to find all checked-out files?

0

There are 0 answers