Click here to monitor SSC

Bart

Software Engineer - Red Gate Software

.NET Reflector Support: How can I tell which overload of a method is being called in the decompiled source code?

Published Wednesday, August 19, 2009 2:44 PM

Many methods in .NET code are overloaded. For example, the PipeStream method on the StreamPiper class, in figure 1, has four overloads.

Overloads of the PipeStream method on the StreamPiper class.

Figure 1. The .NET Reflector browser, showing overloads of the PipeStream method on the StreamPiper class.

So, when you find one of these methods used in the decompiled source code, how do you know which overload is being called, other than by guessing, perhaps by looking at the number of parameters passed to the method?

Fortunately, this is fairly straightforward: just hover your mouse cursor over the method invocation, and .NET Reflector will pop up a tooltip telling you which overload is being called, as shown in figure 2, below.

Tooltip showing which method overload is being called.

Figure 2. Decompiled source in the Disassembler pane with a tooltip showing which overload of the PipeStream method is being called. This example shows C#, however this also works for other languages.

Occasionally people ask us if we can further annotate invocations to overloaded methods, however there are a couple of problems with this. The first is that, unless we annotated with comments, there would be no chance of the code compiling, which would be a problem if you were trying to recover it. The second follows on from the first: any annotations would seriously interfere with the readability of the generated source code, simply because of the number of overloaded methods in most .NET code.

by Bart Read
Filed Under: , ,

Comments

 

Jason Haley said:

Interesting Finds: August 20, 2009
August 20, 2009 6:40 AM
 

Jason Haley said:

Interesting Finds: August 20, 2009
August 20, 2009 6:45 AM
You need to sign in to comment on this blog

About Bart Read

Bart has done many things since he started work at Red Gate Software Ltd in August 2004, but nowadays he's (mainly) the product manager for the .NET Developer Tools. He still feels like this is a bit like admitting you were cheering for the Empire whilst watching Star Wars, but for now he's along for the ride. In a previous incarnation he was a project manager leading the .NET Reflector Pro, ANTS Memory Profiler 5, ANTS Performance Profiler 4 & 5, and SQL Prompt 3.0 - 3.6 projects. He still occasionally writes some code and, in the past, has touched the code for most of the Red Gate SQL developer tools... some of them still haven't recovered from the shock. He was born and grew up in Dorset, was educated in Nottingham and London, and likes music and real ale. His photo is extremely misleading.
<August 2009>
SuMoTuWeThFrSa
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345
How to Kill a Company in One Step or Save it in Three
 The majority of companies that suffer a major data loss subsequently go out of business. Wesley David... Read more...

Migrating from OCS 2007 R2 to Lync: Part 4
 Having migrated the rest of our users and legacy resources across and started getting ready to... Read more...

Automated Script-generation with Powershell and SMO
 In the first of a series of articles on automating the process of building, modifying and copying SQL... Read more...

Seth Godin: Big in the IT Business
 Seth Godin has transformed our understanding of marketing in IT. He invented the concept of 'permission... Read more...

Using SQL Test Database Unit Testing with TeamCity Continuous Integration
 With database applications, the process of test and integration can be frustratingly slow because so... Read more...