@@ -19,10 +19,11 @@ public sealed class InjectableTestOutputSink : IInjectableTestOutputSink
19
19
private const string _defaultTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{Exception}" ;
20
20
21
21
private readonly MessageTemplateTextFormatter _fmt ;
22
- private readonly Channel < LogEvent > _ch = Channel . CreateUnbounded < LogEvent > (
23
- new UnboundedChannelOptions { SingleReader = true , SingleWriter = false , AllowSynchronousContinuations = false } ) ;
22
+
23
+ private readonly Channel < LogEvent > _ch = Channel . CreateUnbounded < LogEvent > ( new UnboundedChannelOptions
24
+ { SingleReader = true , SingleWriter = false , AllowSynchronousContinuations = false } ) ;
25
+
24
26
private readonly Task _readerTask ;
25
- private readonly CancellationTokenSource _cts = new ( ) ;
26
27
27
28
private readonly ReusableStringWriter _sw = new ( ) ;
28
29
@@ -58,7 +59,7 @@ public void Emit(LogEvent logEvent)
58
59
59
60
private async Task ReadLoop ( )
60
61
{
61
- await foreach ( LogEvent evt in _ch . Reader . ReadAllAsync ( _cts . Token ) . ConfigureAwait ( false ) )
62
+ await foreach ( LogEvent evt in _ch . Reader . ReadAllAsync ( ) . ConfigureAwait ( false ) )
62
63
{
63
64
ITestOutputHelper ? helper = _helper ; // volatile read
64
65
@@ -107,17 +108,9 @@ public async ValueTask DisposeAsync()
107
108
// 1) Tell the reader no more items are coming
108
109
_ch . Writer . TryComplete ( ) ;
109
110
110
- try
111
- {
112
- // 2) Let the reader finish formatting & flushing
113
- await _readerTask . ConfigureAwait ( false ) ;
114
- }
115
- finally
116
- {
117
- // 3) Now it’s safe to cancel / dispose
118
- await _cts . CancelAsync ( ) . ConfigureAwait ( false ) ; // optional – keeps teardown symmetric
119
- _cts . Dispose ( ) ;
120
- await _sw . DisposeAsync ( ) . ConfigureAwait ( false ) ;
121
- }
111
+ // 2) Let the reader finish formatting & flushing
112
+ await _readerTask . ConfigureAwait ( false ) ;
113
+
114
+ await _sw . DisposeAsync ( ) . ConfigureAwait ( false ) ;
122
115
}
123
116
}
0 commit comments