How to correctly emit a base.Method() call?

Topics: Metadata Model
Nov 28, 2010 at 8:35 PM

I was using a virtual call to the base class method and a mutable BaseClassReference as "this" instance.

The result is a callvirt to the base class method in CIL that is translated in a this.Method() call in C# by Reflector.

I disassembled a base.Method() call emitted by the C# compiler and it's a plain (non virtual) call to the base class method.

Probably reflector is confused because I mixed things up.

What should be the correct way to write a base.Method() call in with CCI?

Nov 28, 2010 at 9:00 PM

A plain (non virtual call) to the base class method.

In general, think of CCI as an object model over IL and metada. So, once you you've compiled something with whichever language you like, use Reflector (or ildasm) to view and understand the IL. Then work backwards from there.

Nov 28, 2010 at 9:02 PM
Edited Nov 28, 2010 at 10:02 PM

The way seems to be

IsVirtual = false,

MethodToCall = [a reference to the base classe method],

ThisArgument = [this can be a ThisReference or a BaseClassReference, it seems to be irrelevant]


What's the use of BaseClassReference then?



Nov 28, 2010 at 9:30 PM

None, it seems. It is an evolutionary artifact. It needs to be removed. I'll put it on my list of things to do.