Inside TFS

Collaborative Commenting with TFS 2013's Lightweight Code Comments

Team Foundation Server 2013's lightweight code comments could change the way your team collaborates.

Here's a scenario: You're sitting in an airport, waiting to get on the plane. You receive a frantic text from a team member, begging you to review a code change the he just checked into your Team Foundation Server environment. He really needs your opinion on the code change that's just been made.

Before Team Foundation Server 2013, you might have asked your team member to e-mail the code change to you. Or you might have booted your laptop, connected to the wireless network at the airport, opened Visual Studio, downloaded the change from Team Foundation Server and then reviewed the change, finally e-mailing the team member back with your comments.

Now, imagine calling up a Web browser on your phone, opening the modified file and leaving comments directly attached to the file that your team member can see and also comment on. And all those comments are tracked in Team Foundation Server. This new feature, called lightweight code commenting, is available with Team Foundation Server 2013 and Team Foundation Service.

It enables commenting on entire files or specific lines of a file. This allows for both an interactive or time-shifted conversation about the code, and works wherever you are, including smartphones.

Lightweight code commenting starts with Team Foundation Server Web Access, which provides Web-based access to a variety of Team Foundation Server features. Open your Web browser and navigate to the Team Web Access site of your team project to get started. From the main page of the site, click the Code tab at the top of the page, then select the Changesets sub-tab. Note that there is also a sub-tab for Shelvesets. Lightweight code comments can be applied to both changesets and shelvesets.

From this page, you can see all the different changesets checked into Team Foundation Version Control. Selecting a changeset link displays detailed information about the changeset, including all the files contained within the changeset, and the details of what was changed within each file, as shown in Figure 1.

[Click on image for larger view.] Figure 1. Leave Comments on a Changeset Using Team Web Access

Clicking the highlighted button at the left of the toolbar lets you leave a comment for the entire changeset. Users can click the reply link in the comment to respond back to it, allowing a chained conversation to begin, similar to a message board. You can also select a comment and create a work item from that comment.

You have the capability to comment on specific files, in addition to the entire changeset. To comment on a specific file, first select it. Then, within the file, move your mouse over the line on which you want to comment. Notice that a new comment button appears to the left of the line number, as shown in Figure 2. Clicking this button opens a new comment, tied to that specific line of code.

[Click on image for larger view.] Figure 2. Add a Comment to a Specific Line of the File

On the left side of the Web page is a Send Email icon for Changesets and Shelvesets that allows you to send a permalink to that source control artifact. This includes data about the files in the changeset or shelveset, and any comments left against those files. This can be very handy if you've left comments on someone's code and want to make sure they know about them.

Lightweight code commenting isn't designed to take the place of the code review process built into Team Foundation Server and Visual Studio. Instead, it should be used as just one more method for team members to provide feedback on the code being developed.

About the Author

Mickey Gousset spends his days as a principal consultant for Infront Consulting Group. Gousset is lead author of "Professional Application Lifecycle Management with Visual Studio 2012" (Wrox, 2012) and frequents the speaker circuit singing the praises of ALM and DevOps. He also blogs at ALM Rocks!. Gousset is one of the original Team System/ALM MVPs and has held the award since 2005.

comments powered by Disqus
Upcoming Events

.NET Insight

Sign up for our newsletter.

I agree to this site's Privacy Policy.