Code Reviews Using the Visual Studio Pull Requests Extension
The Pull Requests for Visual Studio is a new experimental extension that adds several code review tools to Visual Studio. This extension aims to make it easy for you to launch and view pull requests inside the integrated development environment (IDE) without needing to switch windows or use the web. We learned from customers that having a high-quality code review process is very important to increase productivity. To achieve that, this extension is enabling you to use existing and new Visual Studio code navigation, debugging and sharing capabilities in your code review process.
As of today, Pull Requests for Visual Studio only supports Azure DevOps and is available for you to download on the Marketplace. For those looking for GitHub pull request support, consider using the GitHub extension for Visual Studio.
This blog will focus on the basics of creating and reviewing a pull request, including:
- Creating new pull requests
- Reviewing pull requests
- Providing expressive comments using markdown, emojis, and likes
- Comparing code differences for over-the-shoulder and self-code review
With this extension you can also:
- Review and checkout Pull Requests from Azure Repos
- Get an inline peek to see more details about methods used in the code
- View previous updates and understand how collaboration and discussion evolved over the course of the pull request
To learn more about this extension, please feel free to watch the following online demo, which talks about building the award winning app, Seeing AI, with Visual Studio 2019.
Creating a New Pull Request
After installing the pull requests extension and connecting to your Git repository on Azure DevOps, you can create a new pull request when pushing your branch to remote by clicking on create a pull request and filling the new pull request form.
You can also create pull requests using the pull requests page by navigating to Team Explorer > Home > Pull Requests and selecting New Pull Request.
When you have local commits that have not been pushed to remote, the pull request extension reminds you to share your changes with remote before creating a new pull request. The Build & Code Analysis Results section will automatically expand and let you know about any failing unit tests, errors, and warnings. (Compatible only with C++, C#, and VB)
Reviewing Pull Requests
The pull requests page provides a summary of pull requests created by you and pull requests that have been assigned to you. You can do a brief review by opening the pull request, reviewing the changes that were made, and leaving comments or approving the pull request as shown below. To do a detailed review and be able to run and debug the pull request locally, you can use the Check out option.
The pull requests details page is a focused screen that provides the pull request description and the discussion that the team is having. It also provides access to the code changes introduced by the pull request where you can add and view previous comments added by the team.
You can add your comments by right clicking on the line of code that you would like to comment on and selecting Add Comment. Markdown and emojis are supported and you can use the preview option to view your comment before creating it. You can also reference bugs, team members, and other context that you might want to bring into your comment. Comments can also be marked as resolved which sends notification to their authors.
Reviewing Your Own Work
The Pull Requests extension for Visual Studio comes with a unique code diff tool that allows you to review your own work any time you want before creating a pull request. This allows you to see a history of changes as you code, which can be helpful when you are conducting over-the-shoulder code review and want to focus on the introduced code changes. To turn on code diff click on the Comparisons button on the tool bar.
With the Pull Requests extension, we now have integrated pull requests and code reviews inside of Visual Studio.
We Need Your Feedback!
We continue to value your feedback. As always, let us know of any issues you run into by using the Report a Problem tool in Visual Studio. You can also head over to Visual Studio Developer Community to track your issues, suggest a feature, ask questions, and find answers from others. We use your feedback to continue to improve Visual Studio 2019, so thank you again on behalf of our entire team.