This project is read-only.
1
Vote

EventSource Implenting interface breaks OOP

description

When an event source class implements a contract where the event methods are defined by the interface, out-of-process event sinks do not function properly.

811 event "An out-of-band event notification was received from an event source not defined in the block. For example, the sampling parameters were invalid." events are generated instead.

Not being able to implement interface contracts blocks SOLID principles.
Also preventing mocking and dependency injection by interface.


This code snippet can be dropped into LinqPad for a quick review. Uncommenting the method in the interface causes the break. With just a single method this causes and Index Out of Range Exception.
void Main()
{
    TestEventSource.Log.Hello("Hey there!");
}

public interface IBroken
{   
    //void Hello(string message);
}

[EventSource(Name = "Test2")]
public class TestEventSource : EventSource, IBroken
{
    public readonly static TestEventSource Log = new TestEventSource();
    private TestEventSource() {}
    
    [Event(1, Message = "Event said, \"{0}\"", Level = EventLevel.Informational, Version = 3)]
    public void Hello(string message)
    {
        WriteEvent(1, message);
    }
}

comments

bennage wrote Jan 24, 2015 at 1:52 AM

Yeah, avoid concrete depedencies on an event source is something that we've been discussing. We are planning a major update/design in a few weeks. We'd love to have this kind of input.