-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
executable file
·80 lines (68 loc) · 2.76 KB
/
Program.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using VSCodeDebug;
class Program
{
static void Main()
{
MainImpl().GetAwaiter().GetResult();
}
static async Task MainImpl()
{
// Launch OpenDebugAD7 adapter
var startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Users\jcouv\.vscode\extensions\ms-vscode.csharp-1.6.2\.debugger\OpenDebugAD7.exe";
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
int exitCode;
// Run the external process & wait for it to finish
using (Process proc = Process.Start(startInfo))
{
// Start chatting with it
var client = new DebugClient();
Task running = client.Start(proc.StandardOutput.BaseStream, proc.StandardInput.BaseStream);
new System.Threading.Thread(() => running.GetAwaiter().GetResult());
InitializeResponse initResponse = await client.Initialize(new InitializeRequest(new InitializeRequestArguments()));
Response launchResponse = await client.Request(new LaunchRequest(new LaunchArguments()
{
program = @"C:\Users\jcouv\.babun\cygwin\home\jcouv\issues\hello-world\bin\Debug\netcoreapp1.0\hello-world.dll",
cwd = @"C:\Users\jcouv\.babun\cygwin\home\jcouv\issues\hello-world\bin\Debug\netcoreapp1.0",
logging = new LoggingOptions() { engineLogging = true, trace = true, traceResponse = true }
}));
await client.Initialized();
Response response;
response = await client.Request(new SetExceptionBreakpointsRequest(new SetExceptionBreakpointsArguments()));
response = await client.Request(new ConfigurationDoneRequest());
response = await client.Request(new ThreadsRequest());
// response = await client.Request(new NextRequest(new NextArguments()));
// response = await client.Request(new ThreadsRequest());
// response = await client.Request(new StackTraceRequest(new StackTraceArguments()));
proc.WaitForExit();
// Retrieve the app's exit code
exitCode = proc.ExitCode;
}
}
}
public class DebugClient : ProtocolClient
{
TaskCompletionSource<bool> initialized = new TaskCompletionSource<bool>();
public DebugClient() : base()
{
TRACE = true;
}
protected override void DispatchEvent(Event @event)
{
switch(@event.eventType)
{
case "initialized":
initialized.SetResult(true);
break;
}
}
public async Task<bool> Initialized()
{
return await initialized.Task;
}
}