【问题标题】:Team foundation server - retrieving review commentsTeam Foundation 服务器 - 检索评论评论
【发布时间】:2017-03-23 00:32:15
【问题描述】:

我正在尝试从 TFS 检索我所有代码审查的审查 cmets。 我无法构建查询。我的参数如下。我没有从中得到任何东西:-(

Team Project = @Project
And    Work Item Type     In Group    Code Review Response Category
And    Requested By          =        @Me
Or     Requested By       Was Ever    @Me

谢谢

【问题讨论】:

    标签: tfs


    【解决方案1】:

    工作项查询无法检索代码审查 cmets,您可以使用 TFS API 来实现您的目标。 This case提供了解决方案,大家可以查看:

    您应该能够使用 Microsoft.TeamFoundation.Discussion.Client 命名空间中的功能进行代码审查 cmets。

    具体来说,可以通过 DiscussionThread 类访问 cmets。您应该可以使用IDiscussionManager 查询讨论。

    代码sn-p如下:

     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; }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-21
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      • 2015-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多