diff options
author | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-05-20 19:29:13 +0300 |
---|---|---|
committer | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-05-28 18:26:39 +0300 |
commit | 6a80d07570b7b731c735b2e2bd1f506ff6b659a8 (patch) | |
tree | 88c3c145a5b9b347e02cb247b84911c3c60db022 /main | |
parent | 9be6c2239978cff2d3edd3c5ba8f37642c7dcd1b (diff) |
[VSCodeDebugProtocol] stylistic fixes
Diffstat (limited to 'main')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs index 592bb7db72..c7673f0bd6 100644 --- a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs +++ b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs @@ -317,12 +317,36 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol bool? EvaluateCondition (int frameId, string exp) { var response = protocolClient.SendRequestSync (new EvaluateRequest (exp, frameId)).Result; + if (bool.TryParse (response, out var result)) return result; + OnDebuggerOutput (false, $"The condition for an exception catchpoint failed to execute. The condition was '{exp}'. The error returned was '{response}'.\n"); + return null; } + bool ShouldStopOnExceptionCatchpoint (Catchpoint catchpoint, int frameId) + { + if (!catchpoint.Enabled) + return false; + + // global:: is necessary if the exception type is contained in current namespace, + // and it also contains a class with the same name as the namespace itself. + // Example: "Tests.Tests" and "Tests.TestException" + var qualifiedExceptionType = catchpoint.ExceptionName.Contains ("::") ? catchpoint.ExceptionName : $"global::{catchpoint.ExceptionName}"; + + if (catchpoint.IncludeSubclasses) { + if (!EvaluateCondition (frameId, $"$exception is {qualifiedExceptionType}")) + return false; + } else { + if (!EvaluateCondition (frameId, $"$exception.GetType() == typeof({qualifiedExceptionType})")) + return false; + } + + return string.IsNullOrWhiteSpace (catchpoint.ConditionExpression) || EvaluateCondition (frameId, catchpoint.ConditionExpression); + } + protected void HandleEvent (object sender, EventReceivedEventArgs obj) { Task.Run (() => { @@ -360,29 +384,9 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol args = new TargetEventArgs (TargetEventType.TargetStopped); break; case StoppedEvent.ReasonValue.Exception: - stackFrame = (VsCodeStackFrame)this.GetThreadBacktrace (body.ThreadId ?? -1).GetFrame (0); - - bool ShouldStopOnExceptionCatchpoint(Catchpoint e) - { - if (!e.Enabled) - return false; - var qualifiedExceptionType = e.ExceptionName.Contains ("::") ? e.ExceptionName : $"global::{e.ExceptionName}"; - // global:: is necessary if the exception type is contained in current namespace, - // and it also contains a class with the same name as the namespace itself. - // Example: "Tests.Tests" and "Tests.TestException" - if (e.IncludeSubclasses) { - if (EvaluateCondition (stackFrame.frameId, $"$exception is {qualifiedExceptionType}") == false) - return false; - } - else { - if (EvaluateCondition (stackFrame.frameId, $"$exception.GetType() == typeof({qualifiedExceptionType})") == false) - return false; - } - return string.IsNullOrWhiteSpace (e.ConditionExpression) || EvaluateCondition (stackFrame.frameId, e.ConditionExpression) != false; - } + stackFrame = (VsCodeStackFrame) this.GetThreadBacktrace (body.ThreadId ?? -1).GetFrame (0); - if (!breakpoints.Select (b => b.Key).OfType<Catchpoint> ().Any (ShouldStopOnExceptionCatchpoint)) - { + if (!breakpoints.Select (b => b.Key).OfType<Catchpoint> ().Any (c => ShouldStopOnExceptionCatchpoint (c, stackFrame.frameId))) { OnContinue (); return; } |