Getting hold of the MethodInfo of a generic method via Reflection (so you can invoke it dynamically, for example) can be a bit of a pain. So this afternoon I formulated a pain-killer, SymbolExtensions.GetMethodInfo. It’s not fussy: it works for non-generic methods too. You use it like this:

internal class SymbolExtensionsTests { [Test] public void GetMethodInfo_should_return_method_info() { var methodInfo = SymbolExtensions.GetMethodInfo<TestClass>(c => c.AMethod()); methodInfo.Name.ShouldEqual("AMethod"); } [Test] public void GetMethodInfo_should_return_method_info_for_generic_method() { var methodInfo = SymbolExtensions.GetMethodInfo<TestClass>(c => c.AGenericMethod(default(int))); methodInfo.Name.ShouldEqual("AGenericMethod"); methodInfo.GetParameters().First().ParameterType.ShouldEqual(typeof(int)); } [Test] public void GetMethodInfo_should_return_method_info_for_static_method_on_static_class() { var methodInfo = SymbolExtensions.GetMethodInfo(() => StaticTestClass.StaticTestMethod()); methodInfo.Name.ShouldEqual("StaticTestMethod"); methodInfo.IsStatic.ShouldBeTrue(); } }

The active ingredient, as you can see, is Lambda expressions: