You can make it much more simple. Instead of calling
MethodBase.GetCurrentMethod, use Cecil to inject a:

ldtoken methodDef
call MethodBase::GetMethodFromHandle

like it do it here:

http://evain.net/blog/articles/2010/05/05/parameterof-propertyof-methodof

On Wed, Nov 24, 2010 at 5:08 PM, Jeff Nevins <[email protected]> wrote:
> Hi,
>
> I have a method that's called many many times and needs to pass the
> currently executing method into an "interceptor". I was doing
> MethodBase.GetCurrentMethod(), but that has a significant performance
> impact, so I was thinking to store the MethodInfo as static field and
> just ldfld inside the MethodDefinition I'm rewriting.
>
> Is there a way I can get from a MethodDefinition to a MethodInfo that
> I want to store in my static field?
>
> Let me know if I'm being unclear.
>
> Thanks in advance.
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to