Reflect on Method's Implementation

G

Guest

Is it possible to use reflection to look at a method's implementation?

I would like to know which other methods the method in question might call.

Any quick pointers to references appreciated.

Thanks

-Andrew
 
M

Mattias Sjögren

Is it possible to use reflection to look at a method's implementation?

In v2.0 of the framework yes, in earlier versions no.


Mattias
 
R

Richard Grimes

Andrew said:
Is it possible to use reflection to look at a method's implementation?

I would like to know which other methods the method in question might
call.

Any quick pointers to references appreciated.

As others have said, in 1.1 it is not possible with th framework, but in
..NET 2.0 it is possible with the MethodBody class.

In 1.1 I have done it with the unmanaged metadata API in unmanaged code.
It is possible to call that API through platform invoke, but it would be
messy.

The reason why I wanted to get the methods called by methods was because
I wanted to see whether the .NET framework library is a mere wrapper
around Win32 and get an idea of how this changes with .NET version.

So I measured how many methods there are, how many method calls are made
to managed code in the assembly and managed code in another assembly,
how many are through platform invoke, how many are made to COM objects
and how many method calls are internalcall (which is an unmanaged
implementation provided by the runtime). I have the raw data for various
versions, but I haven't finished analysing it... If you are interested
in the result, watch my home page for an announcement sometime.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top