Reflector is a disassembler for .Net provided by the lovely people at Redgate. It’s so good that it seems almost magical in its power. Previously if I wanted to poke around in a dll then I’d use MSIL disassembler (ildasm.exe) and then feel all manly that I was interfacing directly with the intermediate language code. Since I was feeling all scientific I whipped up a quick test class to compare the two.
The test class
using System.Collections.Generic;
using System.Text;
namespace TestProject
{
/// <summary>
/// Test Class
/// </summary>
public class TestClass
{
private int _testInt;
/// <summary>
/// Test Int
/// </summary>
public int TestInt
{
get { return _testInt * 6; }
}
private string _testString;
/// <summary>
/// Test String
/// </summary>
public string TestString
{
get { return _testString; }
set { _testString = value; }
}
/// <summary>
/// Test Class
/// </summary>
public TestClass()
{
_testString = "TechSplurge";
_testInt = 99;
}
/// <summary>
/// Test Method
/// </summary>
/// <param name="maxCount"></param>
/// <returns></returns>
public void TestMethod(int maxCount)
{
for(int i=0;i<maxCount;i++)
{
Console.WriteLine(_testString + i.ToString());
}
Console.WriteLine("End");
}
}
}
With Ildasm
It’s a bit cryptic in there. Let’s look at the manifest

OK I can see namespaces but the rest is mysterious
With Reflector

Wow – the scales have fallen from my eyes and I see real code buried in the dll.
In fairness it’s a little like comparing apples with oranges. Ildasm.exe is for looking at what the code actually does once it’s been compiled - useful when really going for performance tweaks. Reflector is for seeing what the programmer intended and for seeing how on earth that third party dll works.
No comments:
Post a Comment