If you don’t know that tool yet, stop reading and … stop reading … and download it from http://www.aisto.com/roeder/dotnet/. This is a must have for any serious .NET developer.
Actually one of the very first things I do after installing VS.NET 200x is to add it as the first tool under the Tools menu in the IDE.
Title: .NET Reflector
Command: D:\Bits\NET Reflector\Reflector.exe
Initial Directory: $(TargetDir)
I use it all the time to better understand what the C# and the C++/CLI compilers generate and to look at our “own source code”, disassembled. The second one I put down there is ILDasm.
An example from System::Text::StringBuilder::Append:
System::Text::StringBuilder^ Append(System::String^ value)
if (value != nullptr)
System::String^ text1 = this->m_StringValue;
System::IntPtr ptr1 = System::Threading::Thread::InternalGetCurrentThread();
if (this->m_currentThread != ptr1)
text1 = System::String::GetStringForStringBuilder(text1, text1->Capacity);
int num1 = text1->Length;
int num2 = (num1 + value->Length);
if (this->NeedsAllocation(text1, num2))
System::String^ text2 = this->GetNewString(text1, num2);
As soon as this will be ready, he’ll discuss with Lutz to integrate his code into the .NET Reflector. Good times are coming your way. Chapeau Dean!
BTW, I don’t know about you, but I can’t stand this design guideline that says that a nullptr String reference should be treated the same way as a reference to an empty String instance… Open door to hidden bugs if you ask me!