Visual Studio Add-in for code review

Background

We do use static code analysis on our code and use Resharper as well which I am not sure where to place category wise but surely it is the best tool next to visual studio a developer can have. Although these tools have made the life of  the Architects lot easier,  a manual code reviews (if I may say it so) are still very relevant.

Some while back I had to do a code review for a decent sized project.  For some one as Lazy as I am it is a struggle to write down the review reports. It is a pain to write down the context information like project, file, line number and then some selected text to for each defect report. I  Googled for a  tool which can make my life easier, but most of the tools I found were a bit to complex for my need and on top of that most of them were coupled with some particular source control (not to mention they were not free also).

The Add-In

Eventually I thought of writing a very simple version myself. Here are the requirements for this simplest version

  • should be able to show it in visual studio
  • should be able to write a description of the issue
  • should get the context following context information
    • Solution Name
    • Project Name
    • File Name
    • Line Number
    • Selected Text
  • should be able to append these reports to a text file

In this post I will try to introduce you the addin and its capabilities which are not many and how to install it. I will explain a bit more about the code in my next post. I will how ever put a link to the source code in the end if you want to look at it.

Once you install the plug in you get a menu item in your tools menu “Code Review” once this item is clicked a visual studio tool window is loaded with the code review form. You can dock this window in visual studio for easy access. Here is how it looks like after docking.

image

So the plug in offers you some very basic capabilities. Once loaded you can select a text file where all of your review will be saved. You can go to a file and may be select some text and on the window start writing an issue description and puff the above mentioned context information appears in the context box. once done with the description  you can click the append to file button and the description along with the context information will be saved in the text file.

image

 

and when you click append to file here is what is saved to the file

Code Review Defect Report
**************************
Description
***********
this code generated by visual studio really stinks, well not really I am just doing to create a fake code defect report
Context
*******
Solution: C:\Users\Ovais\documents\visual studio 2010\Projects\Wisdom.VisualStudio.Tools\Wisdom.VisualStudio.Tools.sln
Project: Wisdom.VisualStudio.TestApplication
File: Program.cs
Line: 19

Selected Text: Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());

 

Installation

I have not made any fancy installation setup with this so you will have to do the following steps manually

  1. Copy the contents of the install.zip to a folder on your computer e.g. c:\Wisdomplugins
  2. in the visual studio go to tools menu and then select options
  3. in the options dialog select Environment/Add-in/Macros Security
  4. Click the add button and provide the path of your newly created folder.
  5. restart the visual studio and with a stroke of luck you will see the menu item in the tools menu

I have only tested this on the English version and I am pretty sure it will not work on any other language Smile.

You can get the code for the Add-in from the following location.

http://ge.tt/4X0Mm7F?c

As I mentioned I will explain the code of the Add-in in a later post. So if you are interested stay tuned.

Happy reviewing!

8 thoughts on “Visual Studio Add-in for code review

  1. Great work, for manual reviews its superb and i agree with the pain of review and review reports.

    may be resharper should also provide something similar and if this add in integrates with any automatic code checker even if it is Microsoft code analysis, i believe it will be more awesome.

  2. not sure how will such a tool integrate with code analysis ideally code analysis if done as a service should report the issues in the bug reporting system the team is using, and may be assign the defects automatically by getting the last checkin from the source control.

  3. “We do use static code analysis on our code and use Resharper as well which I am not sure where to place category wise but surely it is the best tool next to visual studio a developer can have. Although these tools have made the life of the Architects lot easier, manual code reviews (if I may say it so) are still very relevant.”

    We do need manual code reviews, and actually passing all the levels of static code analysis the manual code reviews become more beneficial.

    things like

    How good you have modelled your domain according to the application requirements
    Your method/class does what its name suggests
    and so on and so forth.

    next time I review your code I will tell you what I am talking about here 😉

  4. i remember myself preparing templates for code analysis and integrating them with TFS with the checkins, that includes standards plus some serious deviations.. but this is all precautions, i agree may be code analysis is not the right candidate for static code review and preparing bug reports, but i think i will give it a try as putting code analysis restrictions on checkins and applying custom rules helped a lot to avoid bad code and people learn as well so it may help us for the reviews as well.

    and the biggest task is to identify if people followed the right architecture, right domain , right patterns at times… and that for sure has to be manual regardless

  5. I think along with the same,if we can add ,datetime stamp of review and may be version of file that is reviewed (pull it from vss/tfs/perforce etc..) that will be awesome..by the way thanks a ton for sharing this simple tool..I love the simplicity of it.

  6. If we could add date time and source control file version of it that will be awesome. btw, Thanks for sharing the tool. I liked the simplicity of it.

  7. Thanks for liking the post and your ideas.

    I dint wanted to couple this implementation with a particular source control that is why I avoided any interaction with the source control. I am thinking of a good way so that the source control functionality can be injected into this type of tools. Will do a post if I end up doing it.

Leave a reply to ovaisakhter Cancel reply