[release/6.0-rc1] [wasm][debugger] Fixing assert while debugging. (#58032)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 24 Aug 2021 20:37:20 +0000 (16:37 -0400)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 20:37:20 +0000 (16:37 -0400)
When trying to evaluate DebuggerProxyAttribute of a generic type <T, K>, it was working only for one parameter .

Fixes #58021

Co-authored-by: Thays <thaystg@gmail.com>
src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
src/mono/wasm/debugger/DebuggerTestSuite/CustomViewTests.cs
src/mono/wasm/debugger/tests/debugger-test/debugger-custom-view-test.cs

index d804421..4182153 100644 (file)
@@ -2280,10 +2280,16 @@ namespace Microsoft.WebAssembly.Diagnostics
                             var assemblyNameArg = await GetFullAssemblyName(sessionId, assemblyIdArg, token);
                             var classNameArg = await GetTypeNameOriginal(sessionId, genericTypeArgs[k], token);
                             typeToSearch += classNameArg +", " + assemblyNameArg;
+                            if (k + 1 < genericTypeArgs.Count)
+                                typeToSearch += "], [";
+                            else
+                                typeToSearch += "]";
                         }
-                        typeToSearch += "]]";
+                        typeToSearch += "]";
                         typeToSearch +=  ", " + assemblyName;
                         var genericTypeId = await GetTypeByName(sessionId, typeToSearch, token);
+                        if (genericTypeId < 0)
+                            return null;
                         methodId = await GetMethodIdByName(sessionId, genericTypeId, ".ctor", token);
                     }
                     else
index 09bee32..fa188b1 100644 (file)
@@ -17,7 +17,7 @@ namespace DebuggerTests
         [Fact]
         public async Task UsingDebuggerDisplay()
         {
-            var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 6);
+            var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 12);
             var pause_location = await EvaluateAndCheck(
                 "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DebuggerCustomViewTest:run'); }, 1);",
                 "dotnet://debugger-test.dll/debugger-custom-view-test.cs",
@@ -34,7 +34,7 @@ namespace DebuggerTests
         [Fact]
         public async Task UsingDebuggerTypeProxy()
         {
-            var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 6);
+            var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 12);
             var pause_location = await EvaluateAndCheck(
                 "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DebuggerCustomViewTest:run'); }, 1);",
                 "dotnet://debugger-test.dll/debugger-custom-view-test.cs",
@@ -54,8 +54,13 @@ namespace DebuggerTests
             props = await GetObjectOnFrame(frame, "b");
             CheckString(props, "Val2", "one");
 
+            CheckObject(locals, "openWith", "System.Collections.Generic.Dictionary<string, string>", description: "Count = 3");
+            props = await GetObjectOnFrame(frame, "openWith");
+            Assert.Equal(1, props.Count());
+
             await EvaluateOnCallFrameAndCheck(frame["callFrameId"].Value<string>(),
                 ("listToTestToList.ToList()", TObject("System.Collections.Generic.List<int>", description: "Count = 11")));
+
         }
     }
 }
index ecdccf0..bd25c49 100644 (file)
@@ -67,6 +67,14 @@ namespace DebuggerTests
             var c = new DebuggerDisplayMethodTest();
             List<int> myList = new List<int>{ 1, 2, 3, 4 };
             var listToTestToList = System.Linq.Enumerable.Range(1, 11);
+
+            Dictionary<string, string> openWith = new Dictionary<string, string>();
+
+            openWith.Add("txt", "notepad");
+            openWith.Add("bmp", "paint");
+            openWith.Add("dib", "paint");
+            Console.WriteLine("break here");
+
             Console.WriteLine("break here");
         }
     }