Closed GoogleCodeExporter closed 9 years ago
It looks like a bug, I think that if there was code inside the add/remove
accessors, it would have worked, but maybe because it's empty, SharpKit
confuses it as if it's an automatic event.
Original comment by DanelK...@gmail.com
on 12 Dec 2013 at 12:40
Oh, sorry I wasn't clear, the code I posted above was intended to illustrate a
SSCCE. My real code was trying to wrap a javascript DOM event with my own
event, but I only wanted to attach the event handler to the DOM element if I
actually add an event handler to my custom class. Here's another
less-contrived example that will illustrate the same problem:
private Delegate customEvent;
private bool customEventsAdded;
public event Action CustomEvent
{
add
{
customEvent = Delegate.Combine(customEvent, value);
customEventsAdded = true;
}
remove
{
customEvent = Delegate.Remove(customEvent, value);
}
}
And the compiled result:
add_CustomEvent: function (value)
{
this.CustomEvent = $CombineDelegates(this.CustomEvent, value);
},
remove_CustomEvent: function (value)
{
this.CustomEvent = $RemoveDelegate(this.CustomEvent, value);
}
You'll notice that it's the same generated output, notably omitting the
assignment to my field.
Original comment by kirk.w...@sqor.com
on 14 Dec 2013 at 4:08
Original comment by DanelK...@gmail.com
on 11 Jan 2014 at 7:49
Original issue reported on code.google.com by
kirk.w...@gmail.com
on 9 Dec 2013 at 10:40