(Action<T>).Name does not return expected values
- by Tomas Lycken
I have the following method (used to generate friendly error messages in unit tests):
protected string MethodName<TTestedType>(Action<TTestedType> call)
{
return string.Format("{0}.{1}", typeof(TTestedType).FullName, call.Method.Name);
}
But when I call it as follows, I don't get the expected results:
var nm = MethodName<MyController>(ctrl => ctrl.Create());
After running this code, nm contains "<Create_CreateShowsView>b__8", and not (as expected) "Create". How should I change the code to obtain the expected result?