Reflecting on Interface Inheritance
The other day I was working on an interceptor that listened to calls to some Services and redirected the calls to services hosted on remote machine, instead of running it locally when strangest thing happened. I was trying to find and invoke existing methods on my interface that according to reflection, were not there. Those services were using inherited interface:
public interface IServiceBase<T>
I was trying to get methods of ICustomerSerivce defined and inherited from the base interface:
Unfortunately, this fails! It seems reflection does not work consistently on inherited interfaces. To solve this, you’d have all the base methods redefined, which becomes very nasty if you have multiple interface inheritances, or if you extensively use generics on interface level. So changing the above code to this will make the test go green:
public interface ICustomerService : IServiceBase<Customer>
I still don’t know why this behavior, or maybe this is a known issue?
Update: Found out that the behavior in fact is inline with ECMA CLI specifications. You can however check the methods on Interface’s other interfaces. See a solution here