How can I create a MethodInfo from an Action delegate

Posted by Michael Meadows on Stack Overflow See other posts from Stack Overflow or by Michael Meadows
Published on 2010-04-05T02:22:40Z Indexed on 2010/04/05 2:33 UTC
Read the original article Hit count: 304

Filed under:
|
|
|

I am trying to develop an NUnit addin that dynamically adds test methods to a suite from an object that contains a list of Action delegates. The problem is that NUnit appears to be leaning heavily on reflection to get the job done. Consequently, it looks like there's no simple way to add my Actions directly to the suite.

I must, instead, add MethodInfo objects. This would normally work, but the Action delegates are anonymous, so I would have to build the types and methods to accomplish this. I need to find an easier way to do this, without resorting to using Emit. Does anyone know how to easily create MethodInfo instances from Action delegates?

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection