Skip to content

Commit

Permalink
Fix warnings on main (#3870)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Jul 20, 2022
1 parent ef92a80 commit 11f2503
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel;
/// <summary>
/// ParallelProxyDiscoveryManager that manages parallel discovery
/// </summary>
internal class ParallelProxyDiscoveryManager : IParallelProxyDiscoveryManager
internal sealed class ParallelProxyDiscoveryManager : IParallelProxyDiscoveryManager, IDisposable
{
private readonly IDataSerializer _dataSerializer;
private readonly DiscoveryDataAggregator _dataAggregator;
private readonly bool _isParallel;
private readonly ParallelOperationManager<IProxyDiscoveryManager, ITestDiscoveryEventsHandler2, DiscoveryCriteria> _parallelOperationManager;
private readonly Dictionary<string, TestRuntimeProviderInfo> _sourceToTestHostProviderMap;
private readonly IRequestData _requestData;

private int _discoveryCompletedClients;
private int _availableTestSources;
private int _availableWorkloads;
private bool _skipDefaultAdapters;
private readonly IRequestData _requestData;
private bool _isDisposed;

public bool IsAbortRequested { get; private set; }

Expand Down Expand Up @@ -295,4 +297,13 @@ private void DiscoverTestsOnConcurrentManager(IProxyDiscoveryManager proxyDiscov

EqtTrace.Verbose("ProxyParallelDiscoveryManager.DiscoverTestsOnConcurrentManager: No sources available for discovery.");
}

public void Dispose()
{
if (!_isDisposed)
{
_parallelOperationManager.Dispose();
_isDisposed = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel;
/// <summary>
/// ParallelProxyExecutionManager that manages parallel execution
/// </summary>
internal class ParallelProxyExecutionManager : IParallelProxyExecutionManager
internal sealed class ParallelProxyExecutionManager : IParallelProxyExecutionManager, IDisposable
{
private readonly IDataSerializer _dataSerializer;
private readonly bool _isParallel;
private readonly ParallelOperationManager<IProxyExecutionManager, IInternalTestRunEventsHandler, TestRunCriteria> _parallelOperationManager;
private readonly Dictionary<string, TestRuntimeProviderInfo> _sourceToTestHostProviderMap;

private bool _isDisposed;

#region TestRunSpecificData

// This variable id to differentiate between implicit (abort requested by testPlatform) and explicit (test host aborted) abort.
Expand Down Expand Up @@ -405,6 +407,15 @@ private void StartTestRunOnConcurrentManager(IProxyExecutionManager proxyExecuti

EqtTrace.Verbose("ProxyParallelExecutionManager: No sources available for execution.");
}

public void Dispose()
{
if (!_isDisposed)
{
_parallelOperationManager.Dispose();
_isDisposed = true;
}
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client;
/// <summary>
/// Base class for any operations that the client needs to drive through the engine.
/// </summary>
[SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", Justification = "Would cause a breaking change if users are inheriting this class and implement IDisposable")]
public class ProxyOperationManager
{
private readonly string _versionCheckPropertyName = "IsVersionCheckRequired";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
Expand All @@ -28,6 +29,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Discovery;
/// <summary>
/// Orchestrates discovery operations for the engine communicating with the test host process.
/// </summary>
[SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", Justification = "Would cause a breaking change if users are inheriting this class and implement IDisposable")]
public class DiscoveryManager : IDiscoveryManager
{
private readonly TestSessionMessageLogger _sessionMessageLogger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer;
/// <summary>
/// Vstest.console process manager
/// </summary>
internal class VsTestConsoleProcessManager : IProcessManager
internal sealed class VsTestConsoleProcessManager : IProcessManager, IDisposable
{
/// <summary>
/// Port number for communicating with Vstest CLI
Expand Down Expand Up @@ -56,6 +56,7 @@ internal class VsTestConsoleProcessManager : IProcessManager
private Process? _process;
private bool _vstestConsoleStarted;
private bool _vstestConsoleExited;
private bool _isDisposed;

internal IFileHelper FileHelper { get; set; }

Expand Down Expand Up @@ -260,4 +261,14 @@ private string GetConsoleRunner()

private static string GetEscapeSequencedPath(string path)
=> path.IsNullOrEmpty() ? path : $"\"{path.Trim('"')}\"";

public void Dispose()
{
if (!_isDisposed)
{
_processExitedEvent.Dispose();
_process?.Dispose();
_isDisposed = true;
}
}
}

0 comments on commit 11f2503

Please sign in to comment.