public void PrepareStart(string caller_trace) { InitializeRequest initializeRequest = new InitializeRequest(); initializeRequest.arguments.clientID = "vscode"; initializeRequest.arguments.clientName = "Visual Studio Code"; initializeRequest.arguments.adapterID = "coreclr"; initializeRequest.arguments.pathFormat = "path"; initializeRequest.arguments.linesStartAt1 = true; initializeRequest.arguments.columnsStartAt1 = true; initializeRequest.arguments.supportsVariableType = true; initializeRequest.arguments.supportsVariablePaging = true; initializeRequest.arguments.supportsRunInTerminalRequest = true; initializeRequest.arguments.locale = "en-us"; Assert.True(VSCodeDebugger.Request(initializeRequest).Success, @"__FILE__:__LINE__" + "\n" + caller_trace); LaunchRequest launchRequest = new LaunchRequest(); launchRequest.arguments.name = ".NET Core Launch (console) with pipeline"; launchRequest.arguments.type = "coreclr"; launchRequest.arguments.preLaunchTask = "build"; launchRequest.arguments.program = ControlInfo.TargetAssemblyPath; launchRequest.arguments.cwd = ""; launchRequest.arguments.console = "internalConsole"; launchRequest.arguments.stopAtEntry = true; launchRequest.arguments.internalConsoleOptions = "openOnSessionStart"; launchRequest.arguments.__sessionId = Guid.NewGuid().ToString(); Assert.True(VSCodeDebugger.Request(launchRequest).Success, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void Continue() { ContinueRequest continueRequest = new ContinueRequest(); continueRequest.arguments.threadId = threadId; Assert.True(VSCodeDebugger.Request(continueRequest).Success); }
public static void WasExit() { bool wasExited = false; int? exitCode = null; bool wasTerminated = false; Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited")) { wasExited = true; ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON); exitCode = exitedEvent.body.exitCode; } if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated")) { wasTerminated = true; } if (wasExited && exitCode == 0 && wasTerminated) { return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public static void PrepareStart() { InitializeRequest initializeRequest = new InitializeRequest(); initializeRequest.arguments.clientID = "vscode"; initializeRequest.arguments.clientName = "Visual Studio Code"; initializeRequest.arguments.adapterID = "coreclr"; initializeRequest.arguments.pathFormat = "path"; initializeRequest.arguments.linesStartAt1 = true; initializeRequest.arguments.columnsStartAt1 = true; initializeRequest.arguments.supportsVariableType = true; initializeRequest.arguments.supportsVariablePaging = true; initializeRequest.arguments.supportsRunInTerminalRequest = true; initializeRequest.arguments.locale = "en-us"; Assert.True(VSCodeDebugger.Request(initializeRequest).Success); LaunchRequest launchRequest = new LaunchRequest(); launchRequest.arguments.name = ".NET Core Launch (console) with pipeline"; launchRequest.arguments.type = "coreclr"; launchRequest.arguments.preLaunchTask = "build"; launchRequest.arguments.program = DebuggeeInfo.TargetAssemblyPath; // NOTE this code works only with one source file launchRequest.arguments.cwd = Directory.GetParent(DebuggeeInfo.SourceFilesPath).FullName; launchRequest.arguments.console = "internalConsole"; launchRequest.arguments.stopAtEntry = true; launchRequest.arguments.internalConsoleOptions = "openOnSessionStart"; launchRequest.arguments.__sessionId = Guid.NewGuid().ToString(); Assert.True(VSCodeDebugger.Request(launchRequest).Success); }
public void DebuggerExit(string caller_trace) { DisconnectRequest disconnectRequest = new DisconnectRequest(); disconnectRequest.arguments = new DisconnectArguments(); disconnectRequest.arguments.restart = false; Assert.True(VSCodeDebugger.Request(disconnectRequest).Success, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void DebuggerExit() { DisconnectRequest disconnectRequest = new DisconnectRequest(); disconnectRequest.arguments = new DisconnectArguments(); disconnectRequest.arguments.restart = false; Assert.True(VSCodeDebugger.Request(disconnectRequest).Success); }
public void Continue(string caller_trace) { ContinueRequest continueRequest = new ContinueRequest(); continueRequest.arguments.threadId = threadId; Assert.True(VSCodeDebugger.Request(continueRequest).Success, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void AbortExecution(string caller_trace) { TerminateRequest terminateRequest = new TerminateRequest(); terminateRequest.arguments = new TerminateArguments(); terminateRequest.arguments.restart = false; Assert.True(VSCodeDebugger.Request(terminateRequest).Success, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static VSCodeResult SetVariable(int variablesReference, string Name, string Value) { SetVariableRequest setVariableRequest = new SetVariableRequest(); setVariableRequest.arguments.variablesReference = variablesReference; setVariableRequest.arguments.name = Name; setVariableRequest.arguments.value = Value; return(VSCodeDebugger.Request(setVariableRequest)); }
public static void CalcExpressionWithNotDeclared(Int64?frameId, string Expression) { EvaluateRequest evaluateRequest = new EvaluateRequest(); evaluateRequest.arguments.expression = Expression; evaluateRequest.arguments.frameId = frameId; var ret = VSCodeDebugger.Request(evaluateRequest); Assert.False(ret.Success); }
public void CheckErrorAtRequest(string caller_trace, Int64 frameId, string Expression) { EvaluateRequest evaluateRequest = new EvaluateRequest(); evaluateRequest.arguments.expression = Expression; evaluateRequest.arguments.frameId = frameId; var ret = VSCodeDebugger.Request(evaluateRequest); Assert.False(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void WasExit() { string resJSON = VSCodeDebugger.Receive(-1); Assert.True(VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated")); DisconnectRequest disconnectRequest = new DisconnectRequest(); disconnectRequest.arguments = new DisconnectArguments(); disconnectRequest.arguments.restart = false; Assert.True(VSCodeDebugger.Request(disconnectRequest).Success); }
public void SetBreakpoints(string caller_trace) { SetBreakpointsRequest setBreakpointsRequest = new SetBreakpointsRequest(); setBreakpointsRequest.arguments.source.name = BreakpointSourceName; // NOTE this code works only with one source file setBreakpointsRequest.arguments.source.path = ControlInfo.SourceFilesPath; setBreakpointsRequest.arguments.lines.AddRange(BreakpointLines); setBreakpointsRequest.arguments.breakpoints.AddRange(BreakpointList); setBreakpointsRequest.arguments.sourceModified = false; Assert.True(VSCodeDebugger.Request(setBreakpointsRequest).Success, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void SetBreakpoints() { SetBreakpointsRequest setBreakpointsRequest = new SetBreakpointsRequest(); setBreakpointsRequest.arguments.source.name = BreakpointSourceName; // NOTE this code works only with one source file setBreakpointsRequest.arguments.source.path = DebuggeeInfo.SourceFilesPath; setBreakpointsRequest.arguments.lines.AddRange(BreakpointLines); setBreakpointsRequest.arguments.breakpoints.AddRange(BreakpointList); setBreakpointsRequest.arguments.sourceModified = false; Assert.True(VSCodeDebugger.Request(setBreakpointsRequest).Success); }
public void WasPaused(string caller_trace) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "pause")) { return(true); } return(false); }; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public VariablesResponse GetLocalVariables(string caller_trace, Int64 frameId) { int variablesReference = GetVariablesReference(@"__FILE__:__LINE__" + "\n" + caller_trace, frameId, "Locals"); VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = variablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); return(JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr)); }
public static VariablesResponse GetLocalVariables(Int64 frameId) { int variablesReference = Context.GetVariablesReference(frameId, "Locals"); VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = variablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success); return(JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr)); }
public void GetResultAsString(string caller_trace, Int64 frameId, string expr, out string strRes) { EvaluateRequest evaluateRequest = new EvaluateRequest(); evaluateRequest.arguments.expression = expr; evaluateRequest.arguments.frameId = frameId; var ret = VSCodeDebugger.Request(evaluateRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); EvaluateResponse evaluateResponse = JsonConvert.DeserializeObject <EvaluateResponse>(ret.ResponseStr); strRes = evaluateResponse.body.result; }
public void WasEntryPointHit(string caller_trace) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "entry")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); return(true); } return(false); }; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void WasStopped(string Reason, Breakpoint breakpoint) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", Reason)) { if (Reason == "breakpoint") { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); } return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } StackTraceRequest stackTraceRequest = new StackTraceRequest(); stackTraceRequest.arguments.threadId = threadId; stackTraceRequest.arguments.startFrame = 0; stackTraceRequest.arguments.levels = 20; var ret = VSCodeDebugger.Request(stackTraceRequest); Assert.True(ret.Success); Assert.Equal(BreakpointType.Line, breakpoint.Type); var lbp = (LineBreakpoint)breakpoint; StackTraceResponse stackTraceResponse = JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr); foreach (var Frame in stackTraceResponse.body.stackFrames) { if (Frame.line == lbp.NumLine && Frame.source.name == lbp.FileName // NOTE this code works only with one source file && Frame.source.path == DebuggeeInfo.SourceFilesPath) { return; } } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public static string CalcExpression(Int64?frameId, string Expression) { EvaluateRequest evaluateRequest = new EvaluateRequest(); evaluateRequest.arguments.expression = Expression; evaluateRequest.arguments.frameId = frameId; var ret = VSCodeDebugger.Request(evaluateRequest); Assert.True(ret.Success); EvaluateResponse evaluateResponse = JsonConvert.DeserializeObject <EvaluateResponse>(ret.ResponseStr); return(evaluateResponse.body.result); }
public void CheckErrorAtRequest(string caller_trace, Int64 frameId, string Expression, string errMsgStart) { EvaluateRequest evaluateRequest = new EvaluateRequest(); evaluateRequest.arguments.expression = Expression; evaluateRequest.arguments.frameId = frameId; var ret = VSCodeDebugger.Request(evaluateRequest); Assert.False(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); EvaluateResponse evaluateResponse = JsonConvert.DeserializeObject <EvaluateResponse>(ret.ResponseStr); Assert.True(evaluateResponse.message.StartsWith(errMsgStart), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void CalcAndCheckExpression(string caller_trace, Int64?frameId, string ExpectedResult, string Expression) { EvaluateRequest evaluateRequest = new EvaluateRequest(); evaluateRequest.arguments.expression = Expression; evaluateRequest.arguments.frameId = frameId; var ret = VSCodeDebugger.Request(evaluateRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); EvaluateResponse evaluateResponse = JsonConvert.DeserializeObject <EvaluateResponse>(ret.ResponseStr); Assert.Equal(ExpectedResult, evaluateResponse.body.result, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasBreakpointHitWithProperThreadID(string caller_trace, string bpName) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "breakpoint")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); return(true); } return(false); }; threadId = -1; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.True(isThredInThreadsList(@"__FILE__:__LINE__" + "\n" + caller_trace, threadId), @"__FILE__:__LINE__" + "\n" + caller_trace); StackTraceRequest stackTraceRequest = new StackTraceRequest(); stackTraceRequest.arguments.threadId = threadId; stackTraceRequest.arguments.startFrame = 0; stackTraceRequest.arguments.levels = 20; var ret = VSCodeDebugger.Request(stackTraceRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); Breakpoint breakpoint = ControlInfo.Breakpoints[bpName]; Assert.Equal(BreakpointType.Line, breakpoint.Type, @"__FILE__:__LINE__" + "\n" + caller_trace); var lbp = (LineBreakpoint)breakpoint; StackTraceResponse stackTraceResponse = JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr); foreach (var Frame in stackTraceResponse.body.stackFrames) { if (Frame.line == lbp.NumLine && Frame.source.name == lbp.FileName // NOTE this code works only with one source file && Frame.source.path == ControlInfo.SourceFilesPath) { return; } } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void WasPaused() { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "pause")) { return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public static void WasEntryPointHit() { string resJSON = VSCodeDebugger.Receive(-1); Assert.True(VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "entry")); foreach (var Event in VSCodeDebugger.EventList) { if (VSCodeDebugger.isResponseContainProperty(Event, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(Event, "reason", "entry")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(Event, "threadId")); break; } } }
public static void WasEntryPointHit() { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "entry")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public void TestExceptionInfo(string caller_trace, string excCategory, string excMode, string excName) { ExceptionInfoRequest exceptionInfoRequest = new ExceptionInfoRequest(); exceptionInfoRequest.arguments.threadId = threadId; var ret = VSCodeDebugger.Request(exceptionInfoRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); ExceptionInfoResponse exceptionInfoResponse = JsonConvert.DeserializeObject <ExceptionInfoResponse>(ret.ResponseStr); if (exceptionInfoResponse.body.breakMode == excMode && exceptionInfoResponse.body.exceptionId == excCategory + "/" + excName && exceptionInfoResponse.body.details.fullTypeName == excName) { return; } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
public void PrepareStart(string caller_trace) { InitializeRequest initializeRequest = new InitializeRequest(); initializeRequest.arguments.clientID = "vscode"; initializeRequest.arguments.clientName = "Visual Studio Code"; initializeRequest.arguments.adapterID = "coreclr"; initializeRequest.arguments.pathFormat = "path"; initializeRequest.arguments.linesStartAt1 = true; initializeRequest.arguments.columnsStartAt1 = true; initializeRequest.arguments.supportsVariableType = true; initializeRequest.arguments.supportsVariablePaging = true; initializeRequest.arguments.supportsRunInTerminalRequest = true; initializeRequest.arguments.locale = "en-us"; Assert.True(VSCodeDebugger.Request(initializeRequest).Success, @"__FILE__:__LINE__" + "\n" + caller_trace); LaunchRequest launchRequest = new LaunchRequest(); launchRequest.arguments.name = ".NET Core Launch (web)"; launchRequest.arguments.type = "coreclr"; launchRequest.arguments.preLaunchTask = "build"; string AbsolutePathToAssembly = Path.GetFullPath(ControlInfo.TargetAssemblyPath); launchRequest.arguments.program = Path.GetFileName(AbsolutePathToAssembly); string targetAssemblyPath = Path.GetFileName(AbsolutePathToAssembly); int subLength = AbsolutePathToAssembly.Length - targetAssemblyPath.Length; string dllPath = AbsolutePathToAssembly.Substring(0, subLength); launchRequest.arguments.cwd = dllPath; launchRequest.arguments.env = new Dictionary <string, string>(); launchRequest.arguments.env.Add("ASPNETCORE_ENVIRONMENT", "Development"); launchRequest.arguments.env.Add("ASPNETCORE_URLS", "https://*****:*****@"__FILE__:__LINE__" + "\n" + caller_trace); }
public int GetChildVariablesReference(string caller_trace, int VariablesReference, string VariableName) { VariablesRequest variablesRequest = new VariablesRequest(); variablesRequest.arguments.variablesReference = VariablesReference; var ret = VSCodeDebugger.Request(variablesRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); VariablesResponse variablesResponse = JsonConvert.DeserializeObject <VariablesResponse>(ret.ResponseStr); foreach (var Variable in variablesResponse.body.variables) { if (Variable.name == VariableName) { return(Variable.variablesReference); } } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }