When compiling a simple anonymous type code like this:
public class Test
{
public static void Main()
{
var my_anonymous = new { Name = "anonymous"};
}
}
The IL code has a Debugger attribute for every generated method of the anonymous type. e.g. for Equals:
.method public hidebysig virtual instance bool
Equals(object 'value') cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
... // rest of IL code
Why does the compiler generate it automatically? I compiled it with Microsoft (R) Visual C# Compiler version 4.6.1055.0, and (if this has any relevance) without using the VS cmd.
Note: There's this answer for removing the attribute (not possible), but I wonder about the "Why?".
Because anonymous type implementation is automatically done by the compiler and there is no point in having the debugger step through the auto generated code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With