From fd7da7650c054ee4eba290d62bea8d92485271f5 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 8 Nov 2022 18:01:04 -0300 Subject: [PATCH 1/2] DotnetDebugger.setDebuggerProperty does not depend of having a session. --- src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index 5b6bf24290f731..f56b45e78f7066 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -267,8 +267,11 @@ protected override async Task AcceptCommand(MessageId id, JObject parms, C if (pauseOnException != PauseOnExceptionsKind.Unset) _defaultPauseOnExceptions = pauseOnException; } - // for Dotnetdebugger.* messages, treat them as handled, thus not passing them on to the browser - return method.StartsWith("DotnetDebugger.", StringComparison.OrdinalIgnoreCase); + if (method != "DotnetDebugger.setDebuggerProperty") + { + // for Dotnetdebugger.* messages, treat them as handled, thus not passing them on to the browser + return method.StartsWith("DotnetDebugger.", StringComparison.OrdinalIgnoreCase); + } } switch (method) From 6cebadddee865313e2135870fda7f26e48aa7f2a Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 14 Nov 2022 16:59:42 -0300 Subject: [PATCH 2/2] addressing @radical comments --- src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs index f56b45e78f7066..ed451c9494b63b 100644 --- a/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs +++ b/src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs @@ -20,6 +20,7 @@ internal class MonoProxy : DevToolsProxy { private IList urlSymbolServerList; private HashSet sessions = new HashSet(); + private static readonly string[] s_executionContextIndependentCDPCommandNames = { "DotnetDebugger.setDebuggerProperty" }; protected Dictionary contexts = new Dictionary(); public static HttpClient HttpClient => new HttpClient(); @@ -258,7 +259,7 @@ protected override async Task AcceptCommand(MessageId id, JObject parms, C if (id == SessionId.Null) await AttachToTarget(id, token); - if (!contexts.TryGetValue(id, out ExecutionContext context)) + if (!contexts.TryGetValue(id, out ExecutionContext context) && !s_executionContextIndependentCDPCommandNames.Contains(method)) { if (method == "Debugger.setPauseOnExceptions") { @@ -267,11 +268,7 @@ protected override async Task AcceptCommand(MessageId id, JObject parms, C if (pauseOnException != PauseOnExceptionsKind.Unset) _defaultPauseOnExceptions = pauseOnException; } - if (method != "DotnetDebugger.setDebuggerProperty") - { - // for Dotnetdebugger.* messages, treat them as handled, thus not passing them on to the browser - return method.StartsWith("DotnetDebugger.", StringComparison.OrdinalIgnoreCase); - } + return method.StartsWith("DotnetDebugger.", StringComparison.OrdinalIgnoreCase); } switch (method)