The Rain and The Shade

March 17, 2012

Visual Studio Add-in for code review

Filed under: C# Coding,Code Quality — ovaisakhter @ 9:16 am

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!

Advertisements

8 Comments »

  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.

    Comment by Aakif Hassan — March 18, 2012 @ 6:28 am | Reply

  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.

    Comment by ovaisakhter — March 18, 2012 @ 7:37 am | Reply

  3. Nice but manual.. and manual is by human, and to error is human.. so if a=b and b=c so a=c. hence proven that doing manual is prone to errors.

    Comment by devbridge — March 22, 2012 @ 1:50 pm | Reply

  4. “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 😉

    Comment by ovaisakhter — March 22, 2012 @ 2:33 pm | Reply

  5. 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

    Comment by Aakif Hassan — April 3, 2012 @ 9:46 am | Reply

  6. 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.

    Comment by lalitkale — April 6, 2012 @ 7:03 am | Reply

  7. 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.

    Comment by lalitkale — April 6, 2012 @ 7:04 am | Reply

  8. 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.

    Comment by ovaisakhter — April 6, 2012 @ 7:51 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: