.NET Reflector in Visual Studio 2012

Visual Studio 2012 is slated to ship soon, and when it does, Reflector will be sim-shipping right there alongside it. As part of our work to support the newest technologies from Microsoft (C# 5, WinRT, .NET 4.5) we’ve been working on Visual Studio 2012 integration and the new theming styles.

Nigel, our developer who’s been doing most of this UI coding, tells us a bit more about the work involved and how he did it:

When anything like Windows 8 or Visual Studio 2012 is released you can guarantee someone at Red Gate will have the .iso image downloaded and installed on a VM as quick as they can. Because a major part of .NET Reflector is the Visual Studio integration, our testers were instantly all over this and complaining that our extension didn’t work. So we had to fix that pretty fast.

Just getting Reflector running inside VS2012 wasn’t hard – a tweak to the .vxismanifest and the code that installed it, so it recognises the new version and we were away. But we wanted more than that. Sure, it could be installed, and pretty much worked – but it looked awful. With the cool new theming system in VS, a white background when everything else is dark just looked terrible. So we had to do something about it and get on board with the themes.

If you were writing UI for VS from scratch you’d use WPF. However the .NET Reflector extension (for the most part) uses Winforms components that are already used in the desktop version. We have a little WPF skinning in places already, but the main tree view would essentially need re-writing. This is on the cards, in fact, but not for a V7.x release. Luckily, Microsoft had produced a whole document on theming guidelines so I printed that off and sat down with an espresso (actually a double, or maybe 2 doubles).

It turns out there’s a handy API for getting the colors out, and a hook so you know when the theme has changed. So it was going to be a matter of just getting those and poking them into the right place. The harder part was that I only had VS2010 (and 2008) installed on my machine, and I don’t usually install pre-release versions of VS right away. With VMs this is an easy fix, except I still need it to compile on my machine, and the build server – which I would be even less happy to install pre-release versions on!

But because the new APIs are COM based this also wasn’t a problem. On a VM I installed VS and the VS SDK, and then I could look up the types and have it generate the C# COM style interfaces – eg:


	[Guid("2B70EA30-51F2-48BB-ABA8-051946A37283")]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	public interface IVsUIShell5 {
	... 
		}

Once I’d put all these into the code, then in VS I can look for the interface implementor, and if it’s not there then we carry on as before. In fact, this acts as a useful switch as to whether we should change the theme or just carry on with what we had. In the code I subclassed the tree we have in .NET Reflector Desktop to make a ThemedAssemblyTree, and this gets passed a newly invented IThemer which it can use to get the colours and also be notified when the theme changes.

So it was all pretty easy in the end, and it seems to work!

Reflector in Visual Studio 2012


Reflector 7.6 in Visual Studio 2012

The next version of Reflector will ship with our Visual Studio 2012 integration (in fact, you can check it out in our latest EAP), and we’ll continue to work on improving the experience. If you want to try VS2012 right away, the release candidate is available now.

One thought on “.NET Reflector in Visual Studio 2012

  1. Pingback: Dew Drop – July 25, 2012 (#1,371) | Alvin Ashcraft's Morning Dew

Leave a Reply

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