TFS代码审核评论 [英] TFS Code review comment
问题描述
如何在TFS门户网站中获取代码审核评论报告。
谢谢
Thanks
推荐答案
您好dkonnet,
Hi dkonnet,
感谢您发布此处。
目前,工作项查询和休息API都无法检索代码审核注释。
Currently neither Work item query nor rest API is able to retrieve code review comments.
我们可以为所有代码审核工作项创建查询(代码审核请求,代码审核响应),打开它们时没有评论。我们只能在团队资源管理器中查看评论。
We can create query for all Code Review work items (Code Review Request, Code Review Response), but no comments when open them. We can only view the comments in Team Explorer.
但是您可以使用TFS API获取评论报告。
However you can get the comments report by using TFS API.
具体来说,注释可以通过 DiscussionThread < /跨度>类。
只需要使用
讨论style ="color:#242729; font-family:'Arial',sans-serif; font-size:11.5pt"> IDiscussionManager 。
示例代码如下:
Specifically the comments are accessible via the DiscussionThread class. Just need to query discussions using IDiscussionManager. Sample code as below:
public List<CodeReviewComment> GetCodeReviewComments(int workItemId)
{
List<CodeReviewComment> comments = new List<CodeReviewComment>();
Uri uri = new Uri(URL_TO_TFS_COLLECTION);
TeamFoundationDiscussionService service = new TeamFoundationDiscussionService();
service.Initialize(new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(uri));
IDiscussionManager discussionManager = service.CreateDiscussionManager();
IAsyncResult result = discussionManager.BeginQueryByCodeReviewRequest(workItemId, QueryStoreOptions.ServerAndLocal, new AsyncCallback(CallCompletedCallback), null);
var output = discussionManager.EndQueryByCodeReviewRequest(result);
foreach (DiscussionThread thread in output)
{
if (thread.RootComment != null)
{
CodeReviewComment comment = new CodeReviewComment();
comment.Author = thread.RootComment.Author.DisplayName;
comment.Comment = thread.RootComment.Content;
comment.PublishDate = thread.RootComment.PublishedDate.ToShortDateString();
comment.ItemName = thread.ItemPath;
comments.Add(comment);
}
}
return comments;
}
static void CallCompletedCallback(IAsyncResult result)
{
// Handle error conditions here
}
public class CodeReviewComment
{
public string Author { get; set; }
public string Comment { get; set; }
public string PublishDate { get; set; }
public string ItemName { get; set; }
}
更多细节请参考这个类似的问题: 使用
TFS API,如何查找在代码审核中发表的评论?
最好的问候
这篇关于TFS代码审核评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!