我在其他帖子中看到了此代码,但是,它没有提供如何更新现有注释的示例。有没有人有一个如何做到这一点的例子。
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;
}
答案 0 :(得分:0)
发布的代码审核评论不支持编辑/更改。上面的代码片段可以帮助您从codereviewrequest workitem的id获取所有代码审核评论。
如果您想使用以下方法为此DisscussionThread设置新的代码审核评论,则会收到错误消息“ 由于讨论或讨论,无法更改属性'内容'评论已发布 。“
thread.RootComment.Content = "New Comment";
以下是您可以投票的用户语音:https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/18698392-change-code-review-comments