I chased this up with one the devs on the JIT team. He confirmed that the 
JIT/NGEN doesn't give this guarantee, both inlining and tail calls can cause 
Assembly.GetExecutingAssembly, Assembly.GetCallingAssembly and 
Method.GetCurrentMethod to return incorrect results. You can somewhat mitigate 
that by marking your method with NoInlining (to prevent inlining) and 
NoOptimization (to prevent the JIT spitting out tail calls)[1], however, it is 
still possible for this to return incorrect results in certain other situations.

http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions.aspx

-----Original Message-----
From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of David Kean
Sent: Tuesday, March 22, 2011 10:06 PM
To: ozDotNet
Subject: RE: Raising property changed events

Hmm, I'll check internally, but I'd be surprised if we give that guarantee. 
We're free to change our inlining policy at any time, in fact, we did just that 
in 3.5 SP1 x64 which broke a lot of customers who were relying on 
Assembly.GetExecutingAssembly() without explicitly turning off inlining for the 
method.

Whether you can repro something now, is not a good indication of whether we'll 
continue to support in a future service pack or version - always check  the 
docs. However, in saying that, the docs don't really make it clear that this 
might not work correctly in certain situations. In which case, if we don't give 
the above guarantee I'll make sure they call it out.

-----Original Message-----
From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of Mark Hurd
Sent: Tuesday, March 22, 2011 9:36 PM
To: ozDotNet
Subject: Re: Raising property changed events

On 23 March 2011 15:00, Mark Hurd <markeh...@gmail.com> wrote:
> I believe it was in this mailing list that we previously confirmed 
> using GetCurrentMethod, even when included in convoluted ways, 
> guarantees the method will not be inlined.

Gmail says GetCurrentMethod has /not/ been mentioned before on this mailing 
list since I've been part of it, so I'm remembering that wrong.

> Can you show an example where GetCurrentMethod does not return the 
> expected method?

This request still stands however.
--
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)


Reply via email to