Let's say I have two interfaces:
public interface IDeclaring
{
String GetValue();
}
public interface IImplementing : IBase
{
String IDeclaring.GetValue() => "IDerived";
}
I'm writing a library that implements interfaces at runtime and therefore needs to understand which interface methods need implementing, and which are already implemented.
Using reflection, I now have one MethodInfo
per interface, say delcaringMethodInfo
and implementingMethodInfo
but I can't figure out how to get the information that the latter implements the former.
There's MethodInfo.GetBaseDefinition
but that doesn't work on interfaces.
That information must somewhere be present and accessible though.
It would probably be enough to be able to check if the two MethodInfo
s have the same signature, but I don't know how to do that either easily as that's not trivial. I suspect I need to check whether they have the same parameters and parameter modifiers.
Aucun commentaire:
Enregistrer un commentaire