reactivemarbles / ObservableEvents

MIT License
122 stars 10 forks source link

Interface events are not available unless type is casted to interface #148

Open harvinders opened 1 year ago

harvinders commented 1 year ago

Imagine I have a type

public IExecutionProgress
{
        event EventHandler<TestExecutionStartedEventArgs> TestExecutionStarting;

        event EventHandler<TestExecutionStartedEventArgs> TestExecutionStarted;

        event EventHandler<TestExecutionCompletedEventArgs> TestExecutionCompleting;

        event EventHandler<TestExecutionCompletedEventArgs> TestExecutionCompleted;
}

public interface ITestExecutor : IExecutionProgress
{
}

public class Runner : ITestExecutor
{
}

Doing something like


var runner = new TestRunner();

runner.Events().TestExecutionStarting.Subscribe(x={}); // Compilation error Events() returns NullEvents

(runner as IExecutionProgress).Events().TestExecutionStarting.Subscribe(x={}); // This works