diff options
author | Michael Belyaev <usrsse2@me.com> | 2019-05-14 17:27:51 +0300 |
---|---|---|
committer | Jeffrey Stedfast <jestedfa@microsoft.com> | 2019-05-28 18:26:39 +0300 |
commit | 9be6c2239978cff2d3edd3c5ba8f37642c7dcd1b (patch) | |
tree | 4151f647d6a0cde70fa54c9d6b154241d8607f1e /main | |
parent | 75f0d3d66dbe68cf047948dc88c143257bb12a8f (diff) |
Refactor long condition to local function
Diffstat (limited to 'main')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VSCodeDebuggerSession.cs | 26 |
1 files changed, 21 insertions, 5 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 7aa028d0a2..592bb7db72 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 @@ -361,11 +361,27 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol break; case StoppedEvent.ReasonValue.Exception: stackFrame = (VsCodeStackFrame)this.GetThreadBacktrace (body.ThreadId ?? -1).GetFrame (0); - if (!breakpoints.Select (b => b.Key).OfType<Catchpoint> ().Any (e => - e.Enabled && - (e.ExceptionName.Contains ("::") ? e.ExceptionName : $"global::{e.ExceptionName}") is var qualifiedExceptionType && // 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" - (e.IncludeSubclasses && EvaluateCondition(stackFrame.frameId, $"$exception is {qualifiedExceptionType}") != false || !e.IncludeSubclasses && EvaluateCondition(stackFrame.frameId, $"$exception.GetType() == typeof({qualifiedExceptionType})") != false) && - (string.IsNullOrWhiteSpace(e.ConditionExpression) || EvaluateCondition (stackFrame.frameId, e.ConditionExpression) != false))) + + 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; + } + + if (!breakpoints.Select (b => b.Key).OfType<Catchpoint> ().Any (ShouldStopOnExceptionCatchpoint)) { OnContinue (); return; |