From 98bae6c8c8c9f923974e9b58e18dd52831be19b5 Mon Sep 17 00:00:00 2001 From: Thays Date: Mon, 2 Aug 2021 20:02:54 -0300 Subject: [PATCH 1/2] Created test case do close 47658. --- .../wasm/debugger/DebuggerTestSuite/Tests.cs | 27 +++++++++++++++++++ .../tests/debugger-test/debugger-test2.cs | 27 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs index 35bc79fcb0a27..2d7a86fd7d9be 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs @@ -826,6 +826,33 @@ public async Task GetSourceUsingSourceLink() Assert.True(source.IsOk); } + [Fact] + public async Task GetObjectValueWithInheritance() + { + var pause_location = await EvaluateAndCheck( + "window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);", + "dotnet://debugger-test.dll/debugger-test2.cs", 83, 4, + "TestWatchWithInheritance"); + var frame_id = pause_location["callFrames"][0]["callFrameId"].Value(); + var frame_locals = await GetProperties(frame_id); + var test_props = await GetObjectOnLocals(frame_locals, "test"); + Console.WriteLine($"test_props - {test_props}"); + await CheckProps(test_props, new + { + j = TNumber(20), + i = TNumber(50), + k = TNumber(30), + GetJ = TGetter("GetJ"), + GetI = TGetter("GetI"), + GetK = TGetter("GetK") + }, "test_props"); + await EvaluateOnCallFrameAndCheck(frame_id, + ($"test.GetJ", TNumber(20)), + ($"test.GetI", TNumber(50)), + ($"test.GetK", TNumber(30)) + ); + } + //TODO add tests covering basic stepping behavior as step in/out/over } } diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs b/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs index b9d97c8e23484..d360819356479 100644 --- a/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs +++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-test2.cs @@ -56,3 +56,30 @@ public static void BreakOnDebuggerBreakCommand() Debugger.Break(); } } + +public class TestParent2 +{ + public int k = 30; + public int GetK => k; +} + +public class TestParent : TestParent2 +{ + public int j = 20; + public int GetJ => j; +} + +public class TestChild : TestParent +{ + public int i = 50; + public int GetI => i; + public TestChild() + { + Console.WriteLine("Hi"); + } + public static void TestWatchWithInheritance() + { + TestChild test = new TestChild(); + Debugger.Break(); + } +} From 14cc371cba40f8ae6785444c237e87f740766fac Mon Sep 17 00:00:00 2001 From: Thays Date: Tue, 3 Aug 2021 10:53:55 -0300 Subject: [PATCH 2/2] Moving test to file that @radical suggested. --- .../DebuggerTestSuite/GetPropertiesTests.cs | 26 ++++++++++++++++++ .../wasm/debugger/DebuggerTestSuite/Tests.cs | 27 ------------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs index 3215ef1184d89..6b4dcd65900be 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/GetPropertiesTests.cs @@ -335,6 +335,32 @@ public async Task GetPropertiesTestJSAndManaged(bool test_js, bool? own_properti AssertEqual(expected_names.Length, filtered_props.Count(), $"expected number of properties"); } + [Fact] + public async Task GetObjectValueWithInheritance() + { + var pause_location = await EvaluateAndCheck( + "window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);", + "dotnet://debugger-test.dll/debugger-test2.cs", 83, 4, + "TestWatchWithInheritance"); + var frame_id = pause_location["callFrames"][0]["callFrameId"].Value(); + var frame_locals = await GetProperties(frame_id); + var test_props = await GetObjectOnLocals(frame_locals, "test"); + await CheckProps(test_props, new + { + j = TNumber(20), + i = TNumber(50), + k = TNumber(30), + GetJ = TGetter("GetJ"), + GetI = TGetter("GetI"), + GetK = TGetter("GetK") + }, "test_props"); + await EvaluateOnCallFrameAndCheck(frame_id, + ($"test.GetJ", TNumber(20)), + ($"test.GetI", TNumber(50)), + ($"test.GetK", TNumber(30)) + ); + } + private async Task CheckExpectedProperties(string[] expected_names, Func get_actual_prop, Dictionary all_props) { foreach (var exp_name in expected_names) diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs index 2d7a86fd7d9be..35bc79fcb0a27 100644 --- a/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs +++ b/src/mono/wasm/debugger/DebuggerTestSuite/Tests.cs @@ -826,33 +826,6 @@ public async Task GetSourceUsingSourceLink() Assert.True(source.IsOk); } - [Fact] - public async Task GetObjectValueWithInheritance() - { - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] TestChild:TestWatchWithInheritance'); }, 1);", - "dotnet://debugger-test.dll/debugger-test2.cs", 83, 4, - "TestWatchWithInheritance"); - var frame_id = pause_location["callFrames"][0]["callFrameId"].Value(); - var frame_locals = await GetProperties(frame_id); - var test_props = await GetObjectOnLocals(frame_locals, "test"); - Console.WriteLine($"test_props - {test_props}"); - await CheckProps(test_props, new - { - j = TNumber(20), - i = TNumber(50), - k = TNumber(30), - GetJ = TGetter("GetJ"), - GetI = TGetter("GetI"), - GetK = TGetter("GetK") - }, "test_props"); - await EvaluateOnCallFrameAndCheck(frame_id, - ($"test.GetJ", TNumber(20)), - ($"test.GetI", TNumber(50)), - ($"test.GetK", TNumber(30)) - ); - } - //TODO add tests covering basic stepping behavior as step in/out/over } }