Skip to content

Commit

Permalink
remove destructor pattern from LogMessageListener (#4585)
Browse files Browse the repository at this point in the history
Co-authored-by: Amaury Levé <[email protected]>
  • Loading branch information
SimonCropp and Evangelink authored Jan 23, 2025
1 parent 9151e75 commit 4c476ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
25 changes: 3 additions & 22 deletions src/Adapter/MSTest.TestAdapter/Execution/LogMessageListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ public LogMessageListener(bool captureDebugTraces)
}
}

~LogMessageListener()
{
Dispose(false);
}

/// <summary>
/// Gets logger output.
/// </summary>
Expand All @@ -108,31 +103,17 @@ 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()
=> s_redirectedDebugTrace?.ToStringAndClear();

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

private void Dispose(bool disposing)
{
if (!disposing || _isDisposed)
if (_isDisposed)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
*REMOVED*Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.LogMessageListener.~LogMessageListener() -> void
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
*REMOVED*Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.LogMessageListener.~LogMessageListener() -> void

0 comments on commit 4c476ee

Please sign in to comment.