Click here to Skip to main content
12,954,672 members (71,108 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 7 Oct 2011

Peer Code Review Add-in for Visual Studio 2008 - ReviewMyCode

, 7 Oct 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
Peer code reviews are a proven way to improve software quality. ReviewMyCode helps you overcome some barriers to this best practice with a simple Visual Studio 2008 add-in that fits your process.


Peer code reviews are a proven way to improve software quality. ReviewMyCode helps you overcome some barriers to this best practice with a simple Visual Studio 2008 add-in that fits your process. The team members can contribute to the review process without leaving the development environment.

The add-in works well within a team development environment by integrating the review process with the SVN source control management system.


Getting Started with Extending Visual Studio is a good starting point for Visual Studio add-in development.

Using the Code

An add-in must have at least two files, the add-in descriptor XML file and the assembly which implements the actual add-in. The descriptor file describes the add-in assembly and is located in the user's %USERPROFILE%\Documents\Documents\Visual Studio 2008\Addins folder.

A typical add-in descriptor XML file looks like this:

<Extensibility xmlns="">
		<Name>Microsoft Visual Studio</Name>
		<Description>Review My Code</Description>

The Extensibility\Addin\Assembly gives the path to the add-in assembly. With just the file name, Visual Studio will load the add-in assembly from the add-in descriptor folder. If you need to debug the add-in, you need to point it to the debug build of your add-in. Also you need to set up debug properties of the Visual Studio project to start Visual Studio as an external program. Make sure to specify:/resetaddin ReviewMyCode.View.Connect as the command line arguments.

The entry point of an add-in is the Connect class. It implements Extensibility.IDTExtensibility2 interface. The OnConnection method receives notification that the add-in is being loaded and we perform our initialization code here, such as creation of the solution event (Solution Open, Solution Before Closing) delegates. In order to handle solution level events the delegates must be defined in the Connect class.

The OnStartupComplete method receives notification that the host application has completed loading, in which we create our tool window (add-in window) and shows it. The add-in window is a UserControl.

The rest of the classes are just implementing the logic and the UI. Retrieving information about the code being reviewed depends on the selected line. The following code snippet shows the details:

private void ToolStripReviewItemAddNew_Click(object sender, EventArgs e)
    TextPoint textPoint = null;
    TextSelection selection = 
        Connect.ApplicationObject.ActiveDocument.Selection as TextSelection;
    if (selection != null)
        textPoint = selection.ActivePoint as TextPoint;
        if (textPoint != null)
            this.textBoxLineNumber.Text = 
    CodeElement codeElement = null;
    FileCodeModel2 fileCodeModel =
				as VCFileCodeModel;
    if (fileCodeModel == null)
        fileCodeModel = Connect.ApplicationObject.ActiveDocument.
        		ProjectItem.FileCodeModel as FileCodeModel2;
    if (textPoint != null && fileCodeModel != null)
        // Supported scopes - set up here in the right parsing order
        // from lowest level to highest level.
        // NOTE: Must be adjusted to match any CodeElements supported.
        vsCMElement[] scopes = 
        foreach (vsCMElement scope in scopes)
            // Catch and ignore all exceptions from CodeModel.
            // CodeElementFromPoint will raise a COM based exception:
            // System.Runtime.InteropServices.COMException 
            // (0x80004005): Unspecified error.
                codeElement = fileCodeModel.CodeElementFromPoint(textPoint, scope);
                if (codeElement != null)
    if (codeElement != null)
        this.textBoxMethodName.Text = codeElement.FullName;
        this.textBoxProjectName.Text =
        this.textBoxFileName.Text = codeElement.ProjectItem.Name;
        this.textBoxMethodName.Enabled = true;
        this.textBoxProjectName.Enabled = true;
        this.textBoxFileName.Enabled = true;
    this.textBoxCreatedBy.Text = ReviewWindow.TextToTitleCase(Environment.UserName);
    this.toolStripReviewItemSave.Enabled = true;

Points of Interest

Using the Add-in

  • Add-in must be loaded from the Visual Studio IDE. To do this, select Add-in Manager from the Tools menu.
  • To initiate a review, click on "Send to Review" button. This will bring up a new mail message window. Fill in the "To" field and send the mail message to the team members.
  • Reviewers can add review items by selecting review item tab. To modify an item, click on the item in the review list and then select review item tab.
  • A review item can contain comments, such as a rejection comment or comments about the fix.
  • Loading a solution from the Visual Studio automatically loads the current review log from SVN. When closing the solution, the updated review log will be saved in the SVN.


The Review List

The review list

Adding a Review Comment

Adding a review comment

Adding a Comment for a Review Comment

Adding a comment for a review commen


  • Oct 5 2011 - Version - Initial version
  • Oct 7 2011 - Added screenshots


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hilmi Jauffer
Australia Australia
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionUseless at the moment Pin
satx_ewallace1-Mar-12 10:58
membersatx_ewallace1-Mar-12 10:58 
SuggestionLooks like a very helpful tool Pin
cwienands28-Feb-12 10:31
membercwienands28-Feb-12 10:31 
QuestionVS.NET 2008 only? Pin
nezza17-Oct-11 21:30
membernezza17-Oct-11 21:30 
AnswerRe: VS.NET 2008 only? Pin
Hilmi Jauffer18-Oct-11 9:43
memberHilmi Jauffer18-Oct-11 9:43 
QuestionHi hilmi Pin
Member 83001997-Oct-11 23:32
memberMember 83001997-Oct-11 23:32 
QuestionCan You add a Screenshot? Pin
crashedapp7-Oct-11 5:54
membercrashedapp7-Oct-11 5:54 
AnswerRe: Can You add a Screenshot? Pin
Hilmi Jauffer7-Oct-11 10:21
memberHilmi Jauffer7-Oct-11 10:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 7 Oct 2011
Article Copyright 2011 by Hilmi Jauffer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid