From 6766f447a8c2bbc4d6ab2715646d450e4658bd4e Mon Sep 17 00:00:00 2001 From: "Arash A. Sabet" Date: Thu, 29 Aug 2024 21:41:24 -0400 Subject: [PATCH] #264 Some improvements in the code to gain performance and manage garbage collection --- src/Abstracts/TestBedFixture.cs | 3 ++- src/Logging/OutputLoggerProvider.cs | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Abstracts/TestBedFixture.cs b/src/Abstracts/TestBedFixture.cs index 09080e8..d687a70 100644 --- a/src/Abstracts/TestBedFixture.cs +++ b/src/Abstracts/TestBedFixture.cs @@ -4,7 +4,7 @@ namespace Xunit.Microsoft.DependencyInjection.Abstracts; public abstract class TestBedFixture : IDisposable, IAsyncDisposable { - private readonly IServiceCollection _services; + private readonly ServiceCollection _services; private ServiceProvider? _serviceProvider; private bool _disposedValue; private bool _disposedAsync; @@ -79,6 +79,7 @@ public async ValueTask DisposeAsync() Dispose(); _disposedAsync = true; } + GC.SuppressFinalize(this); } protected abstract void AddServices(IServiceCollection services, IConfiguration? configuration); diff --git a/src/Logging/OutputLoggerProvider.cs b/src/Logging/OutputLoggerProvider.cs index 6a02b0e..6c62124 100644 --- a/src/Logging/OutputLoggerProvider.cs +++ b/src/Logging/OutputLoggerProvider.cs @@ -7,7 +7,5 @@ public class OutputLoggerProvider(ITestOutputHelper testOutputHelper) : ILoggerP public ILogger CreateLogger(string categoryName) => new OutputLogger(categoryName, _testOutputHelper); - public void Dispose() - { - } + public void Dispose() => GC.SuppressFinalize(this); }