Click here to Skip to main content
15,174,684 members
Articles / Programming Languages / C#
Posted 4 Nov 2009


61 bookmarked

Code Review Plug-in for Visual Studio 2008, ReviewPal

Rate me:
Please Sign up or sign in to vote.
4.59/5 (18 votes)
4 Nov 2009CPOL5 min read
ReviewPal is a Visual Studio 2008 IDE plug-in to help out doing code reviews. Helps the user with collecting review comments and reporting them within the IDE with easy navigation.
Sample Image - maximum width is 600 pixels


Code Reviewing is a must for a software project/product to maintain the code quality (indirectly the overall quality) and to share knowledge by pointing out best practices, etc. There are not lots of tools out there to help out with code reviews and not all those tools fit into organizational needs. What this tool does is that it makes it really easy to do code reviews and to address the review comments easily with less effort.


Doing code reviews or addressing them by the owner of the code can be done even without using tools. It can be done even with an Excel file, where the reviewer reports his comments on an Excel file and passes it to the code owner and he addresses the comments by navigating to the code areas mentioned on the Excel file. But is this something we should do as professionals giving software solutions to others?

This process should be very much integrated with the development IDE, and neither reviewer nor the developer should have the need to switch to other unrelated applications in the code review process (unless really needed, not just to read the comments and navigate to the correct place).

So my idea was to search for an IDE plug-in to help with this, where reviews can be done totally within the IDE itself. Not being able to find such a tool exactly the way I wanted, I thought of developing one.

Using the Code

This is a plug-in for the Visual Studio IDE, so all you have to do this is deploy the plug-in and enable it, to use it. If you are not interested in the code and you would just like to try it out, all you have to do is download the "ReviewPal Add-In binaries" and copy it to the plug-in directory.

Plug-in Location: C:\Users\Chathuranga\Documents\Visual Studio 2008\Addins for my machine on Windows 7.

How Visual Studio plug-ins work is through the ".AddIn" files. At the startup of the VS IDE, it looks for the plug-in location usually "Visual Studio 2008" folder under current users documents folder and loads those Add-ins. These .AddIn files are just XML files, like the one below:

<?xml version="1.0" encoding="UTF-16" standalone="no"?> 
   <Extensibility xmlns=""> 
       <Name>Microsoft Visual Studio</Name>   
      <Description>ReviewPal - Code review companion.</Description> 
      <AboutBoxDetails>For more information about </AboutBoxDetails> 

The important tag here is the <Assembly> which contains the DLL location for the Add-In. For usage only; this could be set to the release version of the DLL either from the same directory where .AddIn file resides or from an installation folder. If you are to develop the Add-In or for debugging, this can be directed to the debug folder of the DLL.

The starting point of a Visual Studio plug-in is the "Connect" class which implements the two interfaces "IDTExtensibility2" and "IDTCommandTarget". This class is auto generated initially when you create a project with the template "Visual Studio Add-In" under "Other project types --> Extensibility". Then the key point of change is required on the "OnConnection" method of the "Connect" class.

public void OnConnection(object application, 
	ext_ConnectMode connectMode, object addInInst, ref Array custom)
            visualStudioInstance = (DTE2)application;
  _addInInstance = (AddIn)addInInst;
    object programmableObject = null;
    String guidstr = "{858C3FCD-8B39-4540-A592-F31C1520B174}";
    EnvDTE80.Windows2 windows2 = (EnvDTE80.Windows2)visualStudioInstance.Windows;
    System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
    _windowToolWindow = windows2.CreateToolWindow2
	(_addInInstance, asm.Location, "ReviewPal.UI.ReviewWindow", "Review List",
 	guidstr, ref programmableObject);
    _windowToolWindow.Visible = true;
    ReviewWindow rCommentControl = (ReviewWindow)_windowToolWindow.Object;
    rCommentControl.VisualStudioInstance = visualStudioInstance;
  catch (Exception ex)

We gain the great power of VS extensibility here with a reference to the Visual Studio instance, which we assign as a reference object within our plug-in (visualStudioInstance variable in the code), so that we get to access the IDE and control it. And then we load the UI elements implemented as "ReviewPal.UI.ReviewWindow". Notice that we load our custom UI elements through the "windows2.CreateToolWindow2" method, which creates a window within the IDE same like other in-built Visual Studio windows like the Solution Explorer or Task List. This way we inherently gain all the behaviors of the typical VS IDE windows like docking, floating, etc.

Once we have this setup, it becomes much like developing a Windows Forms application, which means you can do anything that a windows forms application can do, interacting with the IDE as and when required. So what I have done here is, provide a list of Reviews as in a grid control and user populates it with review comments. When adding a new review comment, we can get the current IDE properties as follows through the "VisualStudioInstance" reference we assigned in the initial OnConnecttion method.

TextSelection textSelection = 
int line = textSelection.CurrentLine; 
int col = textSelection.CurrentColumn; 
string file = VisualStudioInstance.ActiveDocument.Name; 
string project = VisualStudioInstance.ActiveDocument.ProjectItem.ContainingProject.Name;

With the Plug-in enabled on Visual Studio 2008 solution, you can navigate through the source code and add review comments for the code, which will be saved into an XML document when you click save (for which I have chosen XML serialization for easy implementation). And you can pass the review comments (the saved file) to the owner of the code in whatever way is preferred (may be through SVN). Then the owner of the code needs to load the review file using the same plug-in, and he can easily navigate to the code locations to address them. The data currently gathered during a review looks like below:

