-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathDebugAdapterClientExtensions.cs
37 lines (33 loc) · 1.3 KB
/
DebugAdapterClientExtensions.cs
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Threading.Tasks;
using Microsoft.PowerShell.EditorServices.Handlers;
using OmniSharp.Extensions.DebugAdapter.Client;
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
using System.Threading;
namespace PowerShellEditorServices.Test.E2E
{
public static class DebugAdapterClientExtensions
{
public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient, string script, TaskCompletionSource<object> started)
{
LaunchResponse launchResponse = await debugAdapterClient.Launch(
new PsesLaunchRequestArguments
{
NoDebug = false,
Script = script,
Cwd = "",
CreateTemporaryIntegratedConsole = false
}).ConfigureAwait(true);
if (launchResponse is null)
{
throw new Exception("Launch response was null.");
}
// This will check to see if we received the Initialized event from the server.
await Task.Run(
async () => await started.Task.ConfigureAwait(true),
new CancellationTokenSource(2000).Token).ConfigureAwait(true);
}
}
}