【发布时间】:2022-02-23 18:17:25
【问题描述】:
我需要导出代码审查中所做的 cmets 以及有关相关更改的信息。文件格式不是那么重要,只需要从 Azure DevOps 中获取数据即可。
谢谢!
【问题讨论】:
标签: azure-devops azure-devops-extensions
我需要导出代码审查中所做的 cmets 以及有关相关更改的信息。文件格式不是那么重要,只需要从 Azure DevOps 中获取数据即可。
谢谢!
【问题讨论】:
标签: azure-devops azure-devops-extensions
据我所知,没有可用于导出代码审阅者 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?
【讨论】:
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; }
}
【讨论】: