Visual Studio 2010/11 Utilities

Here is a compilation of very useful utilities for VS 2010 and VS 11.
Note: Utilities with an asterisk (*) beside the name are not available to VS 11 yet.

CLIArgs Made Easy

http://www.ricardosabino.com/?p=214
CLI Args Made Easy (Command Line Arguments Made Easy) is an add-in that allow you to change the command line arguments of the startup project very easily by adding a combobox in the toolbar. It also saves all the arguments you insert for future use.

Debugger Canvas (*)

http://msdn.microsoft.com/en-us/devlabs/debuggercanvas.aspx
Debugger Canvas is a new user experience for the debugger in Visual Studio Ultimate. It pulls together the code you’re exploring onto a single pan-and-zoom display. Visual debugger and multithreading debugging goodies.

Productivity Power Tools (*)

http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef
A set of extensions to Visual Studio Professional (and above) which improves developer productivity. Very useful enhanced scrollbar, vertical tabs, quick find files, searchable references and editing tools.

ReSharper

http://www.jetbrains.com/resharper/
With unparalleled support for C#, VB.NET, XAML, JavaScript, XML, HTML, CSS, ASP.NET and ASP.NET MVC, including comprehensive cross-language functionality, ReSharper will help Visual Studio users write better code, easily examine and refactor existing code bases. A must have for anyone who’s doing C# code.

Visual Assist X

http://www.wholetomato.com/
Read, write, navigate, and refactor code FAST with more than 50 productivity-boosting features for C++/C, C#, VB, ASP, JavaScript. A must have for anyone who’s doing C++ code.

VisualHG (*)

http://visualhg.codeplex.com/
Mercurial Source Control Plugin for MS Visual Studio.

CLIArgsMadeEasy2010 Update

I just updated my CLIArgsMadeEasy2010 Visual Studio add-in. It fixes a bug that prevented it from working correctly on solutions that included projects inside project folders.

I’ve also decided to update it with a small feature that saves a lot of time. If you’re like me and have a few add-ins installed, you might have a context menu like mine that fits the whole screen at 1080 and it becomes painful to find the “set as starting project” option. So CLIArgsMadeEasy2010 v1.2 now includes a neat combo box with the current startup project and all the other projects which allow you pick another project as the startup project very easily by choosing it from this combo box.

If you don’t use any of the features you can hide them by clicking in the arrow beside the add-in toolbar box.

Grab the add-in here.

CLI Args Made Easy 2010 / 2012

Find the new CLIArgsMadeEasy version here.

 

Summary

Improved version of the CLI Args Made Easy for Visual Studio 2005 and 2008.
Visual Studio Add-in that puts the project’s command line arguments more accessible.

Description:

Command Line Arguments Made Easy (CLIArgsMadeEasy) is a Visual Studio Add-in that eases the access and change of the startup project’s command line arguments. Instead of having to go to project properties or instead of using the command window to run your program with different arguments, CLIArgsMadeEasy adds a field in the toolbar for you to edit and saves everything you enter. A button is also added that opens a console window in the project’s working directory or home directory (if there’s no working directory set for this project).

Features:

  • More stable and faster than it’s predecessor CLIArgsMadeEasy.
  • Rapidly change startup project’s command line arguments in toolbar.
  • Saves command arguments history per user per machine.
  • Open console window in working directory or project’s directory (if there’s no working directory set).
  • Easily set a new startup project in the toolbar.

Screen shot:

cliargs

Changelog:

  • v1.3 – fixed bug that prevented resizing the CLIArgs input box.
  • v1.2 – added new combo box to easily choose a new startup project.
  • v1.1 – fixed bug parsing solutions with projects inside project folders.

Note: to resize the add-in input boxes you can click on the toolbar options button on the right and choose: “Add or Remove Buttons”->“Customize”. Then select the input box you want to change and choose “Modify Selection” and set the width as you like.

Known limitations:

  • Doesn’t work with XBox 360 projects.

I’d really appreciate if someone could give me a hand to solve this problem since I don’t have access to the XBox 360 SDK.

If you notice any slow downs or other problems because of CLIArgsMadeEasy 2010, let me know.

If you like this add-in and want to support it, donate by clicking in the button:

Download

You can download CLIArgsMadeEasy2010 v1.3 here. (for Visual Studio 2010)

ATTENTION: There is a known bug in CLIArgsMadeEasy2012. If you want the add-in to work properly, please make sure that it is visible in the Visual Studio’s toolbar BEFORE you open a solution, otherwise the add-in won’t behave like it should. This bug doesn’t impact your IDE experience. I’m currently working on a fix but it will take me some time to get it 100%. In the meanwhile you can use the version below.
You can download CLIArgsMadeEasy2012 v1.0 RC2 here. (for Visual Studio 2012)

Many thanks to Diogo Teixeira (aka fozi) for the add-in idea and testing of the program. And I also have to thank Matt Phillips for showing interest in the add-in which inspired me to make this second release.
Thanks to everyone who’s been reporting bugs and helping me building a stable version of CLIArgsMadeEasy.

VSX: How to detect when Property Pages (Project Properties) window is closed

I posted a thread on the MSDN forums to seek for help in detecting when the property pages window (accessible through project->properties) in Visual Studio is closed. You can follow up the thread here: Detect when project properties window is closed. Ziwei Chen was really helpful and could find me a way to achieve this in C# projects but to my surprise, to achieve the same results for C++ projects proved to be harder than I thought.

I decided to write this short tutorial to help those who have the same problem in future.

First of we need to detect when the user click in any project->properties menu selection. Put this code where you initialize your add-in:

m_commandEventsAfterExecuteProperties1 =
    m_applicationObject.DTE.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 396);
m_commandEventsAfterExecuteProperties1.AfterExecute +=
    new _dispCommandEvents_AfterExecuteEventHandler(CommandEvents_AfterExecuteProperties);

m_commandEventsAfterExecuteProperties2 =
    m_applicationObject.DTE.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 397);
m_commandEventsAfterExecuteProperties2.AfterExecute +=
    new _dispCommandEvents_AfterExecuteEventHandler(CommandEvents_AfterExecuteProperties);

These command events ids were found using the technique described in this post: How to find Visual Studio command bars. When registering the event handlers be careful with this: Visual Studio .NET events being disconnected from add-in. So declare these as member attributes and not as method variables:

private CommandEvents m_commandEventsAfterExecuteProperties1;
private CommandEvents m_commandEventsAfterExecuteProperties2;

Now, lets dig into some rather awful code to get our property pages handle. Property pages in .NET projects are document windows but, unfortunately, if we try to call the ActiveDocument property directly through the ActiveEnvDTE library, it will throw an exception. So, with the precious help of Chen, this is the code came up with:

// For C# projects the property pages is a document window, lets try to find it.
// I was unable to get a handle using the EnvDTE library which could have eased things a bit.
bool propertyPagesFound = false;

IVsWindowFrame[] frames = new IVsWindowFrame[1];
uint numFrames;

IEnumWindowFrames ppenum;
m_uiShell.GetDocumentWindowEnum(out ppenum);

while (ppenum.Next(1, frames, out numFrames) == VSConstants.S_OK && numFrames == 1)
{
	m_frame = frames[0] as IVsWindowFrame;
	object title;
	m_frame.GetProperty((int)__VSFPROPID.VSFPROPID_Caption, out title);

	// I really don't like the way I'm using to retrieve the property pages handle.
	//TODO: CHANGE IF BETTER SOLUTION IS FOUND.
	if ((title as String).ToLowerInvariant() == GetStartupProject().Name.ToLowerInvariant())
	{
		propertyPagesFound = true;
		((IVsWindowFrame2)m_frame).Advise(this, out m_cookieWindowFrameNotify);
	}
}

First, all document windows are retrieved to the ppenum variable and next we go one by one and test its caption name to see if it’s equal to the project’s name. After we got our desired window frame we register the IVsWindowNotifyFrame event handler.

In the C++ case, things are a bit different. The property pages window isn’t an instance of document or frame, it’s a dialog window. To catch the dialog window events we use an auxiliary class that listens for the destroy message in the WndProc method.

// If we didn't find any property pages before then we need to go and search for a C++ one since they're
// different from C# property pages.
if (!propertyPagesFound)
{
	//NOTE: This might not work well if we happen to have two Visual Studio instances with the same
	//      project names.
	//TODO: TRY TO FIND A WAY TO FIX IT.
	//HACK: Go through all windows to find the project properties dialog window that matters.
	FindWindowLike.Window[] list =
	    FindWindowLike.Find(IntPtr.Zero, GetStartupProject().Name.ToLowerInvariant() + " property pages", "");
	
	// Release any handle we might have.
	if (m_subclassedMainWindow != null)
	{
		m_subclassedMainWindow.ReleaseHandle();
		m_subclassedMainWindow = null;
	}

	if (m_subclassedMainWindow == null && list != null && list.Length >= 1)
	{
		m_subclassedMainWindow = new SubclassedWindow(list[0].Handle);
	}
}

Apart from that FindWindowLike that we’ll check later, I think the code is pretty simple to understand. I really don’t like to have to search through all windows in the system but apparently the dialog window couldn’t be found under the dte’s MainWindow.HWnd hierarchy.

 

As for the event implementations, here is the C# first:

public int OnShow(int fShow)
{
	switch (fShow)
	{
		case (int)__FRAMESHOW.FRAMESHOW_TabDeactivated:
			// Property pages lost focus, put your code here!
			((IVsWindowFrame2)m_frame).Unadvise(m_cookieWindowFrameNotify);
			m_cookieWindowFrameNotify = 0;
			break;

		default:
			break;

	}

	return VSConstants.S_OK;
}

We need to implement the IVsWindowFrameNotify interface and in the OnShow you can check when the tab is closed. I used the FRAMESHOW_TabDeactivated because it is called when the tab loses focus and also when the tab closes.

Now for the C++ version:

/// 
/// Auxiliary window to intercept messages sent to the property pages dialog window.
/// 
public class SubclassedWindow : NativeWindow
{
	private const int WM_NCDESTROY = 0x0082;

	public SubclassedWindow(IntPtr hWnd)
	{
		AssignHandle(hWnd);
	}

	protected override void WndProc(ref Message m)
	{
		if (m.Msg == WM_NCDESTROY)
		{
			// Property pages window was closed, put your code here!
		}
		base.WndProc(ref m);
	}
}

As explained before, in this case we have an auxiliary window to catch the destroy event for the dialog window.

I found this script over at FindWindowLike for C# and changed it a bit to fit my needs. I modified the code that compared the window title; created a new class and changed p/invoke methods’ signature just to keep VS quiet about some warnings.

/// <summary>
/// Now we have to declare p/invoke methods in a class called NativeMethods (or similar) to
/// shut up some VS warnings.
/// </summary>
internal static class NativeMethods
{
	[DllImport("user32")]
	internal static extern IntPtr GetWindow(IntPtr hwnd, int wCmd);

	[DllImport("user32")]
	internal static extern IntPtr GetDesktopWindow();

	[DllImport("user32", EntryPoint = "GetWindowLongW")]
	internal static extern int GetWindowLong(IntPtr hwnd, int nIndex);

	[DllImport("user32")]
	internal static extern IntPtr GetParent(IntPtr hwnd);

	[DllImport("user32", EntryPoint = "GetClassNameW", CharSet = CharSet.Unicode)]
	internal static extern int GetClassName(IntPtr hWnd, [Out] StringBuilder lpClassName, int nMaxCount);

	[DllImport("user32", EntryPoint = "GetWindowTextW", CharSet = CharSet.Unicode)]
	internal static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount);
}

// FROM: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_21611201.html
// Just changed the way it checked strings.
internal class FindWindowLike
{
	internal class Window
	{
		public string Title;
		public string Class;
		public IntPtr Handle;
	}

	private const int GWL_ID = (-12);
	private const int GW_HWNDNEXT = 2;
	private const int GW_CHILD = 5;

	public static Window[] Find(IntPtr hwndStart, string findText, string findClassName)
	{
		ArrayList windows = DoSearch(hwndStart, findText, findClassName);

		return (Window[])windows.ToArray(typeof(Window));

	} //Find


