The past few days I moved the development of TestApi to the Codeplex TFS servers. Previously, we used to develop TestApi in the internal WPF branch at Microsoft, which had become a bit of a drag due to the need to support contributors from various teams across the company.

As part of the move, I needed to set up a code review process. Turns out that it’s a bit of a struggle to figure out how to set up a simple CR process using standard tools – mostly due to poor documentation – so I thought I’d share what I did in this post. Hopefully, that will save someone out there some time.

 

Code Review Process

The general CR process goes as follows:

  1. The developer creates a new shelveset (see the TFS documentation for a definition of “shelveset”) with his/her changes and sends the shelveset for CR.
  2. The code reviewer performs the CR, sending back feedback.
  3. The developer revises his/her code based on the CR feedback and generates a new shelveset.
  4. Steps 1-3 get repeated until the code reviewer approves the code change for checkin.
  5. The developer checks in the code.

The tools we use for CR are VS 2010 itself and WINDIFF. The latter is a diffing tool used for step 2 of the CR process.

 

Initial Setup

To set up WINDIFF as your diff-ing tool, in VS 2010 go to Tools > Options…, scroll down to the Source Control item and configure your compare tool to be WINDIFF as shown below:

image

image

image

 

Shelving

Shelving is the act of storing pending changes on the TFS server (see this link for more). To create a shelveset, in Source Control Explorer, right-click on the folder, containing all pending changes, and choose Shelve Pending Changes… in the displayed context menu. This will bring up a dialog that you can use to shelve your changes.

image

Once you shelve your proposed changes, send an email to the code reviewer, with your username and the name of your shelveset.

 

Unshelving, Diffing and Code Review

When you get a CR request, go to File > Source Control > Unshelve Pending Changes… and in the displayed Unshelve dialog, discover the shelveset that you need to review and click Details…

image

In the displayed Shelveset Details dialog, right click the file you want to review and compare it to its unmodified version. This will trigger WINDIFF as a comparison tool. Record your comments in an email and send them back to the developer (or approve the checkin if you agree to it).

image

 

Conclusion

That’s pretty much it. Obviously, this is a poor man’s solution, but it’s certainly better than nothing. There are a bunch of more advanced solutions out there providing code annotation, review workflows, etc. that you may find valuable too. This post by JB Brown may be a good starting point for those who want to go further.