November 17, 2009 Leave a comment
One of the greatest tools for any .NET developer is Reflector. The tool was originally written by Lutz Roeder, but was bought out by Red Gate last year. Red Gate, to date, has left the tool as a free tool. You can download a copy from:
What is Reflector?
Reflector is a tool that reflects over .NET assemblies so you can see how the routines in the assembly work. It is set up so you can navigate from routine to routine by clicking, just like a web page. In addition, there are plenty of add-ins that allow you to do various things with the dissembled assembly. It is my number one tool for .NET.
How do you use it?
Open up Reflector and hit the open button. Find an assembly you wish to “reverse engineer” and then double click it. I am not sure if anything could be simpler.
So Reflector is a hacker tool?
I guess it could be used this way, but only with companies that fail to properly obfuscate their public software. I find three very good uses for Reflector (I am sure there are others):
- I need to reverse engineer a tool we no longer have source for. Generally this is from a former employee who did not understand source control (thus the former in front of employee?).
- I need a better understanding of the .NET shipped assemblies. If you want a good one to start with, look at the ADO.NET assemblies (System.Data, etc). It reveals a lot about how ADO.NET works, underneath the surface.
- I have a bug and need a better picture of what is going on. Yes, I know I can do this in Visual Studio, but Reflector makes it easier, at least for me. Note: I am not talking about debugging.
What all can you do with it?
With the standard install (no plug-ins), you can examine source code one routine at a time and navigate through the source and get a better idea of the flow of code. With add ins, you can do so much more (see add ins below).
What Add ins are available and what do they do?
I do not use all of the add ins, so if there is a feature you need, see if it is available here:
The add ins I use are the following:
- FileDisassembler – This tool allows you to completely reverse engineer an assembly. Unfortunately, this one is a bit out of date, so you have some code cleanup with newer versions of .NET. There is also another add in called FileGenerator that I have not had the opportunity to use. it is a bit newer, but has not been updated since December of 2008.
- CodeMetrics – Although I have other code metric tools, this is useful on assemblies other devs have worked on.
- Review – This is one I recently got into, and I am not sure how really useful it is in my situation. Essentially, this tool allows you to add annotations during a code review and have them tagged to particular routines.
- Diff – A tool to compare two versions of an assembly for changes. You can do the same with source control, but I have found myself having to use this on jobs where people lost their brains (ie, no source control).
- Pex – Do you Pex? No, probably not. But you will in the .NET 4.0 realm (along with code contracts, trust me). Pex is a cool tool from Dev labs (believe it was originally MS Research) that creates white box tests. The most blogged benefit is 100% code coverage, but it sells Pex short, as it looks for fringe conditions. Pex, combined with Code Contracts, will greatly improve the quality of your code. This add allows you to call Pex on your assembly from Reflector. Nuff said. If you want to create unit tests, there is also Doubler.
BTW, Code Contract bits are also available on DevLabs.
- SilverlightLoader and SilverlightBrowser – I have not played with these enough to determine which I would use, if not both. Both focus on loading Silverlight assemblies into Reflector.
- Reflexil – This add in is not for the newbs. It is a very powerful addition that allows you to manipulate IL and save it back to an assembly. This can be as IL or as C# or VB “injected” code. Very powerful, but can also be a bit dangerous. 😉
- ComLoader – This is more of a productivity tool than anything else, as it encapsulates creating the .NET wrapper
Today, I just found out something interesting about Reflector. I copied the tool from my home machine, which has a max screen width of 1920. Did not think much of it until I opened up an assembly in Dissassembler. This is the screenshot:
Where is my list? It turns out this is an issue with the configuration file. The config, looked like this:
I changed the Pane value to “600”, as shown below, and everything is sailing fine now:
Hope you enjoy this.
Peace and Grace,
Miranda’s believe site: http://tinyurl.com/mirandabelieve