Possible Duplicate:
Reflecting over all properties of an interface, including inherited ones?
While trying to receive information about all methods from an interface, I first tried the following:
interface IBaseInterface
{
void SomeMethod();
}
interface ISomeInterface : IBaseInterface {}
Type interfaceType = typeof( ISomeInterface );
BindingFlags allInstanceMembers = BindingFlags.FlattenHierarchy |
BindingFlags.Instance |
BindingFlags.NonPublic |
BindingFlags.Public;
MethodInfo[] methods = interfaceType.GetMethods( allInstanceMembers );
This results in an empty methods array.
I believe the problem is flatten hierarchy doesn't work for interfaces, but I'm not sure. Before attempting an implementation using Type.GetInterfaceMap
it would be nice if someone could confirm, or explain what I'm doing wrong.