c# - Difference in CSC and Roslyn compiler's static lambda expression evaluation? -


consider following example code.

class program {     static void main( string[] args )     {         dosomethingwithaction( =>             {                 console.writeline( "value: {0}", );             } );          console.readline();     }      private static void dosomethingwithaction( action<int> )     {         console.writeline( something.target == null             ? "method static."             : "method not static." );          something( 5 );     } } 

if compile , run code under debug using visual studio 2010 (under csc compiler) print out following result:

method not static. value: 5 

if compile same code in visual studio 2010, time using release settings, following output generated:

method static. value: 5 

now, if execute same code time using visual studio 2015 ctp (under roslyn compiler), following output generated both debug , release settings:

method not static. value: 5 

first, find curious there difference between debug , release versions of vs2010 (csc). why not evaluate static method under debug? also, appears under cases evaluate static when compiled in debug. have production application getting expected static result under debug.

secondly, should roslyn compiler match behavior of csc in particular case?

this deliberate change made roslyn team.

delegates point instance methods faster invoke, roslyn compiles lambdas instance methods when doesn't need to.

see discussion.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -