Groups | Blog | Home
all groups > dotnet sdk > april 2005 >

dotnet sdk : Interface Mapping with Metadata API



Reinhard
4/6/2005 6:14:48 AM
I need to find out for class Foo whether a method implements a method
from interface IFoo or not. In case of method Bar() I can use
EnumMethodImpls, but for Baz() there is no MethodImpl entry.

interface IFoo
{
void Bar();
void Baz();
}

class Foo : IFoo {
static void Main() { }
void IFoo.Bar() {} // EnumMethodImpls works
public void Baz() {} // no MethodImpl in Metadata
public void Other() { }
}

Is there any other API in Metadata that can do this? I dont want to
compare Name and Signature manually.
Jon Shemitz
4/6/2005 10:11:17 AM
[quoted text, click to view]

I'm not sure what the question is. If the class supports the
interface, you know it implements all methods in the interface. Do you
mean that you want to know ehether the class implements a particular
method directly, or whether it inherits it?

--

Reinhard
4/6/2005 11:46:24 AM
With API IMetaDataImport::EnumInterfaceImpls I determine that class Foo
implements interface IFoo. Fine. Next thing is, I need to know whether
a particular method of Foo is implementing a method defined by
interface IFoo. In my example Bar() & Baz().

In the case of Bar() which is implemented by *explicitly* specifying
the IFoo.Bar, I can use IMetaDataImport::EnumMethodImpls to see that
CFoo.Bar implements IFoo.Bar. However for methods which do not
explicitly implement the interface (as for Baz()), there is no entry in
MethodImpls. There must be another API to get that information. This is
what I am looking for.

Background: My project is a recorder which uses the Profiling API of
Whidbey to record activiations of methods from a given interface
(filtered by interface). Example: "record all method calls which
implement IComparable".
Reinhard
4/7/2005 12:26:36 AM
Someone emailed me with an answer. I unintentionally deleted this
message from my mailbox. Can you please resend your message?
AddThis Social Bookmark Button