Search code examples
azure-devops

Pull Requests: Referencing code in comment replies


I know you can go to the files section of a PR and click to add a comment that references code. But is there any markdown or other method that lets you add a reference to some code in the replies to comments?

note: I mean referencing code from a file, not just pasting in the code. I'd like the code to update dynamically similar to code referenced when creating a comment with a file/line reference.


Solution

  • Here is a statement in Syntax guidance for basic Markdown usage:

    Note: Code attachments aren't permitted in PR comments

    Screenshot of above note on the Microsoft syntax guidance page from the link

    So I am afraid it is not support in Markdown.

    You can try to click the "Copy link to this selection" option for a piece of code in a file and then insert the generated link into the comment reply to achieve the reference.

    Screenshot of the "Copy link to this selection" button when hovering over code in a PR in Azure DevOps

    Screenshot of PR comment editor, with the "Link" button hovered