none
How to get code review comments from TFS by workItem Id. RRS feed

  • Question

  • I tried with below code but getting exception "Could not find dataspace with category VersionControl and identifier 00000000-0000-0000-0000-000000000000".

    public List<CodeReviewComment> GetCodeReviewComments(int workItemId)
            {
                var comments = new List<CodeReviewComment>();
                var uri = new Uri(_tfsUrl);
                var service = new TeamFoundationDiscussionService();
                service.Initialize(new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(uri));
                var discussionManager = service.CreateDiscussionManager();
                IAsyncResult result = discussionManager.BeginQueryByCodeReviewRequest(workItemId, QueryStoreOptions.ServerOnly, 
                    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.Content = thread.RootComment.Content;
                        comment.PublishedDate = thread.RootComment.PublishedDate;
                        comment.ItemPath = thread.ItemPath;
                        comments.Add(comment);
                    }
                }

                return comments;
            }

    Thursday, June 6, 2019 7:36 AM

All replies

  • Hi 

    Thank you for posting here.

    For your question id more related to TFS, you could post a new thread in StackoverFlow.

    https://stackoverflow.com/questions/tagged/tfs

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 7, 2019 5:55 AM