Skip to content

Commit 406068c

Browse files
committed
Simplify null coalescing
1 parent d9c5928 commit 406068c

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

src/bunit.core/TestContextBase.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,7 @@ public abstract class TestContextBase : IDisposable
1313
/// <summary>
1414
/// Gets the renderer used by the test context.
1515
/// </summary>
16-
public ITestRenderer Renderer
17-
{
18-
get
19-
{
20-
if (testRenderer is null)
21-
{
22-
testRenderer = Services.GetRequiredService<ITestRenderer>();
23-
}
24-
25-
return testRenderer;
26-
}
27-
}
16+
public ITestRenderer Renderer => testRenderer ??= Services.GetRequiredService<ITestRenderer>();
2817

2918
/// <summary>
3019
/// Gets the service collection and service provider that is used when a
@@ -90,7 +79,7 @@ protected virtual void Dispose(bool disposing)
9079

9180
// Ignore the async task as GetAwaiter().GetResult() can cause deadlock
9281
// and implementing IAsyncDisposable in TestContext will be a breaking change.
93-
//
82+
//
9483
// NOTE: This has to be called before Services.Dispose().
9584
// If there are IAsyncDisposable services registered, calling Dispose first
9685
// causes the service provider to throw an exception.

0 commit comments

Comments
 (0)