forked from OmniSharp/omnisharp-roslyn
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebugTestService.cs
More file actions
55 lines (49 loc) · 2.3 KB
/
DebugTestService.cs
File metadata and controls
55 lines (49 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Logging;
using OmniSharp.DotNetTest.Models;
using OmniSharp.Eventing;
using OmniSharp.Mef;
using OmniSharp.Services;
namespace OmniSharp.DotNetTest.Services
{
[Shared]
[OmniSharpHandler(OmniSharpEndpoints.V2.DebugTestGetStartInfo, LanguageNames.CSharp)]
[OmniSharpHandler(OmniSharpEndpoints.V2.DebugTestLaunch, LanguageNames.CSharp)]
[OmniSharpHandler(OmniSharpEndpoints.V2.DebugTestStop, LanguageNames.CSharp)]
internal class DebugTestService : BaseTestService,
IRequestHandler<DebugTestGetStartInfoRequest, DebugTestGetStartInfoResponse>,
IRequestHandler<DebugTestLaunchRequest, DebugTestLaunchResponse>,
IRequestHandler<DebugTestStopRequest, DebugTestStopResponse>
{
private readonly DebugSessionManager _debugSessionManager;
[ImportingConstructor]
public DebugTestService(DebugSessionManager debugSessionManager, OmniSharpWorkspace workspace, IDotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
: base(workspace, dotNetCli, eventEmitter, loggerFactory)
{
_debugSessionManager = debugSessionManager;
}
public Task<DebugTestGetStartInfoResponse> Handle(DebugTestGetStartInfoRequest request)
{
var testManager = CreateTestManager(request.FileName);
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.RunSettings, request.TestFrameworkName, request.TargetFrameworkVersion, CancellationToken.None);
}
throw new InvalidOperationException("The debugger could not be started");
}
public Task<DebugTestLaunchResponse> Handle(DebugTestLaunchRequest request)
{
return _debugSessionManager.DebugLaunchAsync(request.TargetProcessId);
}
public Task<DebugTestStopResponse> Handle(DebugTestStopRequest request)
{
return _debugSessionManager.DebugStopAsync();
}
}
}