Reflector has and will continue to be one of the coolest, most useful development tools around. However, when it comes to demystifying .NET framework classes, there is a new game in town.

Here’s a glimpse into what a method in the System.URI .NET framework class looks like using Reflector.

Not bad…but here is what it looks from inside the Visual Studio debugger after configuring it to use the newly available Microsoft symbol server.

Besides actually allowing you to see the control flow in action, manipulate input values, and replay edge case scenarios, this new approach lets you see all of the original developer comments. The ones I’ve looked at so far have tended to add real value to the code reading experience rather than just pointing out the obvious.

Also, since it is derived from the actual source code files rather than a reverse-engineered approximation, the code can serve as a valuable learning tool by showing real-world examples of best practices rather than the 2-3 line fluff usually found in documentation.

Well, ok…the code fragments above are screaming for some “Extract Method” refactorings, but in general I’m guessing the Framework has some instructive examples of how to program given the vast amount of effort and review that goes into the framework classes.

If you haven’t given it a try yet, the setup process to get this working is fairly easy. It simply involves installing a Visual Studio 2008 QFE and changing a couple of debugging configuration options (see Shawn Burke’s post). Within minutes, I was able to F11 into WebClient.DownloadString(). For some reason this just magically worked the first time, but the next day I had to right click on System.dll in the modules window and select “Load Symbols” in order to get it to work.

Below you can see in the Modules window how it shows that the symbols are loaded for System.dll and you can see in the call stack window that I am inside a framework method. If you look in the directory on your local machine that you configure as the symbols location, you’ll also be able to see the downloaded PDB file after you do this step.

Reflector will still hold an esteemed place in my developer toolbox when I need to peek inside all non-framework dll’s or verify the contents of a deployed dll, but I doubt I will use it anymore to spelunk framework dll’s (at least the ones whose symbols have been released).

Update: Although the setup was seamless on my Vista box at home, I haven’t been able to get the QFE to install on my Windows XP laptop yet. I don’t know if this is a common problem or if my machine has some unusual quirk due to the hundreds of utilities I install on it.

Popularity: 10% [?]