views:

65

answers:

1

As the question says, I am curious if any of you know about attributes that affect how the CLR will compile/optimize the bytecode. Is there an attribute that will affect code inlining decisions? Unroll loops?

Are there undocumented attributes on classes generated for anonymous types/delegates?

There's probably attributes to disable optimizations for debug purposes, but somehow I am not so interested in those.

+1  A: 

Only one I've used in debugging something:

[MethodImpl(MethodImplOptions.NoInlining)]

This prevents JIT from inlining a method. There's also a:

[MethodImpl(MethodImplOptions.NoOptimization)]

Which just prevents JIT from optimizing anything, in case you found a rare bug in code generation that's actually causing the issue.

Nick Craver
It wasn't exactly the answer I was hoping for... but thanks for the answer!
jdv