serilog-contrib / SerilogSinksInMemory

In-memory sink for Serilog to use for testing
MIT License
53 stars 7 forks source link

.NET Framework Support #7

Closed jasoncastellano closed 4 years ago

jasoncastellano commented 4 years ago

Any chance of updating the projects with .NET Framework 4.5 targets? Would love to use this sink for unit testing, but only targeting .NET Standard is quite limiting.

sandermvanvliet commented 4 years ago

Currently net462 is the minimum target, it was chosen partly because of xUnit support and the fact that AsyncLocal<T> is only supported from net462 onwards.

I have prepared a PR that supports net45 that uses ThreadLocal<T> instead of AsyncLocal<T> which should be sufficient with the caveat that you will need to call Dispose() on the logger to clear the LogEvents collection of the sink.

If you don't do that you will get multiple messages being collected as tests are isolated by assembly (NUnit default) though even with xUnit / MSTest that could cause problems at times.

sandermvanvliet commented 4 years ago

See PR #8

sandermvanvliet commented 4 years ago

@jasoncastellano if you download this zip that contains the preview packages with net45 support. Could you give these a spin and let me know if that works for you?

If it does I'll merge the PR and push the packages.

Serilog.Sinks.InMemory.0.5.0.zip

sandermvanvliet commented 4 years ago

As I've had no response yet I'm closing this issue and the associated PR. Maintaining net45 is a bit tricky and moving forward not something that is going to be sustainable.