Closed jonwagner closed 10 years ago
This one is a dilemma. Right now, ESP always generates the extra events on interfaces, so you can always do:
var log = EventSourceImplementer.GetEventSource<ISource>();
var proxy = new TracingProxy<ISource>(foo);
The proxy binds to the extra events on the log, since they are always there. You can only define a logger once. If we don't always put them there, then the behavior will depend upon whether the logger is created first or the proxy. That would be bad.
One option would be to generate them on interfaces, but not on abstract EventSource classes (since they would never be needed). I'm not sure if that would be confusing.
The latest code no longer generates complement methods (Completed/Faulted) when implementing a class derived from EventSource. (v2.0.1 and later)
I'll keep thinking on this for a bit.
My suggestion, if you still need to generate the the extra _Completed and _Faulted events for interfaces it to use event IDs from the other side of the integer spectrum (i.e. use IDs counted back from int.Max) or give the user the ability to specify specific IDs for those events (thus letting the user consciously know what IDs are used for what).
I tried Int32.Max, but the EventSource class does this:
_somevariable = new int [MAX(EventID)];
Boom! OutOfMemoryException.
So I'm leaning toward disabling it for EventSource-derived classes (it's not needed), and maybe giving an option to turn it off. Or perhaps leaving it off, and letting people turn it on.
Or more magic. I'm good at magic.
Thanks for the feedback.
I'm going with:
This is in v2.0.1
Jon, ImplementComplementMethods is nullable and the VS 2013 compiler does not allow to set a value for it: Error 1 'ImplementComplementMethods' is not a valid named attribute argument because it is not a valid attribute parameter type
I fixed this in 2.0.2. Hang on...
When ESP generates an EventSource, for each method x, it also generates x_Completed and x_Faulted events. These methods are intended to be used for TracingProxy, so should not be emitted if not creating a proxy.