	private static ArrayList DoSearch(IntPtr hwndStart, string findText, string findClassName)
	{
		ArrayList list = new ArrayList();

		if (hwndStart == IntPtr.Zero)
			hwndStart = NativeMethods.GetDesktopWindow();

		IntPtr hwnd = NativeMethods.GetWindow(hwndStart, GW_CHILD);
		while (hwnd != IntPtr.Zero)
		{
			// Recursively search for child windows.
			list.AddRange(DoSearch(hwnd, findText, findClassName));

			StringBuilder text = new StringBuilder(255);
			int rtn = NativeMethods.GetWindowText(hwnd, text, 255);
			string windowText = text.ToString();
			windowText = windowText.Substring(0, rtn);

			StringBuilder cls = new StringBuilder(255);
			rtn = NativeMethods.GetClassName(hwnd, cls, 255);
			string className = cls.ToString();
			className = className.Substring(0, rtn);

			if (NativeMethods.GetParent(hwnd) != IntPtr.Zero)
				rtn = NativeMethods.GetWindowLong(hwnd, GWL_ID);

			if (windowText.Length > 0 &&
				windowText.ToUpperInvariant().Contains(findText.ToUpperInvariant()) &&
				(className.Length == 0 ||
					className.ToUpperInvariant().Contains(findClassName.ToUpperInvariant())))
			{
				Window currentWindow = new Window();

				currentWindow.Title = windowText;
				currentWindow.Class = className;
				currentWindow.Handle = hwnd;

				list.Add(currentWindow);
			}

			hwnd = NativeMethods.GetWindow(hwnd, GW_HWNDNEXT);
		}

		return list;
	} //DoSearch
} //Class

And that’s it! I’d really appreciate if someone could tell me how to improve some of this code, mostly the parts where I have TODOs and/or HACK.
Thank you and I hope you find this useful!

Thanks to:

I wanted to thank Ziwei Chen for the excellent help at the forums.

References

VSSDK IDE Sample: Combo Box
Detect when project properties window is closed
I need FindWindowLike for C#
How to find Visual Studio command bars
Visual Studio .NET events being disconnected from add-in

Links:

Visual Studio Extensibility Forum
VSX Home on Code Gallery
Visual Studio on MSDN

CLI Args Made Easy

Find the new CLIArgsMadeEasy version here.

Summary

Visual Studio Add-in that puts the project’s command line arguments more accessible.

Description:

Command Line Arguments Made Easy (CLIArgsMadeEasy) is a Visual Studio Add-in that eases the access and change of the startup project’s command line arguments. Instead of having to go to project properties or instead of using the command window to run your program with different arguments, CLIArgsMadeEasy adds a field in the toolbar for you to edit and saves everything you enter. A button is also added that opens a console window in the project’s working directory or home directory (if there’s no working directory set for this project).

Features:

  • Rapidly change startup project’s command line arguments in toolbar.
  • Current session command arguments history.
  • Open console window in working directory or project’s directory (if there’s no working directory set).

Screenshot:

cliargscliargs_options

Future:

  • Support keyboard shortcuts.
  • Save command line arguments history per startup project and between VS sessions.
  • Support for multiple startup projects.

Known limitations:

  • The commands that you insert in the combo box will not do anything if you remove the focus from the combo with a mouse click on any other place. For some reason that I do not understand, when you use the mouse to change the focus, the value that is sent to the event handler is the old value that was in the box, not the new one that the user inserted. So, if you want to change the focus using a mouse click, make sure that you press the enter key in the combo box first.
  • Visual Studio’s extensibility API doesn’t provide an easy way to get a reference to a startup project, so we have to parse the solution which takes some time.
  • Since Visual Studio’s extensibility API doesn’t provide a way to catch any “startup project has change” event, there’s a timer that from time to time checks if there was any change.

I’d really appreciate if someone could give me some tips on how to solve any of these problems.

If you notice any slow downs because of CLIArgsMadeEasy, let me know.

If you like this add-in and want to support it, donate by clicking in the button:

CLIArgsMadeEasy is a free add-in, use it at your own risk. The authors can not be held responsible if anything wrong happens when using this add-in.

Download

You can download CLIArgsMadeEasy 1.0 Beta here.

Many thanks to Diogo Teixeira (aka fozi) for the add-in idea and testing of the program.

VS File Finder 2008

Summary

