From 4c476eeea331a9e30efdb396093d426987d56122 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Fri, 24 Jan 2025 05:02:57 +1100 Subject: [PATCH] remove destructor pattern from LogMessageListener (#4585) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- .../Execution/LogMessageListener.cs | 25 +++---------------- .../PublicAPI/PublicAPI.Unshipped.txt | 1 + .../uap10.0.16299/PublicAPI.Unshipped.txt | 1 + 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/Adapter/MSTest.TestAdapter/Execution/LogMessageListener.cs b/src/Adapter/MSTest.TestAdapter/Execution/LogMessageListener.cs index 7e3dc95d39..b7a7c6a09c 100644 --- a/src/Adapter/MSTest.TestAdapter/Execution/LogMessageListener.cs +++ b/src/Adapter/MSTest.TestAdapter/Execution/LogMessageListener.cs @@ -87,11 +87,6 @@ public LogMessageListener(bool captureDebugTraces) } } - ~LogMessageListener() - { - Dispose(false); - } - /// /// Gets logger output. /// @@ -108,17 +103,9 @@ public LogMessageListener(bool captureDebugTraces) [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the public API")] public string? DebugTrace => s_redirectedDebugTrace?.ToString(); - public string? GetAndClearStandardOutput() - { - string? output = _redirectedStandardOutput.ToStringAndClear(); - return output; - } + public string? GetAndClearStandardOutput() => _redirectedStandardOutput.ToStringAndClear(); - public string? GetAndClearStandardError() - { - string? output = _redirectedStandardError.ToStringAndClear(); - return output; - } + public string? GetAndClearStandardError() => _redirectedStandardError.ToStringAndClear(); [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the public API")] public string? GetAndClearDebugTrace() @@ -126,13 +113,7 @@ public LogMessageListener(bool captureDebugTraces) public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (!disposing || _isDisposed) + if (_isDisposed) { return; } diff --git a/src/Adapter/MSTest.TestAdapter/PublicAPI/PublicAPI.Unshipped.txt b/src/Adapter/MSTest.TestAdapter/PublicAPI/PublicAPI.Unshipped.txt index 7dc5c58110..871e104b0f 100644 --- a/src/Adapter/MSTest.TestAdapter/PublicAPI/PublicAPI.Unshipped.txt +++ b/src/Adapter/MSTest.TestAdapter/PublicAPI/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +*REMOVED*Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.LogMessageListener.~LogMessageListener() -> void diff --git a/src/Adapter/MSTest.TestAdapter/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt b/src/Adapter/MSTest.TestAdapter/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt index 7dc5c58110..871e104b0f 100644 --- a/src/Adapter/MSTest.TestAdapter/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt +++ b/src/Adapter/MSTest.TestAdapter/PublicAPI/uap10.0.16299/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ #nullable enable +*REMOVED*Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.LogMessageListener.~LogMessageListener() -> void