Отличный вопрос.Тем не менее, нет прямого метода, который вы могли бы использовать для этого.Вместо этого вам нужно будет сделать следующее:
public string GetProgrammer(string projectname, string file, int linenumber)
{
// 1. Connect To TFS get the project name that you have passed
var tfs = TfsTeamProjectCollectionFactory
.GetTeamProjectCollection(new Uri("TfsUrl"));
var vsStore = tfs.GetService<VersionControlServer>();
var myProject = vsStore.TryGetTeamProject(projectName);
// 2. Use the versionControlServer Service and get a history
// i.e. all changesets that fall under the parent 'filename'
// with recursion.none
var histories = service.GetBranchHistory(
new ItemSpec[] { new ItemSpec (filePath, RecursionType.None) },
VersionSpec.Latest);
// 3. Loop through each changeset and build your code block adding
// the name of the user who owns the changeset in a List.
foreach (BranchHistoryTreeItem history in histories[0])
{
var change = service.GetChangeset(
history.Relative.BranchToItem.ChangesetId,
true,
true);
if (change.WorkItems.ToList().Count == 0)
{
// Create your file compiling the changes from each check-in
// and lets say store in stream
}
}
// 4. Now pass the line number, in what ever code block it falls
// you should get the details of the user, changeset and other details
// to return.
// Query the stream build in the last step for the line number
return programmerName;
}
Некоторые нерешенные вопросы: - Несколько раз одна и та же строка или, скорее, один и тот же блок кода изменяются несколькими пользователями при разработке файла.Как вы планируете справиться с этим?
Посмотрите на эти записи в блоге, которые могут помочь вам начать работу с TFS, используя versionControlServer для получения наборов изменений для файла и проходя через наборы изменений.http://geekswithblogs.net/TarunArora/category/12804.aspx
HTH Приветствия, Тарун