Visual Studio Add-in that eases the access to files in large projects.

Description

Visual Studio File Finder 2008 (VSFF2008) is an add-in based on VSFileFinder 2005 developed by Jonathan Payne.

This add-in allow you to find files easily in large projects. The files are listed in a new window where you can type a few letters to narrow the list and open the file(s) you’re interested.

It decreases considerably the file access time comparing to Solution Explorer where you may have to scroll and possibly open some “folders” to find the files.

There are some options to configure this add-in: exclude or highlight different files, tooltips’ configuration, project filter and regular expressions.

Many of these improvement ideas came from Diogo. Some of these were already integrated with the official 1.3 version. This is an updated version with support for Visual Studio 2008.

Changes from original version

  • Added wildcards and regular expression support to search. (Wildcards are on by default.)
  • Added a project filter.
  • It is possible to turn on/off, add a timeout or show tooltips with the complete name of the file.
  • Fixed possible bug in tooltips that don’t go away.

Screen shot

vsffvsff_options

VSFileFinder 2008 is a free add-in, use it at your own risk. The authors can not be held responsible if anything wrong happens when using this add-in.

Download

You can download VSFileFinder2008 1.4 Unofficial here.

To download the original version click here.

Again, this add-in was not made by me. I just added some features to the original.

I want to thank Jonathan Payne for the creation of this great add-in and Diogo Teixeira for the suggestions and testing he made.

Visual Studio 2005/2008 Free Utilities

Here are some free add-ins/tools/utilities that you can use in Visual Studio 2005 (or 2008):

AnkhSVN

http://ankhsvn.open.collab.net/
Do you use subversion version control system? TortoiseSVN? This add-in is great and integrates very well with all VS versions since 2002.

CLIArgs Made Easy

http://www.ricardosabino.com/?pag=vs_addin1
CLI Args Made Easy (Command Line Arguments Made Easy) is an add-in that allow you to change the command line arguments of the startup project very easily by adding a combobox in the toolbar. It also saves all the arguments you insert for future use.

Microsoft Visual Studio 2005 IDE Enhancements

http://www.microsoft.com/downloads/details.aspx?FamilyID=CD7C6E48-E41B-48E3-881E-A0E6E97F9534&displaylang=en
Set of Visual Studio extensions that improve productivity: Source code outliner, Visual C++ code snippets, indexed find, super diff utility, event toaster utility.

MPCL

http://www.todobits.es/mpcl.html
This plug-in allow us to compile the source code files of a Visual Studio 2005 project in parallel. This is extremely useful for processors with more than one core to reduce the compile time.

Power Toys for Visual Studio 2005

http://msdn2.microsoft.com/en-us/vstudio/aa718340.aspx
Pack with various tools for VS 2005.

Project Line Counter

http://www.wndtabs.com/download/Download/LineCounter/
Reports statistics about the files in projects. It’s automatic, has a filter and you can check its source code.

Refactor! For Visual Studio 2005/2008

http://msdn2.microsoft.com/en-us/visualc/bb737896.aspx
Free add-in that refactors (simplifies and re-structures) source code to make it easier to read and less costly to maintain.It has more than 15 different features.

RockScroll

http://www.hanselman.com/blog/IntroducingRockScroll.aspx
This add-in extends the Visual Studio’s scroll bar showing the code with syntax highlight. It is extremely useful to go to where you want within long source code files.

SlickEdit Gadgets

http://www.slickedit.com/content/view/441
Free useful gadgets for VS 2005: Editor gadgets – line ruler, indentation guide, auto-copy selection, editor graphic; command spy, file explorer, data object analyzer and SLOC report.

VSFileFinder 2005/2008

http://www.zero-one-zero.com/vs/
VSFileFinder helps you find files quickly in your projects by typing a few letters from any part of the file name which is much faster than using the solution explorer in large projects.

There is also a version with some improvements (wildcards, regular expressions, personalized tooltips, project filter) and compatible with Visual Studio 2008 available here: VSFileFinder2008.

Visual Studio Add-Ins Every Developer Should Download Now

http://msdn.microsoft.com/msdnmag/issues/05/12/VisualStudioAddins/
MSDN page with a collection of free add-ins mostly for .net languages but not only.