Skip to content

Commit 76e2218

Browse files
committed
misc
1 parent 25f2220 commit 76e2218

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/Serilog.Sinks.XUnit.Injectable/InjectableTestOutputSink.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ private async Task ReadLoop(CancellationToken ct)
8989
try
9090
{
9191
await foreach (LogEvent evt in _ch.Reader.ReadAllAsync(ct)
92-
.ConfigureAwait(false))
92+
.ConfigureAwait(false))
9393
{
94-
if (ct.IsCancellationRequested) break;
94+
if (ct.IsCancellationRequested)
95+
break;
9596

9697
ITestOutputHelper? helper = _helper; // volatile read
9798
if (helper is null)
@@ -161,7 +162,8 @@ private void Write(LogEvent evt, ITestOutputHelper helper)
161162

162163
public async ValueTask DisposeAsync()
163164
{
164-
if (!_disposed.TrySetTrue()) return;
165+
if (!_disposed.TrySetTrue())
166+
return;
165167

166168
_helper = null; // stop xUnit calls after this point
167169
_ch.Writer.TryComplete(); // 1) tell reader: no more items
@@ -170,17 +172,17 @@ public async ValueTask DisposeAsync()
170172
{
171173
// 2) give the reader a short window to drain cleanly
172174
await _readerTask.WaitAsync(_drainWait)
173-
.NoSync();
175+
.NoSync();
174176
}
175177
catch (TimeoutException)
176178
{
177179
// 3) fallback: force-break the loop if it didn’t finish
178180
await _cts.CancelAsync()
179-
.NoSync();
181+
.NoSync();
180182
try
181183
{
182184
await _readerTask.WaitAsync(_cancelWait)
183-
.NoSync();
185+
.NoSync();
184186
}
185187
catch
186188
{
@@ -195,7 +197,7 @@ await _readerTask.WaitAsync(_cancelWait)
195197
try
196198
{
197199
await _sw.DisposeAsync()
198-
.NoSync();
200+
.NoSync();
199201
}
200202
catch
201203
{
@@ -206,23 +208,24 @@ await _sw.DisposeAsync()
206208

207209
public void Dispose()
208210
{
209-
if (!_disposed.TrySetTrue()) return;
211+
if (!_disposed.TrySetTrue())
212+
return;
210213

211214
_helper = null;
212215
_ch.Writer.TryComplete();
213216

214217
try
215218
{
216219
_readerTask.GetAwaiter()
217-
.GetResult();
220+
.GetResult();
218221
}
219222
catch
220223
{
221224
_cts.Cancel();
222225
try
223226
{
224227
_readerTask.GetAwaiter()
225-
.GetResult();
228+
.GetResult();
226229
}
227230
catch
228231
{

0 commit comments

Comments
 (0)