【问题标题】:How to get review comments from Code Review Response Task in Azure DevOps?如何从 Azure DevOps 中的代码审查响应任务中获取审查意见?
【发布时间】:2020-01-13 13:49:02
【问题描述】:

尝试了各种方法以编程方式从 Azure DevOps 中提取代码审查 cmets。我可以查询这两个任务(代码审查请求和代码审查响应),但无法检索审查者给出的 cmets。

在 TFS、DiscussionThread 和 IDiscussionManager 中获取 cmets。但它没有 lon

方法一: 尝试使用命名空间 Microsoft.TeamFoundation.WorkItemTracking.WebApi 中的 GetCommentsAsync()

方法 2: “内容”将采用 JSON 格式。我也找不到任何评论 cmets。

 internal class Program
    {
        // URI and PERSONALACCESSTOKEN are removed in the sample code due to security reasons.
        // I referred this link for below details https://docs.microsoft.com/azure/devops/integrate/get-started/authentication/pats
        private const string URI = "";
        private const string PERSONALACCESSTOKEN = "";    

        private static void Main(string[] args)
        {
            GetTaskDetail(85527).Wait();
            Console.ReadKey();
        }

        private static async Task GetTaskDetail(int workItemId)
        {
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", PERSONALACCESSTOKEN))));

                using (HttpResponseMessage response = client.GetAsync(
                            string.Format(URI + "_apis/wit/workitems/{0}?$expand=all&api-version=5.0", workItemId)).Result)
                {
                    response.EnsureSuccessStatusCode();
                    var content = response.Content.ReadAsStringAsync().Result;
                }
            }
        }

【问题讨论】:

  • 您应该使用await 而不是在异步方法返回的任务上调用.Result

标签: c# .net azure-devops


【解决方案1】:

您可以将 DiscussionThread 和 IDiscussionManager 与 Microsoft.TeamFoundationServer.ExtendedClient 一起使用。

Rest Api 仍然不包含在代码审查中进行讨论的方法。

【讨论】:

    猜你喜欢
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    相关资源
    最近更新 更多