Note:
after thinking for another half an hour, the problem for the classesAfter some thought it's clear that there is easily solvable:
public static MethodInfo GetMethod(Type type, string name, Type[] types)
{
while (type != null)
{
var method = type.GetMethod(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, types, null);
if (method != null)
{
return method;
}
type = type.BaseType;
}
return null;
}
This works because C# (andsomething similar in the .NET) uses single inheritanceMicrosoft.VisualBasic
assembly. I simply walk upward (technically this is wrong wrong wrong if I'm importing a VB.NET assembly, because VBsupports late binding.NET uses hide-by-name instead of hide-by-signature It's in Microsoft.VisualBasic.CompilerServices.NewLateBinding
, so a method with the same name but different parameters could shadowit doesn't expose the member you are looking for that is present in a base class)late bounded methods. And for interfaces?