Skip to content

Commit

Permalink
Simplify null coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Feb 28, 2023
1 parent d9c5928 commit 406068c
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/bunit.core/TestContextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@ public abstract class TestContextBase : IDisposable
/// <summary>
/// Gets the renderer used by the test context.
/// </summary>
public ITestRenderer Renderer
{
get
{
if (testRenderer is null)
{
testRenderer = Services.GetRequiredService<ITestRenderer>();
}

return testRenderer;
}
}
public ITestRenderer Renderer => testRenderer ??= Services.GetRequiredService<ITestRenderer>();

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

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

0 comments on commit 406068c

Please sign in to comment.