# Friday, April 17, 2009
« Note in Google Reader | Main | OMG I love recessions! »

I finally downloaded Simian today to give it a test drive, and already I think I'm going to love this tool. If you don't know what Simian is, its a tool to automatically locate duplicate lines of code and any good programmer should love to delete duplicated code, which where I work is pretty important. 

Simian being a console application is pretty useful, but being able to click a button from Visual Studio, see the output in the output window, and then being able to navigate to the duplicated lines by double clicking is what I really wanted.  So that's what I did, I created a Simian output formatter that transforms the output to MSBuild formatted output that is clickable!  Cool, how do we use it?

Download and copy the formatting tool somewhere, I put it in my Simian bin directory.  Create a batch file in this same directory, the batch file is used to pipe the Simian results to the formatter because Visual Studio doesn't let you from the external tools menu.  My batch file looks like this:

@ECHO OFF
REM Run simian redirecting output to the MSBuild formatter
C:\"Program Files (x86)"\Simian\bin\simian-2.2.24.exe %1 | C:\"Program Files (x86)"\Simian\bin\SimianMsBuildFormatter.exe

With that out of the way we need to setup Simian as an external tool within Visual Studio.  In this example I will setup Simian for the current file:

Now Simian - Current File will show up in the Visual Studio Tools menu.  With a file open in the editor we just need to click our new menu item to run Simian and get our output. Here's an example output run.

The interesting and useful part is that the source files listed in the output are now clickable, just like from the csc compiler.  Happy dupe finding!

Tuesday, April 21, 2009 3:13:18 PM (GMT Standard Time, UTC+00:00)
Excellent! I think I created something similar - http://blogs.conchango.com/howardvanrooijen/archive/2006/02/18/monkeywrangler-making-simian-more-usable-in-visual-studio.aspx

But recently I've been using Clone Detective for Visual Studio - http://www.codeplex.com/CloneDetectiveVS - it's pretty awesome.

/Howard
Monday, November 23, 2009 8:56:14 PM (GMT Standard Time, UTC+00:00)
I like this tool, but I had to disassemble it and modify the regular expression in order to handle source directories containing the space and underscore characters. Here's the revised expression, in case you're interested in updating the tool:

string pattern = @"\s+Between\slines\s(?<line1>\d+)\sand\s(?<line2>\d+)\sin\s(?<file>[\b_a-zA-Z0-9:\\.]+)";
Doug
Tuesday, November 24, 2009 9:06:10 PM (GMT Standard Time, UTC+00:00)
Thanks, I've applied your changes to the source. You can find the source here: http://code.google.com/p/sneal/source/browse/#svn/trunk/SimianFormatter
Comments are closed.