Visual Studio & diff Tools

Visual Studio & diff Tools

A diff tool (software to compare the difference between two text files) is a valuable asset to those of us who spend more than a healthy portion of the day looking at text files. Mostly this is to understand, what is different between the original and new version of some code.

Here I’m looking at some common solutions, and the wrapper I created for visual studio.

Common Solutions

Most text editors have a plugin available (usually installable through a plugin manager) such as:

Visual Studio

For visual studio there is the compare files functionality.

Docs:

My Visual Studio Wrapper

As I do a lot of work using SSMS for prototyping and testing (a development phase where I’m not using source control), I needed an independent diff interface. I wanted to do a diff on files using Visual Studio, which isn’t so straightforward if the files aren’t already open with visual studio and using source control.

My solution was to manipulate the command line arguments to visual studio using python, including two file open dialogues which allow to select files passed to the visual studio command line.

  • My code repository:¬†https://github.com/d-roman-halliday/vs_diff

Extending to “Send To” context menu

I run this with the bat file easily accessible.

My solution can be modified to be added to the “Send To” context menu in windows (I haven’t done this yet).

  1. In file explorer, go to the address: shell:sendto
  2. Add a .cmd file: Visual Studio Diff.cmd
  3. Put commands into it like a bash script (see below).
  4. Modify the python script to take an optional argument for the first file.

Visual Studio Diff.cmd

Populate the file with the below, changing the path reference:

@echo off
cls
python C:\Your\File\python_script.py %1

If you want to be able to manage multiple files, then you can modify the command file to something like:

@echo off
cls
:python_loop
IF "%1"=="" GOTO completed
python C:\Your\File\python_script.py %1
SHIFT
GOTO python_loop
:completed

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.