Search code examples
vb.nettfstfs-sdk

How do I pass ItemSpec into GetBranchHistory()?


I'm trying to get information about specific branches in TFS, so to start, I'm trying to create a variable to assign as a BranchHistoryTreeItem. However, when I pass in the ItemSpec, I'm getting an error on Spec (not the definition, but where it's passed into GetBranchHistory):

Value of type 'Microsoft.TeamFoundation.VersionControl.Client.ItemSpec' cannot be converted to '1-dimensional array of Microsoft.TeamFoundation.VersionControl.Client.ItemSpec'

I understand the error, but I'm not entirely sure why it throwing it. Isn't this data type exactly what it's looking for? I believe I have the ItemSpec declared correctly, but I'm a bit lost here. Can anyone offer some advice on why I'm getting this? Code:

Sub GetBranchInfo()
    Dim tfs As New TfsTeamProjectCollection(Common.BuildServerURI)
    Dim Version = tfs.GetService(Of VersionControlServer)()
    Dim Spec As New ItemSpec("$/Project1", RecursionType.None)
    Dim BranchHistory As New BranchHistoryTreeItem(Version.GetBranchHistory(Spec, VersionSpec.Latest))
End Sub

Solution

  • GetBranchHistory takes an array of ItemSpecs.

    My VB is a little rusty, but I think you want something like:

    Dim Spec As New ItemSpec("$/Project1", RecursionType.None)
    Dim Specs(1) = new ItemSpec() {Spec}
    Dim BranchHistory As New BranchHistoryTreeItem(Version.GetBranchHistory(Specs, VersionSpec.Latest))