I'm reflecting over a class (in a unit test of said class) to make sure its members have all the required attributes. To do so, I've constructed a couple of helpers, that take an Expression as an argument. I do some checks for it, and take slightly different actions depending on what type of Expression it is, but it's basically the same.
Now, my problem is that I have several methods with the same name (but different signatures), and the following code throws an AmbiguousMatchException:
// TOnType is a type argument for the type where the method is declared
// mce is the MethodCallExpression
var m = typeof(TOnType).GetMethod(mce.Method.Name);
Now, if I could add an array of Type[] with the types of the arguments to this method as a second parameter to .GetMethod(), the problem would be solved.
But how do I find this Type[] array that I need?
I have cast the Expression<Func<...>> to an Expression, and then to a MethodCallExpression, and in this method the contents of <...> is not known.