I'm writing an extension that I want to use to add some dynamic context to events using the TraceParameterProvider mechanism as outlined on the wiki.
I'd like to unit test this to verify it works. Ideally that would mean creating a TraceParameterProvider that is scoped only to the unit test, attaching that to a generated proxy, capturing a log event, and verifying that the provider added the information desired.
Unfortuantely, I'm finding that to be challenging, if not impossible.
In production, I'll be using the TraceParameterProvider.Default to attach the extension I'm writing. In unit testing, I don't want to corrupt or change the global static state.
I can't create an event source proxy and attach a specific TraceParameterProvider to it. That is, there's no EventSourceImplementer.GetEventSource<ITestLogger>(tpp) method.
I can't execute new TypeImplementer(typeof(ITestLogger), tpp).EventSource as seen in the EventSourceProxy unit tests because that type is internal.
I can't "flush" or "clear" the set of stuff attached to TraceParameterProvider.Default because all the collections where builders and such are registered are all internal, so even if I did change global state and switch to single-threaded testing, I can't reset global state.
The simplest solution would be to make TypeImplementer a public type. Would you be willing to accept a pull request for that one-line change?
I'm writing an extension that I want to use to add some dynamic context to events using the
TraceParameterProvider
mechanism as outlined on the wiki.I'd like to unit test this to verify it works. Ideally that would mean creating a
TraceParameterProvider
that is scoped only to the unit test, attaching that to a generated proxy, capturing a log event, and verifying that the provider added the information desired.Unfortuantely, I'm finding that to be challenging, if not impossible.
In production, I'll be using the
TraceParameterProvider.Default
to attach the extension I'm writing. In unit testing, I don't want to corrupt or change the global static state.TraceParameterProvider
to it. That is, there's noEventSourceImplementer.GetEventSource<ITestLogger>(tpp)
method.new TypeImplementer(typeof(ITestLogger), tpp).EventSource
as seen in the EventSourceProxy unit tests because that type is internal.TraceParameterProvider.Default
because all the collections where builders and such are registered are all internal, so even if I did change global state and switch to single-threaded testing, I can't reset global state.The simplest solution would be to make
TypeImplementer
a public type. Would you be willing to accept a pull request for that one-line change?