使用 TFS API,如何找到对代码审查所做的评论? [英] Using TFS API, how can I find the comments which were made on a Code Review?
问题描述
我正在尝试找出一种方法来查找有关 TFS2012 中代码审查请求/响应项的详细信息.
I'm trying to figure out a way to find details about a Code Review Request / Response item in TFS2012.
我可以通过以下方式查询所有代码审查请求/响应项:
I can query for all Code Review Request/Response items in the following way:
const string TfsUri = "http://mytfsserver:8080/tfs/Default ProjectCollection";
var tfs = new TfsTeamProjectCollection(new Uri(TfsUri));
var store = tfs.GetService<WorkItemStore>();
var versionStore = tfs.GetService<Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer>();
var queryText = "SELECT [System.Id],
FROM WorkItems
WHERE [System.WorkItemType] = 'Code Review Request'
or [System.WorkItemType] = 'Code Review Response'";
var query = new Query(store, queryText);
var result = query.RunQuery().OfType<WorkItem>();
这给了我一个 WorkItem
类型的列表.当我遍历 result.FirstOrDefault().Fields
属性时,它确实为我提供了一些关于与代码审查相关的 ShelveSet 的有用信息,即关联上下文".使用这些信息,我可以查询 ShelveSet:
This gives me a list of WorkItem
types. When I loop over the result.FirstOrDefault().Fields
property, it does give me some usefull information about the ShelveSet which is related to the Code Review, the "Associated Context". Using this information, I can query for the ShelveSet:
var versionStore = tfs.GetService<VersionControlServer>();
var shelveset = versionStore.QueryShelvesets("someCodeReviewId_xxxx","someUserName");
这给了我一个 ShelveSet
项目,但这就是我卡住的地方.
this gives me a ShelveSet
item, but that's where I get stuck.
我查看了 Microsoft.TeamFoundation.CodeReview.Components
和 Microsoft.TeamFoundation.CodeReview.Controls 提供的
库,但这也无济于事.Microsoft.TeamFoundation.CodeReview
命名空间
I've looked into the Microsoft.TeamFoundation.CodeReview
namespace provided by both Microsoft.TeamFoundation.CodeReview.Components
and Microsoft.TeamFoundation.CodeReview.Controls
libraries, but this doesn't help me further either.
我的问题是:如何通过 TFS API 找到在代码审查期间对 ShelveSet 所做的实际评论(一般评论和文件评论)?
My question is: How can I find the actual comments made on a ShelveSet during a Code Review (both General comments and File comments) through the TFS API?
推荐答案
我没有代码示例,但根据 这个讨论,您应该能够在Microsoft.TeamFoundation.Discussion.Client 命名空间.
I don't have code examples, but according to this discussion, you should be able to get to code review comments with functionality in the Microsoft.TeamFoundation.Discussion.Client namespace.
特别是评论可以通过 DiscussionThread 访问 类.您应该能够使用 IDiscussionManager<查询讨论/a>.
Specifically the comments are accessible via the DiscussionThread class. And you should be able to query discussions using IDiscussionManager.
这篇关于使用 TFS API,如何找到对代码审查所做的评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!