Looking at System.Windows.Threading.Dispatcher (as decompiled by Reflector) I came across;
[field: SecurityCritical]
public event DispatcherUnhandledExceptionFilterEventHandler UnhandledExceptionFilter;
I don't recognize the 'field' part of the attribute declaration, what is it?
Edit:
This is how it appears in the reference source:
public event DispatcherUnhandledExceptionFilterEventHandler UnhandledExceptionFilter
{
[SecurityCritical]
[UIPermissionAttribute(SecurityAction.LinkDemand,Unrestricted=true)]
add
{
_unhandledExceptionFilter += value;
}
[SecurityCritical]
[UIPermissionAttribute(SecurityAction.LinkDemand,Unrestricted=true)]
remove
{
_unhandledExceptionFilter -= value;
}
}
It just means that it's applying the attribute to the delegate that's backing the event, rather than the event itself.
Just like how property syntax is a shorthand, the code
event MyDelegate MyEvent;
is actually shorthand for
MyDelegate _BackingDelegate;
event MyDelegate MyEvent
{
add { lock (this._BackingDelegate) this._BackingDelegate += value; }
remove { lock (this._BackingDelegate) this._BackingDelegate -= value; }
}
IIRC*, and that attributes applies to _BackingDelegate
and not MyEvent
.
*Note: I'm not sure if there is a lock
statement or not, but I think there is.
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