samedi 21 juillet 2018

C# - determine if one method would hide another method using reflection

Using C# reflection, given the MethodInfo for a particular method, I need to find a way to determine if another MethodInfo would "hide" that method if implemented on a child class.

Hopefully the approach follows the C# spec as close as possible, but it does not have to be perfect. I think there are a lot of potential considerations - such as generics, Action/Func parameters, ref/out parameters, etc. Or it could be much simpler than I think it might. If the approach is complex, I'd like to be able to determine the reason(s) why a particular target MethodInfo does not hide a given MethodInfo.

If there are already mechanisms built-in to the reflection API for this - even better. Something like this, with exceptions thrown for specific failure scenarios:

boolean HidesMethod(MethodInfo source, MethodInfo target)





Aucun commentaire:

Enregistrer un commentaire