c# - What is DiscardableAttribute used for? -


i can not find practical use of system.runtime.compilerservices.discardableattribute, prototype compiler. insight? thanks.

to give more specific example documentation says - have language supports inlining of static method calls marked using special modifier (from static class):

static class bar {   static inline void foo(int a) { // note fictional 'inline' modifier     return + 10;   } } 

if have class this, isn't referenced other piece of code. when write:

int y = bar.foo(x); 

the compiler compiles as:

int y = x + 10; 

you need keep definition of bar in compiled code, because if reference assembly other project, want see (and when call foo method, compiler take compiled il assembly).

however, class bar never used @ runtime (it there keep code, not execute it). imagine mark discardable , jit possibly skip when generating native code assembly (because class never used).


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -