title: Creating delegates dynamically with parameter names
body: <p>Hi I'm trying to create a function that dynamically creates a delegate with the same return value and the same parameters as a MethodInfo it receives as parameter and also and this is very important the same parameter names!</p>
  
  <p>What I did so far is create a function that returns a lambda that receives the same parameter types and has the same return value as the MethodInfo but it doesn't have the parameter names:</p>
  
  <pre><code>    static void Example()
      {
          Person adam = new Person();
          MethodInfo method = typeof(Person).GetMethod("Jump");
          Delegate result = CreateDelegate(adam, method);
          result.DynamicInvoke((uint)4, "Yeahaa");
      }
  
      private static Delegate CreateDelegate(object instance, MethodInfo method)
      {
          var parametersInfo = method.GetParameters();
          Expression[] expArgs = new Expression[parametersInfo.Length];
          List&lt;ParameterExpression&gt; lstParamExpressions = new List&lt;ParameterExpression&gt;();
          for (int i = 0; i &lt; expArgs.Length; i++)
          {
              expArgs[i] = Expression.Parameter(parametersInfo[i].ParameterType, parametersInfo[i].Name);
              lstParamExpressions.Add((ParameterExpression)expArgs[i]);
          }
  
          MethodCallExpression callExpression = Expression.Call(Expression.Constant(instance), method, expArgs);
          LambdaExpression lambdaExpression = Expression.Lambda(callExpression, lstParamExpressions);
  
          return lambdaExpression.Compile();
      }
  
      private class Person
      {
          public void Jump(uint height, string cheer)
          {
              Console.WriteLine("Person jumped " + height + " "+ cheer);
          }
      }
  </code></pre>
  
  <p>Does anyone have any suggestions how I can do that?
  To make it clear, the reason I care about the parameter names is so I would be able to activate the delegate with the parameter names, so I could call it like this (cheer="YAY!', height=3)
  (My application is integrated with Python that's how I'll be able to do it without DynamicInvoke and this is also the reason why the parameter names are so important 
  and also why I wrote '=' and not ':')</p>