Skip to content

Commit a6ccd53

Browse files
[release/6.0-rc1] [wasm][debugger] Fixing assert while debugging. (#58032)
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>
1 parent 949a0a0 commit a6ccd53

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2280,10 +2280,16 @@ public async Task<JArray> GetValuesFromDebuggerProxyAttribute(SessionId sessionI
22802280
var assemblyNameArg = await GetFullAssemblyName(sessionId, assemblyIdArg, token);
22812281
var classNameArg = await GetTypeNameOriginal(sessionId, genericTypeArgs[k], token);
22822282
typeToSearch += classNameArg +", " + assemblyNameArg;
2283+
if (k + 1 < genericTypeArgs.Count)
2284+
typeToSearch += "], [";
2285+
else
2286+
typeToSearch += "]";
22832287
}
2284-
typeToSearch += "]]";
2288+
typeToSearch += "]";
22852289
typeToSearch += ", " + assemblyName;
22862290
var genericTypeId = await GetTypeByName(sessionId, typeToSearch, token);
2291+
if (genericTypeId < 0)
2292+
return null;
22872293
methodId = await GetMethodIdByName(sessionId, genericTypeId, ".ctor", token);
22882294
}
22892295
else

src/mono/wasm/debugger/DebuggerTestSuite/CustomViewTests.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CustomViewTests : DebuggerTestBase
1717
[Fact]
1818
public async Task UsingDebuggerDisplay()
1919
{
20-
var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 6);
20+
var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 12);
2121
var pause_location = await EvaluateAndCheck(
2222
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DebuggerCustomViewTest:run'); }, 1);",
2323
"dotnet://debugger-test.dll/debugger-custom-view-test.cs",
@@ -34,7 +34,7 @@ public async Task UsingDebuggerDisplay()
3434
[Fact]
3535
public async Task UsingDebuggerTypeProxy()
3636
{
37-
var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 6);
37+
var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 12);
3838
var pause_location = await EvaluateAndCheck(
3939
"window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DebuggerCustomViewTest:run'); }, 1);",
4040
"dotnet://debugger-test.dll/debugger-custom-view-test.cs",
@@ -54,8 +54,13 @@ public async Task UsingDebuggerTypeProxy()
5454
props = await GetObjectOnFrame(frame, "b");
5555
CheckString(props, "Val2", "one");
5656

57+
CheckObject(locals, "openWith", "System.Collections.Generic.Dictionary<string, string>", description: "Count = 3");
58+
props = await GetObjectOnFrame(frame, "openWith");
59+
Assert.Equal(1, props.Count());
60+
5761
await EvaluateOnCallFrameAndCheck(frame["callFrameId"].Value<string>(),
5862
("listToTestToList.ToList()", TObject("System.Collections.Generic.List<int>", description: "Count = 11")));
63+
5964
}
6065
}
6166
}

src/mono/wasm/debugger/tests/debugger-test/debugger-custom-view-test.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ public static void run()
6767
var c = new DebuggerDisplayMethodTest();
6868
List<int> myList = new List<int>{ 1, 2, 3, 4 };
6969
var listToTestToList = System.Linq.Enumerable.Range(1, 11);
70+
71+
Dictionary<string, string> openWith = new Dictionary<string, string>();
72+
73+
openWith.Add("txt", "notepad");
74+
openWith.Add("bmp", "paint");
75+
openWith.Add("dib", "paint");
76+
Console.WriteLine("break here");
77+
7078
Console.WriteLine("break here");
7179
}
7280
}

0 commit comments

Comments
 (0)