From 0f49ad729012edf0dbda01ac9d2216273cb5675f Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Mon, 16 Sep 2024 01:48:03 +1000 Subject: [PATCH] missing dispose in NamedPipeClient (#3833) --- .../IPC/NamedPipeClient.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeClient.cs b/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeClient.cs index 658e6efb12..d49a7b9cf6 100644 --- a/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeClient.cs +++ b/src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeClient.cs @@ -202,21 +202,31 @@ public async Task RequestReplyAsync(TRequest req public void Dispose() { - if (!_disposed) + if (_disposed) { - _namedPipeClientStream.Dispose(); - _disposed = true; + return; } + + _lock.Dispose(); + _serializationBuffer.Dispose(); + _messageBuffer.Dispose(); + _namedPipeClientStream.Dispose(); + _disposed = true; } #if NETCOREAPP public async ValueTask DisposeAsync() { - if (!_disposed) + if (_disposed) { - await _namedPipeClientStream.DisposeAsync(); - _disposed = true; + return; } + + _lock.Dispose(); + await _serializationBuffer.DisposeAsync(); + await _messageBuffer.DisposeAsync(); + await _namedPipeClientStream.DisposeAsync(); + _disposed = true; } #endif }