public VSCodeVariableSource(VSCodeDebuggerSession session, Variable variable, int parentVariablesReference, int frameId) : base(session, parentVariablesReference, frameId) { this.variable = variable; var actualType = GetActualTypeName(variable.Type); Flags = parentVariablesReference > 0 ? ObjectValueFlags.None : ObjectValueFlags.ReadOnly; Flags |= GetFlags(variable.PresentationHint); name = GetFixedVariableName(variable.Name); type = actualType.Replace(", ", ","); if (actualType != "void") { value = GetFixedValue(variable.Value, type, actualType); } else { value = "No return value."; } display = variable.Value; if (name[0] == '[') { Flags |= ObjectValueFlags.ArrayElement; } if (type == null || value == $"'{name}' threw an exception of type '{type}'") { Flags = ObjectValueFlags.Error; } }
public VSCodeObjectSource(VSCodeDebuggerSession vsCodeDebuggerSession, int variablesReference, int parentVariablesReference, string name, string type, string evalName, int frameId, string val) { this.vsCodeDebuggerSession = vsCodeDebuggerSession; this.parentVariablesReference = parentVariablesReference; this.variablesReference = variablesReference; this.evalName = evalName; this.frameId = frameId; if (type == null) { if (IsCSError(118, "is a namespace but is used like a variable", val, out string ns)) { this.display = this.name = this.val = ns; this.flags = ObjectValueFlags.Namespace; this.type = "<namespace>"; return; } if (IsCSError(119, "is a type, which is not valid in the given context", val, out string vtype)) { if (name.StartsWith("global::", StringComparison.Ordinal)) { vtype = name.Substring("global::".Length); } this.display = this.name = this.val = ObjectValueAdaptor.GetCSharpTypeName(vtype); this.flags = ObjectValueFlags.Type; this.type = "<type>"; return; } } var actualType = GetActualTypeName(type); this.flags = parentVariablesReference > 0 ? ObjectValueFlags.None : ObjectValueFlags.ReadOnly; this.type = actualType.Replace(", ", ","); this.name = GetFixedVariableName(name); if (actualType != "void") { this.val = GetFixedValue(val, this.type, actualType); } else { this.val = "No return value."; } this.display = val; if (this.name[0] == '[') { flags |= ObjectValueFlags.ArrayElement; } if (type == null || val == $"'{this.name}' threw an exception of type '{this.type}'") { flags |= ObjectValueFlags.Error; } }
public VSCodeEvaluationSource(VSCodeDebuggerSession session, string expression, EvaluateResponse response, int frameId) : base(session, 0, frameId) { this.expression = expression; this.response = response; // FIXME: can we use PresentationHint.Attributes == VariablePresentationHint.AttributesValue.FailedEvaluation instead? if (response.Type == null) { if (IsCSError(118, "is a namespace but is used like a variable", response.Result, out string ns)) { Flags = ObjectValueFlags.Namespace; display = name = value = ns; type = "<namespace>"; return; } if (IsCSError(119, "is a type, which is not valid in the given context", response.Result, out string vtype)) { if (expression.StartsWith("global::", StringComparison.Ordinal)) { vtype = expression.Substring("global::".Length); } display = name = value = ObjectValueAdaptor.GetCSharpTypeName(vtype); Flags = ObjectValueFlags.Type; type = "<type>"; return; } } var actualType = GetActualTypeName(response.Type); Flags = GetFlags(response.PresentationHint); type = actualType.Replace(", ", ","); name = expression; if (actualType != "void") { value = GetFixedValue(response.Result, type, actualType); } else { value = "No return value."; } display = response.Result; if (name[0] == '[') { Flags |= ObjectValueFlags.ArrayElement; } if (type == null || value == $"'{name}' threw an exception of type '{type}'") { Flags = ObjectValueFlags.Error; } }
public VSCodeObjectSource(VSCodeDebuggerSession vsCodeDebuggerSession, int variablesReference, int parentVariablesReference, string name, string type, string evalName, int frameId, string val) { this.type = type; this.frameId = frameId; this.evalName = evalName; this.name = name; this.vsCodeDebuggerSession = vsCodeDebuggerSession; this.variablesReference = variablesReference; this.parentVariablesReference = parentVariablesReference; this.val = val; }
public VSCodeDebuggerBacktrace(VSCodeDebuggerSession vsCodeDebuggerSession, int threadId) { this.threadId = threadId; this.vsCodeDebuggerSession = vsCodeDebuggerSession; frame0Format = VsCodeStackFrame.GetStackFrameFormat(vsCodeDebuggerSession.EvaluationOptions); var body = vsCodeDebuggerSession.protocolClient.SendRequestSync(new StackTraceRequest(threadId, 0, 1, frame0Format)); totalFramesCount = body.TotalFrames ?? 0; frames = new Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages.StackFrame [totalFramesCount]; if (totalFramesCount > 0 && body.StackFrames.Count > 0) { frames [0] = body.StackFrames [0]; } }
public VSCodeObjectSource(VSCodeDebuggerSession vsCodeDebuggerSession, int variablesReference, int parentVariablesReference, string name, string type, string evalName, int frameId, string val) { this.type = type ?? string.Empty; this.frameId = frameId; this.evalName = evalName; var indexOfType = name.LastIndexOf(" [", StringComparison.Ordinal); if (indexOfType != -1) { name = name.Remove(indexOfType); } this.name = name; this.vsCodeDebuggerSession = vsCodeDebuggerSession; this.variablesReference = variablesReference; this.parentVariablesReference = parentVariablesReference; this.val = val; }
public VSCodeDebuggerBacktrace(VSCodeDebuggerSession session, int threadId) { this.session = session; this.threadId = threadId; format = VsCodeStackFrame.GetStackFrameFormat(session.EvaluationOptions); var response = session.protocolClient.SendRequestSync(new StackTraceRequest(threadId) { StartFrame = 0, Levels = 1, Format = format }); FrameCount = response.TotalFrames ?? 0; frames = new VsStackFrame[FrameCount]; scopes = new List <Scope> [FrameCount]; if (FrameCount > 0 && response.StackFrames.Count > 0) { frames[0] = response.StackFrames[0]; } }
internal static ObjectValue VsCodeVariableToObjectValue(VSCodeDebuggerSession vsCodeDebuggerSession, string name, string evalName, string type, string value, int variablesReference, int parentVariablesReference, int frameId) { return(new VSCodeObjectSource(vsCodeDebuggerSession, variablesReference, parentVariablesReference, name, type, evalName, frameId, value).GetValue(default(ObjectPath), null)); }
protected VSCodeObjectSource(VSCodeDebuggerSession session, int parentVariablesReference, int frameId) { ParentVariablesReference = parentVariablesReference; Session = session; FrameId = frameId; }