From 1a16877a339a4fe6dda3bdaa4398754f04b6e0f7 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 3 Jul 2018 10:46:32 -0700 Subject: [PATCH] Debug only when test manager is connected --- .../Services/DebugTestService.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/OmniSharp.DotNetTest/Services/DebugTestService.cs b/src/OmniSharp.DotNetTest/Services/DebugTestService.cs index 65a9055530..ccb49953cd 100644 --- a/src/OmniSharp.DotNetTest/Services/DebugTestService.cs +++ b/src/OmniSharp.DotNetTest/Services/DebugTestService.cs @@ -1,4 +1,5 @@ -using System.Composition; +using System; +using System.Composition; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -31,9 +32,14 @@ public DebugTestService(DebugSessionManager debugSessionManager, OmniSharpWorksp public Task Handle(DebugTestGetStartInfoRequest request) { var testManager = CreateTestManager(request.FileName); - _debugSessionManager.StartSession(testManager); + if (testManager.IsConnected) + { + //only if the test manager connected successfully, shall we proceed with the request + _debugSessionManager.StartSession(testManager); + return _debugSessionManager.DebugGetStartInfoAsync(request.MethodName, request.TestFrameworkName, request.TargetFrameworkVersion, CancellationToken.None); + } - return _debugSessionManager.DebugGetStartInfoAsync(request.MethodName, request.TestFrameworkName, request.TargetFrameworkVersion, CancellationToken.None); + throw new InvalidOperationException("The debugger could not be started"); } public Task Handle(DebugTestLaunchRequest request)