Skip to content

Commit a1e4196

Browse files
authored
Make IProcess disposable (#3120)
1 parent 5add061 commit a1e4196

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/Platform/Microsoft.Testing.Platform/Helpers/System/IProcess.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Microsoft.Testing.Platform.Helpers;
55

6-
internal interface IProcess
6+
internal interface IProcess : IDisposable
77
{
88
public event EventHandler Exited;
99

src/Platform/Microsoft.Testing.Platform/Helpers/System/SystemProcess.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.Testing.Platform.Helpers;
77

8-
internal sealed class SystemProcess : IProcess
8+
internal sealed class SystemProcess : IProcess, IDisposable
99
{
1010
private readonly Process _process;
1111

@@ -51,4 +51,6 @@ public void Kill()
5151
public void Kill()
5252
=> _process.Kill();
5353
#endif
54+
55+
public void Dispose() => _process.Dispose();
5456
}

src/Platform/Microsoft.Testing.Platform/Hosts/TestHostControllersTestHost.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected override async Task<int> InternalRunAsync()
202202
processStartInfo.EnvironmentVariables.Add($"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_TESTHOSTPROCESSSTARTTIME}_{currentPID}", testHostProcessStartupTime);
203203
await _logger.LogDebugAsync($"{EnvironmentVariableConstants.TESTINGPLATFORM_TESTHOSTCONTROLLER_TESTHOSTPROCESSSTARTTIME}_{currentPID} '{testHostProcessStartupTime}'");
204204
await _logger.LogDebugAsync($"Starting test host process");
205-
IProcess testHostProcess = process.Start(processStartInfo);
205+
using IProcess testHostProcess = process.Start(processStartInfo);
206206

207207
testHostProcess.Exited += (sender, e) =>
208208
{

0 commit comments

Comments
 (0)