From c400764e0e020fce7245f71dec3e38ec3b70690d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Mon, 13 Jun 2022 09:32:44 +0200 Subject: [PATCH] Enable nullables on TestPlatform.Client --- ...stRunAttachmentsProcessingEventsHandler.cs | 6 +- .../DesignMode/DesignModeClient.cs | 87 ++++--- .../DesignModeTestEventsRegistrar.cs | 6 +- .../DesignMode/DesignModeTestHostLauncher.cs | 2 - .../DesignModeTestHostLauncherFactory.cs | 6 +- .../DesignMode/IDesignModeClient.cs | 4 +- .../Discovery/DiscoveryRequest.cs | 120 +++++----- .../Execution/TestRunRequest.cs | 225 +++++++++--------- .../PublicAPI/PublicAPI.Shipped.txt | 117 ++++----- .../RequestHelper/ITestRequestManager.cs | 8 +- .../TestPlatform.cs | 10 +- .../TestPlatformFactory.cs | 4 +- .../TestSession/TestSessionEventsHandler.cs | 4 - .../TestPlatformTests.cs | 6 +- 14 files changed, 294 insertions(+), 311 deletions(-) diff --git a/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs b/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs index 0d15cc77cd..be4cc1b76c 100644 --- a/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs +++ b/src/Microsoft.TestPlatform.Client/AttachmentsProcessing/TestRunAttachmentsProcessingEventsHandler.cs @@ -9,14 +9,12 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing; /// /// The test run attachments processing events handler. /// -/// +/// public class TestRunAttachmentsProcessingEventsHandler : ITestRunAttachmentsProcessingEventsHandler { private readonly ICommunicationManager _communicationManager; @@ -35,7 +33,7 @@ public void HandleTestRunAttachmentsProcessingComplete(TestRunAttachmentsProcess { EqtTrace.Info("Test run attachments processing completed."); - var payload = new TestRunAttachmentsProcessingCompletePayload() + var payload = new TestRunAttachmentsProcessingCompletePayload { AttachmentsProcessingCompleteEventArgs = attachmentsProcessingCompleteEventArgs, Attachments = lastChunk diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs index a058416caa..d965c51b91 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeClient.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Net; using System.Threading; @@ -26,8 +27,6 @@ using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; /// @@ -45,9 +44,9 @@ public class DesignModeClient : IDesignModeClient private readonly TestSessionMessageLogger _testSessionMessageLogger; private readonly object _lockObject = new(); [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] - protected Action onCustomTestHostLaunchAckReceived; + protected Action? onCustomTestHostLaunchAckReceived; [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Part of the public API.")] - protected Action onAttachDebuggerAckRecieved; + protected Action? onAttachDebuggerAckRecieved; /// /// Initializes a new instance of the class. @@ -81,11 +80,12 @@ internal DesignModeClient(ICommunicationManager communicationManager, IDataSeria /// /// Property exposing the Instance /// - public static IDesignModeClient Instance { get; private set; } + public static IDesignModeClient? Instance { get; private set; } /// /// Initializes DesignMode /// + [MemberNotNull(nameof(Instance))] public static void Initialize() { Instance = new DesignModeClient(); @@ -102,7 +102,7 @@ public static void Initialize() /// public void ConnectToClientAndProcessRequests(int port, ITestRequestManager testRequestManager) { - EqtTrace.Info("Trying to connect to server on port : {0}", port); + EqtTrace.Info("Trying to connect to server on port: {0}", port); _communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); var connectionTimeoutInSecs = EnvironmentHelper.GetConnectionTimeout(); @@ -115,7 +115,7 @@ public void ConnectToClientAndProcessRequests(int port, ITestRequestManager test } else { - EqtTrace.Error("DesignModeClient : ConnectToClientAndProcessRequests : Client timed out while connecting to the server."); + EqtTrace.Error("DesignModeClient.ConnectToClientAndProcessRequests: Client timed out while connecting to the server."); Dispose(); throw new TimeoutException( string.Format( @@ -135,7 +135,7 @@ public void HandleParentProcessExit() // this should end the "ProcessRequests" loop with an exception Dispose(); - EqtTrace.Info("DesignModeClient: Parent process exited, Exiting myself.."); + EqtTrace.Info("DesignModeClient.HandleParentProcessExit: Parent process exited, Exiting myself..."); _platformEnvironment.Exit(1); } @@ -303,7 +303,7 @@ public int LaunchCustomHost(TestProcessStartInfo testProcessStartInfo, Cancellat lock (_lockObject) { var waitHandle = new AutoResetEvent(false); - Message ackMessage = null; + Message? ackMessage = null; onCustomTestHostLaunchAckReceived = (ackRawMessage) => { ackMessage = ackRawMessage; @@ -343,7 +343,7 @@ public bool AttachDebuggerToProcess(AttachDebuggerInfo attachDebuggerInfo, Cance lock (_lockObject) { var waitHandle = new AutoResetEvent(false); - Message ackMessage = null; + Message? ackMessage = null; onAttachDebuggerAckRecieved = (ackRawMessage) => { ackMessage = ackRawMessage; @@ -363,7 +363,7 @@ public bool AttachDebuggerToProcess(AttachDebuggerInfo attachDebuggerInfo, Cance { var payload = new EditorAttachDebuggerPayload { - TargetFramework = attachDebuggerInfo.TargetFramework.ToString(), + TargetFramework = attachDebuggerInfo.TargetFramework?.ToString(), ProcessID = attachDebuggerInfo.ProcessId, }; _communicationManager.SendMessage(MessageType.EditorAttachDebugger2, payload); @@ -394,7 +394,7 @@ public void SendRawMessage(string rawMessage) } /// - public void SendTestMessage(TestMessageLevel level, string message) + public void SendTestMessage(TestMessageLevel level, string? message) { var payload = new TestMessagePayload { MessageLevel = level, Message = message }; _communicationManager.SendMessage(MessageType.TestMessage, payload); @@ -405,7 +405,7 @@ public void SendTestMessage(TestMessageLevel level, string message) /// /// /// - public void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) + public void TestRunMessageHandler(object? sender, TestRunMessageEventArgs e) { // save into trace log and send the message to the IDE // @@ -440,41 +440,40 @@ public void TestRunMessageHandler(object sender, TestRunMessageEventArgs e) private void StartTestRun(TestRunRequestPayload testRunPayload, ITestRequestManager testRequestManager, bool shouldLaunchTesthost) { - Task.Run( - () => + Task.Run(() => + { + try { - try - { - testRequestManager.ResetOptions(); + testRequestManager.ResetOptions(); + + // We must avoid re-launching the test host if the test run payload already + // contains test session info. Test session info being present is an indicative + // of an already running test host spawned by a start test session call. + var customLauncher = + shouldLaunchTesthost && testRunPayload.TestSessionInfo == null + ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun( + this, + testRunPayload.DebuggingEnabled) + : null; + + testRequestManager.RunTests(testRunPayload, customLauncher, new DesignModeTestEventsRegistrar(this), _protocolConfig); + } + catch (Exception ex) + { + EqtTrace.Error("DesignModeClient: Exception in StartTestRun: " + ex); - // We must avoid re-launching the test host if the test run payload already - // contains test session info. Test session info being present is an indicative - // of an already running test host spawned by a start test session call. - var customLauncher = - shouldLaunchTesthost && testRunPayload.TestSessionInfo == null - ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun( - this, - testRunPayload.DebuggingEnabled) - : null; - - testRequestManager.RunTests(testRunPayload, customLauncher, new DesignModeTestEventsRegistrar(this), _protocolConfig); - } - catch (Exception ex) + var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; + _communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); + var runCompletePayload = new TestRunCompletePayload() { - EqtTrace.Error("DesignModeClient: Exception in StartTestRun: " + ex); - - var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; - _communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); - var runCompletePayload = new TestRunCompletePayload() - { - TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, true, ex, null, null, TimeSpan.MinValue), - LastRunTests = null - }; + TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, true, ex, null, null, TimeSpan.MinValue), + LastRunTests = null + }; - // Send run complete to translation layer - _communicationManager.SendMessage(MessageType.ExecutionComplete, runCompletePayload); - } - }); + // Send run complete to translation layer + _communicationManager.SendMessage(MessageType.ExecutionComplete, runCompletePayload); + } + }); } private void StartDiscovery(DiscoveryRequestPayload discoveryRequestPayload, ITestRequestManager testRequestManager) diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs index cecf859a19..f945491853 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestEventsRegistrar.cs @@ -2,13 +2,9 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.VisualStudio.TestPlatform.Common.Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; /// @@ -62,7 +58,7 @@ private void OnRawMessageReceived(object sender, string rawMessage) _designModeClient.SendRawMessage(rawMessage); } - public void LogWarning(string message) + public void LogWarning(string? message) { _designModeClient.SendTestMessage(TestMessageLevel.Warning, message); } diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs index 03f02a471c..73df6ca0f6 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncher.cs @@ -7,8 +7,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; /// diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs index f1f56342d9..67400d6b18 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/DesignModeTestHostLauncherFactory.cs @@ -3,8 +3,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; /// @@ -12,8 +10,8 @@ namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; /// public static class DesignModeTestHostLauncherFactory { - private static ITestHostLauncher3 s_defaultLauncher; - private static ITestHostLauncher3 s_debugLauncher; + private static ITestHostLauncher3? s_defaultLauncher; + private static ITestHostLauncher3? s_debugLauncher; public static ITestHostLauncher3 GetCustomHostLauncherForTestRun(IDesignModeClient designModeClient, bool debuggingEnabled) { diff --git a/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs b/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs index 6b13c4e6f2..169a6decee 100644 --- a/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs +++ b/src/Microsoft.TestPlatform.Client/DesignMode/IDesignModeClient.cs @@ -9,8 +9,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.DesignMode; /// @@ -56,5 +54,5 @@ public interface IDesignModeClient : IDisposable /// /// Level for the message /// Actual message string - void SendTestMessage(TestMessageLevel level, string message); + void SendTestMessage(TestMessageLevel level, string? message); } diff --git a/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs b/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs index 7f71a70d09..d2866e204c 100644 --- a/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs +++ b/src/Microsoft.TestPlatform.Client/Discovery/DiscoveryRequest.cs @@ -18,8 +18,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; using Microsoft.VisualStudio.TestPlatform.Utilities; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.Discovery; /// @@ -164,30 +162,30 @@ bool IRequest.WaitForCompletion(int timeout) /// /// Raised when the test discovery starts. /// - public event EventHandler OnDiscoveryStart; + public event EventHandler? OnDiscoveryStart; /// /// Raised when the test discovery completes. /// - public event EventHandler OnDiscoveryComplete; + public event EventHandler? OnDiscoveryComplete; /// /// Raised when the message is received. /// /// TestRunMessageEventArgs should be renamed to more generic - public event EventHandler OnDiscoveryMessage; + public event EventHandler? OnDiscoveryMessage; /// /// Raised when new tests are discovered in this discovery request. /// - public event EventHandler OnDiscoveredTests; + public event EventHandler? OnDiscoveredTests; /// /// Raised when a discovery event related message is received from host /// This is required if one wants to re-direct the message over the process boundary without any processing overhead /// All the discovery events should come as raw messages as well as proper serialized events like OnDiscoveredTests /// - public event EventHandler OnRawMessageReceived; + public event EventHandler? OnRawMessageReceived; /// /// Specifies the discovery criterion @@ -217,7 +215,7 @@ public DiscoveryCriteria DiscoveryCriteria #region ITestDiscoveryEventsHandler2 Methods /// - public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable lastChunk) + public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable? lastChunk) { EqtTrace.Verbose("DiscoveryRequest.HandleDiscoveryComplete: Begin processing discovery complete notification. Aborted: {0}, TotalTests: {1}", discoveryCompleteEventArgs.IsAborted, discoveryCompleteEventArgs.TotalCount); @@ -307,7 +305,7 @@ public void HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryComplete } /// - public void HandleDiscoveredTests(IEnumerable discoveredTestCases) + public void HandleDiscoveredTests(IEnumerable? discoveredTestCases) { EqtTrace.Verbose("DiscoveryRequest.HandleDiscoveredTests: Starting."); @@ -402,66 +400,68 @@ private void HandleLoggerManagerDiscoveryComplete(DiscoveryCompletePayload disco /// Discovery complete payload. /// Message. /// Updated rawMessage. - private string UpdateRawMessageWithTelemetryInfo(DiscoveryCompletePayload discoveryCompletePayload, Message message) + private string? UpdateRawMessageWithTelemetryInfo(DiscoveryCompletePayload? discoveryCompletePayload, Message? message) { var rawMessage = default(string); - if (RequestData.IsTelemetryOptedIn) + if (!RequestData.IsTelemetryOptedIn) { - if (discoveryCompletePayload != null) - { - if (discoveryCompletePayload.Metrics == null) - { - discoveryCompletePayload.Metrics = RequestData.MetricsCollection.Metrics; - } - else - { - foreach (var kvp in RequestData.MetricsCollection.Metrics) - { - discoveryCompletePayload.Metrics[kvp.Key] = kvp.Value; - } - } - - var discoveryFinalTimeTakenForDesignMode = DateTime.UtcNow - _discoveryStartTime; - - // Collecting Total Time Taken - discoveryCompletePayload.Metrics[TelemetryDataConstants.TimeTakenInSecForDiscovery] = discoveryFinalTimeTakenForDesignMode.TotalSeconds; - - // Add extensions discovered by vstest.console. - // - // TODO(copoiena): - // Doing extension merging here is incorrect because we can end up not merging the - // cached extensions for the current process (i.e. vstest.console) and hence have - // an incomplete list of discovered extensions. This can happen because this method - // is called only if telemetry is opted in (see: HandleRawMessage). We should handle - // this merge a level above in order to be consistent, but that means we'd have to - // deserialize all raw messages no matter if telemetry is opted in or not and that - // would probably mean a performance hit. - discoveryCompletePayload.DiscoveredExtensions = TestExtensions.CreateMergedDictionary( - discoveryCompletePayload.DiscoveredExtensions, - TestPluginCache.Instance.TestExtensions?.GetCachedExtensions()); - - // Write extensions to telemetry data. - TestExtensions.AddExtensionTelemetry( - discoveryCompletePayload.Metrics, - discoveryCompletePayload.DiscoveredExtensions); - } + return rawMessage; + } - if (message is VersionedMessage message1) + if (discoveryCompletePayload != null) + { + if (discoveryCompletePayload.Metrics == null) { - var version = message1.Version; - - rawMessage = _dataSerializer.SerializePayload( - MessageType.DiscoveryComplete, - discoveryCompletePayload, - version); + discoveryCompletePayload.Metrics = RequestData.MetricsCollection.Metrics; } else { - rawMessage = _dataSerializer.SerializePayload( - MessageType.DiscoveryComplete, - discoveryCompletePayload); + foreach (var kvp in RequestData.MetricsCollection.Metrics) + { + discoveryCompletePayload.Metrics[kvp.Key] = kvp.Value; + } } + + var discoveryFinalTimeTakenForDesignMode = DateTime.UtcNow - _discoveryStartTime; + + // Collecting Total Time Taken + discoveryCompletePayload.Metrics[TelemetryDataConstants.TimeTakenInSecForDiscovery] = discoveryFinalTimeTakenForDesignMode.TotalSeconds; + + // Add extensions discovered by vstest.console. + // + // TODO(copoiena): + // Doing extension merging here is incorrect because we can end up not merging the + // cached extensions for the current process (i.e. vstest.console) and hence have + // an incomplete list of discovered extensions. This can happen because this method + // is called only if telemetry is opted in (see: HandleRawMessage). We should handle + // this merge a level above in order to be consistent, but that means we'd have to + // deserialize all raw messages no matter if telemetry is opted in or not and that + // would probably mean a performance hit. + discoveryCompletePayload.DiscoveredExtensions = TestExtensions.CreateMergedDictionary( + discoveryCompletePayload.DiscoveredExtensions, + TestPluginCache.Instance.TestExtensions?.GetCachedExtensions()); + + // Write extensions to telemetry data. + TestExtensions.AddExtensionTelemetry( + discoveryCompletePayload.Metrics, + discoveryCompletePayload.DiscoveredExtensions); + } + + if (message is VersionedMessage message1) + { + var version = message1.Version; + + rawMessage = _dataSerializer.SerializePayload( + MessageType.DiscoveryComplete, + discoveryCompletePayload, + version); + } + else + { + rawMessage = _dataSerializer.SerializePayload( + MessageType.DiscoveryComplete, + discoveryCompletePayload); } return rawMessage; @@ -499,7 +499,7 @@ private void Dispose(bool disposing) } // Indicate that object has been disposed - _discoveryCompleted = null; + _discoveryCompleted = null!; _disposed = true; } } diff --git a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs index e91b440ee1..3177f9b0fd 100644 --- a/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs +++ b/src/Microsoft.TestPlatform.Client/Execution/TestRunRequest.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading; +using Microsoft.VisualStudio.TestPlatform.Common; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework; using Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities; using Microsoft.VisualStudio.TestPlatform.Common.Telemetry; @@ -24,8 +25,6 @@ using ClientResources = Microsoft.VisualStudio.TestPlatform.Client.Resources.Resources; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.Execution; public class TestRunRequest : ITestRunRequest, IInternalTestRunEventsHandler @@ -53,7 +52,7 @@ public class TestRunRequest : ITestRunRequest, IInternalTestRunEventsHandler /// /// Tracks the time taken by each run request /// - private Stopwatch _runRequestTimeTracker; + private Stopwatch? _runRequestTimeTracker; private readonly IDataSerializer _dataSerializer; @@ -62,7 +61,7 @@ public class TestRunRequest : ITestRunRequest, IInternalTestRunEventsHandler /// private long _testSessionTimeout; - private Timer _timer; + private Timer? _timer; /// /// Execution Start Time @@ -81,10 +80,10 @@ internal TestRunRequest(IRequestData requestData, TestRunCriteria testRunCriteri internal TestRunRequest(IRequestData requestData, TestRunCriteria testRunCriteria, IProxyExecutionManager executionManager, ITestLoggerManager loggerManager, IDataSerializer dataSerializer) { - Debug.Assert(testRunCriteria != null, "Test run criteria cannot be null"); - Debug.Assert(executionManager != null, "ExecutionManager cannot be null"); - Debug.Assert(requestData != null, "request Data is null"); - Debug.Assert(loggerManager != null, "LoggerManager cannot be null"); + TPDebug.Assert(testRunCriteria != null, "Test run criteria cannot be null"); + TPDebug.Assert(executionManager != null, "ExecutionManager cannot be null"); + TPDebug.Assert(requestData != null, "request Data is null"); + TPDebug.Assert(loggerManager != null, "LoggerManager cannot be null"); EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Creating test run request."); @@ -168,7 +167,7 @@ public int ExecuteAsync() } } - internal void OnTestSessionTimeout(object obj) + internal void OnTestSessionTimeout(object? obj) { EqtTrace.Verbose("TestRunRequest.OnTestSessionTimeout: calling cancellation as test run exceeded testSessionTimeout {0} milliseconds", _testSessionTimeout); @@ -282,30 +281,30 @@ public ITestRunConfiguration TestRunConfiguration /// /// Raised when the test run statistics change. /// - public event EventHandler OnRunStatsChange; + public event EventHandler? OnRunStatsChange; /// /// Raised when the test run starts. /// - public event EventHandler OnRunStart; + public event EventHandler? OnRunStart; /// /// Raised when the test message is received. /// - public event EventHandler TestRunMessage; + public event EventHandler? TestRunMessage; /// /// Raised when the test run completes. /// - public event EventHandler OnRunCompletion; + public event EventHandler? OnRunCompletion; /// /// Raised when data collection message is received. /// #pragma warning disable 67 - public event EventHandler DataCollectionMessage; + public event EventHandler? DataCollectionMessage; #pragma warning restore 67 /// @@ -313,7 +312,7 @@ public ITestRunConfiguration TestRunConfiguration /// This is required if one wants to re-direct the message over the process boundary without any processing overhead /// All the run events should come as raw messages as well as proper serialized events like OnRunStatsChange /// - public event EventHandler OnRawMessageReceived; + public event EventHandler? OnRawMessageReceived; /// /// Parent execution manager @@ -355,7 +354,7 @@ public void Dispose() /// /// Invoked when test run is complete /// - public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection runContextAttachments, ICollection executorUris) + public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, TestRunChangedEventArgs? lastChunkArgs, ICollection? runContextAttachments, ICollection? executorUris) { ValidateArg.NotNull(runCompleteArgs, nameof(runCompleteArgs)); @@ -384,7 +383,7 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, Test try { - _runRequestTimeTracker.Stop(); + _runRequestTimeTracker?.Stop(); if (lastChunkArgs != null) { @@ -402,7 +401,7 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, Test // This is required as TMI adapter is sending attachments as List which cannot be type casted to Collection. runContextAttachments != null ? new Collection(runContextAttachments.ToList()) : null, runCompleteArgs.InvokedDataCollectors, - _runRequestTimeTracker.Elapsed); + _runRequestTimeTracker!.Elapsed); // Add extensions discovered by vstest.console. // @@ -463,40 +462,42 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs runCompleteArgs, Test /// /// Invoked when test run statistics change. /// - public virtual void HandleTestRunStatsChange(TestRunChangedEventArgs testRunChangedArgs) + public virtual void HandleTestRunStatsChange(TestRunChangedEventArgs? testRunChangedArgs) { - if (testRunChangedArgs != null) + if (testRunChangedArgs == null) + { + return; + } + + EqtTrace.Verbose("TestRunRequest:SendTestRunStatsChange: Starting."); + if (testRunChangedArgs.ActiveTests != null) { - EqtTrace.Verbose("TestRunRequest:SendTestRunStatsChange: Starting."); - if (testRunChangedArgs.ActiveTests != null) + // Do verbose check to save performance in iterating test cases + if (EqtTrace.IsVerboseEnabled) { - // Do verbose check to save performance in iterating test cases - if (EqtTrace.IsVerboseEnabled) + foreach (TestCase testCase in testRunChangedArgs.ActiveTests) { - foreach (TestCase testCase in testRunChangedArgs.ActiveTests) - { - EqtTrace.Verbose("InProgress is {0}", testCase.DisplayName); - } + EqtTrace.Verbose("InProgress is {0}", testCase.DisplayName); } } + } - lock (_syncObject) + lock (_syncObject) + { + // If this object is disposed, don't do anything + if (_disposed) { - // If this object is disposed, don't do anything - if (_disposed) - { - EqtTrace.Warning("TestRunRequest.SendTestRunStatsChange: Ignoring as the object is disposed."); - return; - } - - // TODO: Invoke this event in a separate thread. - // For now, I am setting the ConcurrencyMode on the callback attribute to Multiple - LoggerManager.HandleTestRunStatsChange(testRunChangedArgs); - OnRunStatsChange.SafeInvoke(this, testRunChangedArgs, "TestRun.RunStatsChanged"); + EqtTrace.Warning("TestRunRequest.SendTestRunStatsChange: Ignoring as the object is disposed."); + return; } - EqtTrace.Info("TestRunRequest:SendTestRunStatsChange: Completed."); + // TODO: Invoke this event in a separate thread. + // For now, I am setting the ConcurrencyMode on the callback attribute to Multiple + LoggerManager.HandleTestRunStatsChange(testRunChangedArgs); + OnRunStatsChange.SafeInvoke(this, testRunChangedArgs, "TestRun.RunStatsChanged"); } + + EqtTrace.Info("TestRunRequest:SendTestRunStatsChange: Completed."); } /// @@ -550,28 +551,30 @@ public void HandleRawMessage(string rawMessage) /// TestRun complete payload. private void HandleLoggerManagerTestRunComplete(TestRunCompletePayload testRunCompletePayload) { - if (LoggerManager.LoggersInitialized && testRunCompletePayload != null) + if (!LoggerManager.LoggersInitialized || testRunCompletePayload == null) { - // Send last chunk to logger manager. - if (testRunCompletePayload.LastRunTests != null) - { - LoggerManager.HandleTestRunStatsChange(testRunCompletePayload.LastRunTests); - } + return; + } - // Note: In HandleRawMessage attachments are considered from TestRunCompleteArgs, while in HandleTestRunComplete attachments are considered directly from testRunCompletePayload. - // Ideally we should have attachmentSets at one place only. - // Send test run complete to logger manager. - TestRunCompleteEventArgs testRunCompleteArgs = - new( - testRunCompletePayload.TestRunCompleteArgs.TestRunStatistics, - testRunCompletePayload.TestRunCompleteArgs.IsCanceled, - testRunCompletePayload.TestRunCompleteArgs.IsAborted, - testRunCompletePayload.TestRunCompleteArgs.Error, - testRunCompletePayload.TestRunCompleteArgs.AttachmentSets, - testRunCompletePayload.TestRunCompleteArgs.InvokedDataCollectors, - _runRequestTimeTracker.Elapsed); - LoggerManager.HandleTestRunComplete(testRunCompleteArgs); + // Send last chunk to logger manager. + if (testRunCompletePayload.LastRunTests != null) + { + LoggerManager.HandleTestRunStatsChange(testRunCompletePayload.LastRunTests); } + + // Note: In HandleRawMessage attachments are considered from TestRunCompleteArgs, while in HandleTestRunComplete attachments are considered directly from testRunCompletePayload. + // Ideally we should have attachmentSets at one place only. + // Send test run complete to logger manager. + TestRunCompleteEventArgs testRunCompleteArgs = + new( + testRunCompletePayload.TestRunCompleteArgs.TestRunStatistics, + testRunCompletePayload.TestRunCompleteArgs.IsCanceled, + testRunCompletePayload.TestRunCompleteArgs.IsAborted, + testRunCompletePayload.TestRunCompleteArgs.Error, + testRunCompletePayload.TestRunCompleteArgs.AttachmentSets, + testRunCompletePayload.TestRunCompleteArgs.InvokedDataCollectors, + _runRequestTimeTracker!.Elapsed); + LoggerManager.HandleTestRunComplete(testRunCompleteArgs); } /// @@ -580,64 +583,66 @@ private void HandleLoggerManagerTestRunComplete(TestRunCompletePayload testRunCo /// Test run complete payload. /// Updated rawMessage. /// - private string UpdateRawMessageWithTelemetryInfo(TestRunCompletePayload testRunCompletePayload, Message message) + private string? UpdateRawMessageWithTelemetryInfo(TestRunCompletePayload? testRunCompletePayload, Message? message) { var rawMessage = default(string); - if (_requestData.IsTelemetryOptedIn) + if (!_requestData.IsTelemetryOptedIn) { - if (testRunCompletePayload?.TestRunCompleteArgs != null) - { - if (testRunCompletePayload.TestRunCompleteArgs.Metrics == null) - { - testRunCompletePayload.TestRunCompleteArgs.Metrics = _requestData.MetricsCollection.Metrics; - } - else - { - foreach (var kvp in _requestData.MetricsCollection.Metrics) - { - testRunCompletePayload.TestRunCompleteArgs.Metrics[kvp.Key] = kvp.Value; - } - } - - // Fill in the time taken to complete the run - var executionTotalTimeTakenForDesignMode = DateTime.UtcNow - _executionStartTime; - testRunCompletePayload.TestRunCompleteArgs.Metrics[TelemetryDataConstants.TimeTakenInSecForRun] = executionTotalTimeTakenForDesignMode.TotalSeconds; - - // Add extensions discovered by vstest.console. - // - // TODO(copoiena): - // Doing extension merging here is incorrect because we can end up not merging the - // cached extensions for the current process (i.e. vstest.console) and hence have - // an incomplete list of discovered extensions. This can happen because this method - // is called only if telemetry is opted in (see: HandleRawMessage). We should handle - // this merge a level above in order to be consistent, but that means we'd have to - // deserialize all raw messages no matter if telemetry is opted in or not and that - // would probably mean a performance hit. - testRunCompletePayload.TestRunCompleteArgs.DiscoveredExtensions = TestExtensions.CreateMergedDictionary( - testRunCompletePayload.TestRunCompleteArgs.DiscoveredExtensions, - TestPluginCache.Instance.TestExtensions?.GetCachedExtensions()); - - // Write extensions to telemetry data. - TestExtensions.AddExtensionTelemetry( - testRunCompletePayload.TestRunCompleteArgs.Metrics, - testRunCompletePayload.TestRunCompleteArgs.DiscoveredExtensions); - } + return rawMessage; + } - if (message is VersionedMessage message1) + if (testRunCompletePayload?.TestRunCompleteArgs != null) + { + if (testRunCompletePayload.TestRunCompleteArgs.Metrics == null) { - var version = message1.Version; - - rawMessage = _dataSerializer.SerializePayload( - MessageType.ExecutionComplete, - testRunCompletePayload, - version); + testRunCompletePayload.TestRunCompleteArgs.Metrics = _requestData.MetricsCollection.Metrics; } else { - rawMessage = _dataSerializer.SerializePayload( - MessageType.ExecutionComplete, - testRunCompletePayload); + foreach (var kvp in _requestData.MetricsCollection.Metrics) + { + testRunCompletePayload.TestRunCompleteArgs.Metrics[kvp.Key] = kvp.Value; + } } + + // Fill in the time taken to complete the run + var executionTotalTimeTakenForDesignMode = DateTime.UtcNow - _executionStartTime; + testRunCompletePayload.TestRunCompleteArgs.Metrics[TelemetryDataConstants.TimeTakenInSecForRun] = executionTotalTimeTakenForDesignMode.TotalSeconds; + + // Add extensions discovered by vstest.console. + // + // TODO(copoiena): + // Doing extension merging here is incorrect because we can end up not merging the + // cached extensions for the current process (i.e. vstest.console) and hence have + // an incomplete list of discovered extensions. This can happen because this method + // is called only if telemetry is opted in (see: HandleRawMessage). We should handle + // this merge a level above in order to be consistent, but that means we'd have to + // deserialize all raw messages no matter if telemetry is opted in or not and that + // would probably mean a performance hit. + testRunCompletePayload.TestRunCompleteArgs.DiscoveredExtensions = TestExtensions.CreateMergedDictionary( + testRunCompletePayload.TestRunCompleteArgs.DiscoveredExtensions, + TestPluginCache.Instance.TestExtensions?.GetCachedExtensions()); + + // Write extensions to telemetry data. + TestExtensions.AddExtensionTelemetry( + testRunCompletePayload.TestRunCompleteArgs.Metrics, + testRunCompletePayload.TestRunCompleteArgs.DiscoveredExtensions); + } + + if (message is VersionedMessage message1) + { + var version = message1.Version; + + rawMessage = _dataSerializer.SerializePayload( + MessageType.ExecutionComplete, + testRunCompletePayload, + version); + } + else + { + rawMessage = _dataSerializer.SerializePayload( + MessageType.ExecutionComplete, + testRunCompletePayload); } return rawMessage; @@ -690,7 +695,7 @@ protected virtual void Dispose(bool disposing) } // Indicate that object has been disposed - _runCompletionEvent = null; + _runCompletionEvent = null!; _disposed = true; } } diff --git a/src/Microsoft.TestPlatform.Client/PublicAPI/PublicAPI.Shipped.txt b/src/Microsoft.TestPlatform.Client/PublicAPI/PublicAPI.Shipped.txt index db17e826fd..872bef0d70 100644 --- a/src/Microsoft.TestPlatform.Client/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Microsoft.TestPlatform.Client/PublicAPI/PublicAPI.Shipped.txt @@ -1,88 +1,89 @@ +#nullable enable Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.ConnectToClientAndProcessRequests(int port, Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager testRequestManager) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.ConnectToClientAndProcessRequests(int port, Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager! testRequestManager) -> void Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.DesignModeClient() -> void Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.Dispose() -> void Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.HandleParentProcessExit() -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.LaunchCustomHost(Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testProcessStartInfo, System.Threading.CancellationToken cancellationToken) -> int -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.onAttachDebuggerAckRecieved -> System.Action -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.onCustomTestHostLaunchAckReceived -> System.Action -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.SendRawMessage(string rawMessage) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.SendTestMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string message) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.TestRunMessageHandler(object sender, Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestRunMessageEventArgs e) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.LaunchCustomHost(Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo! testProcessStartInfo, System.Threading.CancellationToken cancellationToken) -> int +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.onAttachDebuggerAckRecieved -> System.Action? +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.onCustomTestHostLaunchAckReceived -> System.Action? +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.SendRawMessage(string! rawMessage) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.SendTestMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string? message) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.TestRunMessageHandler(object? sender, Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestRunMessageEventArgs! e) -> void Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.DesignModeTestEventsRegistrar(Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient designModeClient) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.LogWarning(string message) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.RegisterDiscoveryEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.IDiscoveryRequest discoveryRequest) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.RegisterTestRunEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunRequest testRunRequest) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.UnregisterDiscoveryEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.IDiscoveryRequest discoveryRequest) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.UnregisterTestRunEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunRequest testRunRequest) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.DesignModeTestEventsRegistrar(Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient! designModeClient) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.LogWarning(string? message) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.RegisterDiscoveryEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.IDiscoveryRequest! discoveryRequest) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.RegisterTestRunEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunRequest! testRunRequest) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.UnregisterDiscoveryEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.IDiscoveryRequest! discoveryRequest) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestEventsRegistrar.UnregisterTestRunEvents(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunRequest! testRunRequest) -> void Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestHostLauncherFactory Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.ConnectToClientAndProcessRequests(int port, Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager testRequestManager) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.ConnectToClientAndProcessRequests(int port, Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager! testRequestManager) -> void Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.HandleParentProcessExit() -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.LaunchCustomHost(Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo defaultTestHostStartInfo, System.Threading.CancellationToken cancellationToken) -> int -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.SendRawMessage(string rawMessage) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.SendTestMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string message) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.LaunchCustomHost(Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo! defaultTestHostStartInfo, System.Threading.CancellationToken cancellationToken) -> int +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.SendRawMessage(string! rawMessage) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.SendTestMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string? message) -> void Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.Abort() -> void Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.DiscoverAsync() -> void -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.DiscoveryCriteria.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.DiscoveryCriteria +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.DiscoveryCriteria.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.DiscoveryCriteria! Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.Dispose() -> void -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleDiscoveredTests(System.Collections.Generic.IEnumerable discoveredTestCases) -> void -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleDiscoveryComplete(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.DiscoveryCompleteEventArgs discoveryCompleteEventArgs, System.Collections.Generic.IEnumerable lastChunk) -> void -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleLogMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string message) -> void -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleRawMessage(string rawMessage) -> void -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveredTests -> System.EventHandler -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveryComplete -> System.EventHandler -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveryMessage -> System.EventHandler -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveryStart -> System.EventHandler -Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnRawMessageReceived -> System.EventHandler +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleDiscoveredTests(System.Collections.Generic.IEnumerable? discoveredTestCases) -> void +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleDiscoveryComplete(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.DiscoveryCompleteEventArgs! discoveryCompleteEventArgs, System.Collections.Generic.IEnumerable? lastChunk) -> void +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleLogMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string! message) -> void +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.HandleRawMessage(string! rawMessage) -> void +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveredTests -> System.EventHandler? +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveryComplete -> System.EventHandler? +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveryMessage -> System.EventHandler? +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnDiscoveryStart -> System.EventHandler? +Microsoft.VisualStudio.TestPlatform.Client.Discovery.DiscoveryRequest.OnRawMessageReceived -> System.EventHandler? Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.Abort() -> void Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.CancelAsync() -> void -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.DataCollectionMessage -> System.EventHandler +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.DataCollectionMessage -> System.EventHandler? Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.Dispose() -> void Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.ExecuteAsync() -> int -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleLogMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string message) -> void -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleRawMessage(string rawMessage) -> void -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleTestRunComplete(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunCompleteEventArgs runCompleteArgs, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunChangedEventArgs lastChunkArgs, System.Collections.Generic.ICollection runContextAttachments, System.Collections.Generic.ICollection executorUris) -> void -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.LaunchProcessWithDebuggerAttached(Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo testProcessStartInfo) -> int -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRawMessageReceived -> System.EventHandler -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRunCompletion -> System.EventHandler -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRunStart -> System.EventHandler -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRunStatsChange -> System.EventHandler +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleLogMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string! message) -> void +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleRawMessage(string! rawMessage) -> void +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleTestRunComplete(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunCompleteEventArgs! runCompleteArgs, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunChangedEventArgs? lastChunkArgs, System.Collections.Generic.ICollection? runContextAttachments, System.Collections.Generic.ICollection? executorUris) -> void +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.LaunchProcessWithDebuggerAttached(Microsoft.VisualStudio.TestPlatform.ObjectModel.TestProcessStartInfo! testProcessStartInfo) -> int +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRawMessageReceived -> System.EventHandler? +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRunCompletion -> System.EventHandler? +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRunStart -> System.EventHandler? +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.OnRunStatsChange -> System.EventHandler? Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.State.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunState -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.TestRunConfiguration.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunConfiguration -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.TestRunCriteria.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunCriteria -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.TestRunMessage -> System.EventHandler +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.TestRunConfiguration.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunConfiguration! +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.TestRunCriteria.get -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunCriteria! +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.TestRunMessage -> System.EventHandler? Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.WaitForCompletion(int timeout) -> bool Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.AbortTestRun() -> void Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.CancelDiscovery() -> void Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.CancelTestRun() -> void Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.CancelTestRunAttachmentsProcessing() -> void -Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.DiscoverTests(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.DiscoveryRequestPayload discoveryPayload, Microsoft.VisualStudio.TestPlatform.Common.Interfaces.ITestDiscoveryEventsRegistrar disoveryEventsRegistrar, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig protocolConfig) -> void -Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.InitializeExtensions(System.Collections.Generic.IEnumerable pathToAdditionalExtensions, bool skipExtensionFilters) -> void -Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.ProcessTestRunAttachments(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingPayload testRunAttachmentsProcessingPayload, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunAttachmentsProcessingEventsHandler testRunAttachmentsProcessingEventsHandler, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig protocolConfig) -> void +Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.DiscoverTests(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.DiscoveryRequestPayload! discoveryPayload, Microsoft.VisualStudio.TestPlatform.Common.Interfaces.ITestDiscoveryEventsRegistrar! disoveryEventsRegistrar, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig! protocolConfig) -> void +Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.InitializeExtensions(System.Collections.Generic.IEnumerable! pathToAdditionalExtensions, bool skipExtensionFilters) -> void +Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.ProcessTestRunAttachments(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingPayload! testRunAttachmentsProcessingPayload, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestRunAttachmentsProcessingEventsHandler! testRunAttachmentsProcessingEventsHandler, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig! protocolConfig) -> void Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.ResetOptions() -> void Microsoft.VisualStudio.TestPlatform.Client.TestPlatformFactory Microsoft.VisualStudio.TestPlatform.Client.TestPlatformFactory.TestPlatformFactory() -> void Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler -Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleLogMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string message) -> void -Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleProcessedAttachmentsChunk(System.Collections.Generic.IEnumerable attachments) -> void -Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleRawMessage(string rawMessage) -> void -Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleTestRunAttachmentsProcessingComplete(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingCompleteEventArgs attachmentsProcessingCompleteEventArgs, System.Collections.Generic.IEnumerable lastChunk) -> void -Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleTestRunAttachmentsProcessingProgress(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs attachmentsProcessingProgressEventArgs) -> void -Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.TestRunAttachmentsProcessingEventsHandler(Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces.ICommunicationManager communicationManager) -> void +Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleLogMessage(Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging.TestMessageLevel level, string! message) -> void +Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleProcessedAttachmentsChunk(System.Collections.Generic.IEnumerable! attachments) -> void +Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleRawMessage(string! rawMessage) -> void +Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleTestRunAttachmentsProcessingComplete(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingCompleteEventArgs! attachmentsProcessingCompleteEventArgs, System.Collections.Generic.IEnumerable! lastChunk) -> void +Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.HandleTestRunAttachmentsProcessingProgress(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunAttachmentsProcessingProgressEventArgs! attachmentsProcessingProgressEventArgs) -> void +Microsoft.VisualStudio.TestPlatform.Client.TestRunAttachmentsProcessing.TestRunAttachmentsProcessingEventsHandler.TestRunAttachmentsProcessingEventsHandler(Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces.ICommunicationManager! communicationManager) -> void static Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.Initialize() -> void -static Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.Instance.get -> Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient -static Microsoft.VisualStudio.TestPlatform.Client.TestPlatformFactory.GetTestPlatform() -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestPlatform +static Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.Instance.get -> Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient? +static Microsoft.VisualStudio.TestPlatform.Client.TestPlatformFactory.GetTestPlatform() -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestPlatform! virtual Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.Dispose(bool disposing) -> void -virtual Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleTestRunStatsChange(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunChangedEventArgs testRunChangedArgs) -> void -Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.StopTestSession(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads.StopTestSessionPayload payload, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestSessionEventsHandler eventsHandler, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig protocolConfig) -> void -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.AttachDebuggerToProcess(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo attachDebuggerInfo, System.Threading.CancellationToken cancellationToken) -> bool -Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.AttachDebuggerToProcess(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo attachDebuggerInfo, System.Threading.CancellationToken cancellationToken) -> bool -Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.AttachDebuggerToProcess(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo attachDebuggerInfo) -> bool -Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.RunTests(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunRequestPayload testRunRequestPayLoad, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.ITestHostLauncher3 customTestHostLauncher, Microsoft.VisualStudio.TestPlatform.Common.Interfaces.ITestRunEventsRegistrar testRunEventsRegistrar, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig protocolConfig) -> void -Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.StartTestSession(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads.StartTestSessionPayload payload, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.ITestHostLauncher3 testHostLauncher, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestSessionEventsHandler eventsHandler, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig protocolConfig) -> void -static Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient designModeClient, bool debuggingEnabled) -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.ITestHostLauncher3 +virtual Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.HandleTestRunStatsChange(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunChangedEventArgs? testRunChangedArgs) -> void +Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.StopTestSession(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads.StopTestSessionPayload! payload, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestSessionEventsHandler! eventsHandler, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig! protocolConfig) -> void +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.AttachDebuggerToProcess(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo! attachDebuggerInfo, System.Threading.CancellationToken cancellationToken) -> bool +Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient.AttachDebuggerToProcess(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo! attachDebuggerInfo, System.Threading.CancellationToken cancellationToken) -> bool +Microsoft.VisualStudio.TestPlatform.Client.Execution.TestRunRequest.AttachDebuggerToProcess(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.AttachDebuggerInfo! attachDebuggerInfo) -> bool +Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.RunTests(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.TestRunRequestPayload! testRunRequestPayLoad, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.ITestHostLauncher3? customTestHostLauncher, Microsoft.VisualStudio.TestPlatform.Common.Interfaces.ITestRunEventsRegistrar! testRunEventsRegistrar, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig! protocolConfig) -> void +Microsoft.VisualStudio.TestPlatform.Client.RequestHelper.ITestRequestManager.StartTestSession(Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads.StartTestSessionPayload! payload, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.ITestHostLauncher3? testHostLauncher, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ITestSessionEventsHandler! eventsHandler, Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.ProtocolConfig! protocolConfig) -> void +static Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(Microsoft.VisualStudio.TestPlatform.Client.DesignMode.IDesignModeClient! designModeClient, bool debuggingEnabled) -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces.ITestHostLauncher3! diff --git a/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs b/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs index 5108a1591d..d44026f148 100644 --- a/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs +++ b/src/Microsoft.TestPlatform.Client/RequestHelper/ITestRequestManager.cs @@ -10,8 +10,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client.RequestHelper; /// @@ -56,7 +54,7 @@ void DiscoverTests( /// Protocol related information. void RunTests( TestRunRequestPayload testRunRequestPayLoad, - ITestHostLauncher3 customTestHostLauncher, + ITestHostLauncher3? customTestHostLauncher, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig); @@ -86,14 +84,14 @@ void ProcessTestRunAttachments( /// Protocol related information. void StartTestSession( StartTestSessionPayload payload, - ITestHostLauncher3 testHostLauncher, + ITestHostLauncher3? testHostLauncher, ITestSessionEventsHandler eventsHandler, ProtocolConfig protocolConfig); /// /// Stops a test session. /// - /// + /// /// The stop test session payload. /// The events handler. /// Protocol related information. diff --git a/src/Microsoft.TestPlatform.Client/TestPlatform.cs b/src/Microsoft.TestPlatform.Client/TestPlatform.cs index 79de15d7ee..a07f6618db 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatform.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatform.cs @@ -26,8 +26,6 @@ using ClientResources = Microsoft.VisualStudio.TestPlatform.Client.Resources.Resources; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client; /// @@ -81,7 +79,7 @@ protected internal TestPlatform( public IDiscoveryRequest CreateDiscoveryRequest( IRequestData requestData, DiscoveryCriteria discoveryCriteria, - TestPlatformOptions options, + TestPlatformOptions? options, Dictionary sourceToSourceDetailMap) { ValidateArg.NotNull(discoveryCriteria, nameof(discoveryCriteria)); @@ -102,7 +100,7 @@ public IDiscoveryRequest CreateDiscoveryRequest( public ITestRunRequest CreateTestRunRequest( IRequestData requestData, TestRunCriteria testRunCriteria, - TestPlatformOptions options, + TestPlatformOptions? options, Dictionary sourceToSourceDetailMap) { ValidateArg.NotNull(testRunCriteria, nameof(testRunCriteria)); @@ -139,7 +137,7 @@ public bool StartTestSession( return false; } - IProxyTestSessionManager testSessionManager = _testEngine.GetTestSessionManager(requestData, testSessionCriteria, sourceToSourceDetailMap); + IProxyTestSessionManager? testSessionManager = _testEngine.GetTestSessionManager(requestData, testSessionCriteria, sourceToSourceDetailMap); if (testSessionManager == null) { // The test session manager is null because the combination of runsettings and @@ -191,7 +189,7 @@ public void ClearExtensions() } private static void ThrowExceptionIfTestHostManagerIsNull( - ITestRuntimeProvider testHostManager, + ITestRuntimeProvider? testHostManager, string settingsXml) { if (testHostManager == null) diff --git a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs index c1de82f380..2e703efd4a 100644 --- a/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs +++ b/src/Microsoft.TestPlatform.Client/TestPlatformFactory.cs @@ -3,8 +3,6 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client; /// @@ -12,7 +10,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Client; /// public class TestPlatformFactory { - private static ITestPlatform s_testPlatform; + private static ITestPlatform? s_testPlatform; /// /// Gets an instance of the test platform. diff --git a/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs b/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs index e7f195a884..cb1860e581 100644 --- a/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs +++ b/src/Microsoft.TestPlatform.Client/TestSession/TestSessionEventsHandler.cs @@ -2,15 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces; - using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Payloads; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; -#nullable disable - namespace Microsoft.VisualStudio.TestPlatform.Client; /// diff --git a/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs b/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs index 69d039d7e1..ae968206a4 100644 --- a/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs +++ b/test/Microsoft.TestPlatform.Client.UnitTests/TestPlatformTests.cs @@ -105,7 +105,7 @@ public void CreateDiscoveryRequestThrowsIfDiscoveryCriteriaIsNull() { TestPlatform tp = new(); - Assert.ThrowsException(() => tp.CreateDiscoveryRequest(_mockRequestData.Object, null, new TestPlatformOptions(), It.IsAny>())); + Assert.ThrowsException(() => tp.CreateDiscoveryRequest(_mockRequestData.Object, null!, new TestPlatformOptions(), It.IsAny>())); } [TestMethod] @@ -283,7 +283,7 @@ public void CreateTestRunRequestThrowsIfTestRunCriteriaIsNull() { var tp = new TestPlatform(); - Assert.ThrowsException(() => tp.CreateTestRunRequest(_mockRequestData.Object, null, new TestPlatformOptions(), It.IsAny>())); + Assert.ThrowsException(() => tp.CreateTestRunRequest(_mockRequestData.Object, null!, new TestPlatformOptions(), It.IsAny>())); } /// @@ -427,7 +427,7 @@ public void StartTestSessionShouldThrowExceptionIfTestSessionCriteriaIsNull() Assert.ThrowsException(() => tp.StartTestSession( new Mock().Object, - null, + null!, new Mock().Object, new Dictionary())); }