tool to view the compiler generated code
c#
Solution
Your question makes no sense, but you're probably looking for Reflector.
EDIT: Now, your question does make sense. You're still looking for Reflector. However, you'll need to set the Optimization to None in options.
It reveals,
private EventHandler<MyEventArgs> MyEvent;
public event EventHandler<MyEventArgs> MyEvent
{
[MethodImpl(MethodImplOptions.Synchronized)] add
{
this.MyEvent = (EventHandler<MyEventArgs>) Delegate.Combine(this.MyEvent, value);
return;
}
[MethodImpl(MethodImplOptions.Synchronized)] remove
{
this.MyEvent = (EventHandler<MyEventArgs>) Delegate.Remove(this.MyEvent, value);
return;
}
}
Problem
Does anybody know tools to view the C# compiler generated code for delegate? I want to verify the following ``` class X { public event D Ev; } ``` Which is compiled to : ``` class X { private D __Ev; // field to hold the delegate public event D Ev { add { lock(this) { __Ev = __Ev + value; } } remove { lock(this) { __Ev = __Ev – value; } } } } ```