alefranz / MELT

MELT is a free, open source, testing library for the .NET Standard Microsoft Extensions Logging library. It is a solution to easily test logs.
Apache License 2.0
74 stars 5 forks source link

Created a CurrentScope property in TeskSink and a FullScope property in LogEntry to track the scopes as entries are made. #25

Closed wainwrightmark closed 3 years ago

wainwrightmark commented 3 years ago

This is my proposed fix for https://github.com/alefranz/MELT/issues/24

This uses an immutable stack on the TestSink to keep track of the current scopes.

I left the original scope infrastructure intact (but added an attribute in some places) for compatibility.

I've added tests to test the behaviour I was interested in. I've also handled the case of closing scopes in the wrong order, I decided to close all inner scopes and not throw an exception but we could make this behaviour configurable.

I hope this is okay.

Mark

alefranz commented 3 years ago

Regarding the failure of the format build step, you can use dotnet format to automatically fix the highlighted errors.

wainwrightmark commented 3 years ago

Hi Mark,

apologies for the delay. I've left some comments inline, let me know what do you think. I am not trying to drag the PR for too long, I just want to make sure we get a sensible core design. Once we find an agreement on that (I'm happy to be convinced that the current solution is the good one), then I would be happy to merge it and eventually refine later.

Thank you, Alessio

No worries. I'm willing to take as long as is necessary to get it right.

alefranz commented 3 years ago

Hi Mark,

I've decided to merge this as is, we can still refine it before release.

Thank you for the contribution! :)