【问题标题】:Can code review comments be exported to Excel or some other format?代码审查注释可以导出到 Excel 或其他格式吗?
【发布时间】:2022-02-23 18:17:25
【问题描述】:

我需要导出代码审查中所做的 cmets 以及有关相关更改的信息。文件格式不是那么重要,只需要从 Azure DevOps 中获取数据即可。

谢谢!

【问题讨论】:

    标签: azure-devops azure-devops-extensions


    【解决方案1】:

    据我所知,没有可用于导出代码审阅者 cmets 的工具或扩展。有些用户之前已经提交过用户声音,您可以投票,微软工程师会认真评估。 https://visualstudio.uservoice.com/forums/121579-visual-studio

    其他贡献者提供了解决此问题的解决方法,您可以尝试使用 TFS 客户端对象模型提取数据,然后使用 Excel 的自定义 VSTO 插件或使用 Excel Package Plus 或 Aspose Cells 等包将它们放入 Excel生成 Excel 文件。

    详情可以参考本帖:Using TFS API, how can I find the comments which were made on a Code Review?

    【讨论】:

    • 未发送的 cmets 怎么办?我还没有完成更大的代码审查,但需要关闭 VS。
    【解决方案2】:

    以下链接失效

    获取代码审查 cmets 的 C# 示例。

    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
      • 2010-09-11
      • 1970-01-01
      • 2011-02-12
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      相关资源
      最近更新 更多