Class diagram of data colleced at a review

One thing to note about the Solution items hierarchy in Visual Studio is as follows:


When navigating through the solution for searching location (implementation of the ReviewPal.Common.ScanForProjectItems method), first we need to iterate through the Project s in the Solution, then ProjectItems in the projects. ProjectItem could have inner ProjectItems (in case of project items having multiple items like for an ASP.NET page with three items of .aspx, .aspx.cs, designer.cs) or it could have SubProject or nothing inner. So when searching for items, it's implemented in a recursive way to handle this.

With a little effort on XSLT, the XML can be made friendly for the users without the plug-in, Example: Click here.

Sample Image - maximum width is 600 pixels

Points of Interest

Writing plug-ins for Visual Studio was interesting but there's not much documentation, at least it's not easy to find.
Visual Studio 2005 Automation Samples is a good starting point.

So anyone can use this plug-in as a sample to start writing Visual Studio plug-ins. As a fan of Jetbrains Resharper, I tried developing plug-ins with Resharper, and also checked out DX Core, but both seemed to have less documentation to get it going, and at last I thought why should I rely on another third-party library to implement this type of a simple (but very useful :)) plug-in.


  • v .1.0.1 ... This is the initial version and I'll be updating ... may be with your valuable comments (when I some find time)


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


About the Author

Chathuranga K.W.
Technical Lead Zone24x7
Sri Lanka Sri Lanka
Working on .Net stuff, over five years of experience mainly on Web development.

Comments and Discussions

GeneralMy vote of 5 Pin
VC Sekhar Parepalli2-Aug-13 6:26
MemberVC Sekhar Parepalli2-Aug-13 6:26 
Great work, Chaturanga
QuestionVisual Studio 2010 Support? Pin
Surimans27-Nov-10 0:55
professionalSurimans27-Nov-10 0:55 
AnswerRe: Visual Studio 2010 Support? Pin
Chathuranga K.W.30-Dec-10 2:46
MemberChathuranga K.W.30-Dec-10 2:46 
AnswerRe: Visual Studio 2010 Support? Pin
Chathuranga K.W.30-Jan-11 18:54
MemberChathuranga K.W.30-Jan-11 18:54 
GeneralMy vote of 5 Pin
Member 14304117-Sep-10 21:15
MemberMember 14304117-Sep-10 21:15 
GeneralRe: My vote of 5 Pin
Chathuranga K.W.30-Dec-10 2:46
MemberChathuranga K.W.30-Dec-10 2:46 
GeneralRe: My vote of 5 Pin
Chathuranga K.W.30-Jan-11 18:55
MemberChathuranga K.W.30-Jan-11 18:55 
GeneralI am not able to usederstand how to use this addins in existing project Pin
keyur soni4-May-10 2:43
Memberkeyur soni4-May-10 2:43 
GeneralRe: I am not able to usederstand how to use this addins in existing project Pin
Chathuranga K.W.10-Jun-10 20:47
MemberChathuranga K.W.10-Jun-10 20:47 
GeneralRe: I am not able to usederstand how to use this addins in existing project Pin
Chathuranga K.W.30-Dec-10 2:45
MemberChathuranga K.W.30-Dec-10 2:45 
GeneralMy vote of 1 Pin
keyur soni4-May-10 2:42
Memberkeyur soni4-May-10 2:42 
GeneralRe: My vote of 1 Pin
Chathuranga K.W.30-Dec-10 2:45
MemberChathuranga K.W.30-Dec-10 2:45 
GeneralEnhance the add-in Pin
seagle01283-Dec-09 1:51
Memberseagle01283-Dec-09 1:51 
GeneralRe: Enhance the add-in Pin
Chathuranga K.W.30-Dec-10 2:44
MemberChathuranga K.W.30-Dec-10 2:44 
GeneralRe: Enhance the add-in Pin
Chathuranga K.W.30-Jan-11 18:57
MemberChathuranga K.W.30-Jan-11 18:57 
GeneralIs it safe to to develop a pluggin Pin
johan s max22-Nov-09 23:16
Memberjohan s max22-Nov-09 23:16 
GeneralRe: Is it safe to to develop a pluggin Pin
Chathuranga K.W.22-Nov-09 23:28
MemberChathuranga K.W.22-Nov-09 23:28 
GeneralAnother suggestion Pin
karenpayne10-Nov-09 5:57
Memberkarenpayne10-Nov-09 5:57 
GeneralRe: Another suggestion Pin
Chathuranga K.W.30-Dec-10 2:44
MemberChathuranga K.W.30-Dec-10 2:44 
GeneralRe: Another suggestion Pin
Chathuranga K.W.30-Jan-11 18:59
MemberChathuranga K.W.30-Jan-11 18:59 
GeneralGreat job! Features suggestions Pin
Javier Miranda9-Nov-09 8:57
MemberJavier Miranda9-Nov-09 8:57 
GeneralRe: Great job! Features suggestions Pin
Chathuranga K.W.10-Nov-09 5:50
MemberChathuranga K.W.10-Nov-09 5:50 
GeneralRe: Great job! Features suggestions Pin
seagle012814-Dec-09 0:48
Memberseagle012814-Dec-09 0:48 
GeneralRe: Great job! Features suggestions Pin
Chathuranga K.W.14-Dec-09 4:33
MemberChathuranga K.W.14-Dec-09 4:33 
GeneralRe: Great job! Features suggestions Pin
seagle012816-Dec-09 7:34
Memberseagle012816-Dec-09 7:34 

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.