From 1092f85b68ceff6667eadf43081097e02adb77c8 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 2 Aug 2022 07:10:46 -0600 Subject: [PATCH] Fix PerBenchmarkDotNet project This has evidently been broken since I regressed it in 5c0220eecc34. --- .../MessagePackWriterBenchmark.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sandbox/PerfBenchmarkDotNet/MessagePackWriterBenchmark.cs b/sandbox/PerfBenchmarkDotNet/MessagePackWriterBenchmark.cs index 8afaccc14..64e7c89a3 100644 --- a/sandbox/PerfBenchmarkDotNet/MessagePackWriterBenchmark.cs +++ b/sandbox/PerfBenchmarkDotNet/MessagePackWriterBenchmark.cs @@ -13,7 +13,7 @@ namespace PerfBenchmarkDotNet { [GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)] [CategoriesColumn] - public sealed class MessagePackWriterBenchmark : IDisposable + public class MessagePackWriterBenchmark : IDisposable { private const int RepsOverArray = 300 * 1024; private readonly Sequence sequence = new Sequence(); @@ -152,7 +152,16 @@ public void WriteString() public void Dispose() { - this.sequence.Dispose(); + this.Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + this.sequence.Dispose(); + } } } }