Re: Reflection on Interfaces and inherited members

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Niall wrote:

I suspect this is somehow the by design behaviour rather than a bug. But I'm
trying to understand the reason why the behaviour should differ between
interfaces and classes in this way.

As per my previous message, I suspect it has to do with the nature of
interface inheritance. A derived interface doesn't act like a flat set
of methods and properties; it acts like a collection of methods and
properties and interfaces. You can see this in the implementation
behavior (where you have to implement IBase.Foo, not IDerived.Foo) and
you're seeing this in Reflection.

Why? I don't really know - but I guess it's at least partly
implementation driven. Each interface is its own vtable and possibly
(as in, I haven't looked, and [sorry!] don't have the time to look
this morning) ancestral interfaces are implemented as pointers to the
ancestral vtable, not as spaces within the derived vtable. This would
save space, ay some slight runtime cost.

--

<http://www.midnightbeach.com> Contracting, consulting, training
..NET 2.0 for Delphi Programmers <http://www.midnightbeach.com/.net>
In production - in stores by June
.



Relevant Pages