I was looking at some code in reflector today and I noticed something interesting. I saw the use of some methodof keyword.
Expression in C#
Expression<Action<int>> expression = (value) => DoSomething(value);
Expression in Reflector
Expression<Action<int>> expression = Expression.Lambda<Action<int>>(Expression.Call(null, (MethodInfo)
methodof (SemiDomainMapper.DoSomething), new Expression[] { CS$0$0001 = Expression.Parameter(typeof(int), "value") }), new ParameterExpression[] { CS$0$0001 });
Expression in IL
L_003a: ldtoken int32
L_003f: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
L_0044: ldstr "value"
L_0049: call class [System.Core]System.Linq.Expressions.ParameterExpression [System.Core]System.Linq.Expressions.Expression::Parameter(class [mscorlib]System.Type, string)
L_004e: stloc.s CS$0$0001
L_0050: ldnull
L_0051: ldtoken void EnvironmentSyncService.SemiDomainMapper::DoSomething(int32)
L_0056: call class [mscorlib]System.Reflection.MethodBase [mscorlib]System.Reflection.MethodBase::GetMethodFromHandle(valuetype [mscorlib]System.RuntimeMethodHandle)
L_005b: castclass [mscorlib]System.Reflection.MethodInfo
Looks like reflector thinks when we use ldtoken followed by a GetMethodFromHandle we are using the methodof keyword? As far as I know there is no way to do this from C# code?