代码审查意见可以导出为 Excel 或其他格式吗?

Can code review comments be exported to Excel or some other format?

我需要导出对代码审查所做的评论以及有关相关更改的信息。文件格式并不重要,只需要将数据从 Azure DevOps 中取出即可。

谢谢!

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

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

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

下面提到的 link 不起作用

获取代码审查意见的 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; }
    }