Last year, I had the opportunity to have a lunch meeting with Lutz Roeder. I was able to talk with him about life at Microsoft in Redmond, the creation of the Expression suite, and of course, Reflector, the very popular .net class browser, used by every .net programmer that respects himself!
Since a few weeks, the new version of this popular program was released, version 5 that is.
In this article, I’ll discuss some of the new functions and also some of the lesser known functions that were already in previous versions, so you can get the most out of this magnificent tool.
Obtaining the newest version
First, if you haven’t done already, download Reflector here: http://www.aisto.com/roeder/dotnet or if you have an old version installed, you can have it auto-update via the Help menu. There are a great number of extensions available. These are put together on a codeplex site that can be found here: http://www.codeplex.com/reflectoraddins.
Getting started with version 5
One of the very handy new functions is the possibility to register Reflector with Explorer. This way, Reflector will become the default option for your DLL files.
Double-clicking on any .net DLL will open Reflector, and you’ll be able to see the contents of the assembly.
To do this, open a command window, browse to the directory where you have extracted Reflector and run the following command: Reflector /register .You should now get a message that registering went OK, as can be seen on the image below.
If like me, you use Reflector a lot, perhaps on different projects, the list of assemblies in Reflector can become very long. On top of that, the memory use is way higher (I noticed that on my PC, don’t know if this is the case everywhere though) if you have more assemblies loaded in the browser.
There is however a feature that can help solve this annoyance: assembly lists. Press CTRL-L or File à Open List to open the Assembly List Management dialog.
As you can see, I have a number of lists in my window. Each of these corresponds to a list of DLLs that will be displayed in the browser when loaded.
You can create a new list, which is blank by default. In the browser, you can then load assemblies that will only be displayed when that particular list is selected.
Something completely new in version 5 is the so-called “Code URL” support.
Simply select any item in the browser and press Ctrl-Alt-C. This will copy the code-URI for that item in the following format (I selected System.Web.HttpCookie): code://System.Web:220.127.116.11:b03f5f7f11d50a3a/System.Web.HttpCookie.
If you have Reflector installed, clicking the following link in IE will fire up Reflector and immediately browse to the class/method/assembly described in the URL. You can test it with the following link: code://System.Web:18.104.22.168:b03f5f7f11d50a3a/System.Web.HttpCookie.
This feature can also come in handy to pass a link to a colleague, even over MSN!
.net 3.5 support
Even though it is still some months away, Reflector already offers support for .net 3.5. You can enable it via the Options window.
Included in .net 3.5 are C# 3.0 and LINQ. Reflector now includes full support for both of these.
Also, it now offers support for anonymous methods and nullable types.
The new assembly browser
The most important part of Reflector is of course the assembly browser itself. While it was already fast, it didn’t include the possibility to open multiple windows at the same time. That limitation is now gone! For example, you can open the Analyzer and the Disassembler at the same time.
Disassembler and Analyzer
Both the Disassembler and the Analyzer got some new functions in this new release.
The Disassembler now has a “Expand Methods” function, that, like the name says, will expand all functions right in the same window.
The Analyzer, which you can find by right-clicking an assembly, also has some new functions: Exposed by, Instantiated by and Assigned by.
These functions can greatly help you in funding where certain classes are used within the assembly.
While Reflector is great, the extensions available for it make it even greater.
Personally, I do a lot of WPF, and it’s very handy to be able to read the XAML code for things you encounter on the net. For this, we now have the BAML Disassembler. You can read more on this extension here: http://wpfwonderland.wordpress.com/2007/01/27/reflector-and-wpf-baml-disassembler-revisited/