From de9a61dba0f12692df6ab0a007fa3b0dc01e8511 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 10 Apr 2025 11:17:02 +0200 Subject: [PATCH] this is tested elsewhere --- src/mono/browser/Makefile | 10 - .../debugger/DebuggerTestSuite/ArrayTests.cs | 771 ------ .../DebuggerTestSuite/AssignmentTests.cs | 83 - .../debugger/DebuggerTestSuite/AsyncTests.cs | 173 -- .../DebuggerTestSuite/BadHarnessInitTests.cs | 41 - .../DebuggerTestSuite/BreakpointTests.cs | 923 ------- .../DebuggerTestSuite/BrowserLocator.cs | 86 - .../DebuggerTestSuite/CallFunctionOnTests.cs | 964 ------- .../DebuggerTestSuite/ChromeProvider.cs | 178 -- .../DebuggerTestSuite/CustomViewTests.cs | 146 -- .../DebuggerTestSuite/DateTimeTests.cs | 87 - .../DebuggerTestSuite/DebuggerTestBase.cs | 1714 ------------ .../DebuggerTestSuite/DebuggerTestFirefox.cs | 492 ---- .../DebuggerTestSuite.csproj | 153 -- .../DebuggerTestSuite/DelegateTests.cs | 308 --- .../DebuggerTestSuite/DevToolsClient.cs | 76 - .../DebuggerTestSuite/Directory.Build.props | 4 - .../DebuggerTestSuite/EnvironmentVariables.cs | 28 - .../EvaluateOnCallFrame2Tests.cs | 856 ------ .../EvaluateOnCallFrameTests.cs | 937 ------- .../DebuggerTestSuite/ExceptionTests.cs | 375 --- .../FirefoxInspectorClient.cs | 270 -- .../DebuggerTestSuite/FirefoxProvider.cs | 150 -- .../DebuggerTestSuite/GetPropertiesTests.cs | 665 ----- .../DebuggerTestSuite/HarnessTests.cs | 82 - .../DebuggerTestSuite/HotReloadTests.cs | 730 ------ .../debugger/DebuggerTestSuite/Inspector.cs | 469 ---- .../DebuggerTestSuite/InspectorClient.cs | 109 - .../debugger/DebuggerTestSuite/MiscTests.cs | 1223 --------- .../debugger/DebuggerTestSuite/MonoJsTests.cs | 169 -- .../DebuggerTestSuite/PointerTests.cs | 559 ---- .../debugger/DebuggerTestSuite/README.md | 5 - .../DebuggerTestSuite/SetNextIpTests.cs | 288 -- .../SetVariableValueTests.cs | 325 --- .../debugger/DebuggerTestSuite/Settings.cs | 13 - .../DebuggerTestSuite/SteppingTests.cs | 1190 --------- .../DebuggerTestSuite/TestEnvironment.cs | 42 - .../DebuggerTestSuite/TestExtensions.cs | 16 - .../DebuggerTestSuite/TestHarnessOptions.cs | 22 - .../DebuggerTestSuite/TestHarnessProxy.cs | 175 -- .../DebuggerTestSuite/TestHarnessStartup.cs | 208 -- .../DebuggerTestSuite/WasmHostProvider.cs | 127 - .../DebuggerTestSuite/appsettings.json | 15 - .../Wasm.Debugger.Tests/Directory.Build.props | 7 - .../Directory.Build.targets | 9 - .../Wasm.Debugger.Tests.csproj | 88 - .../data/RunScriptTemplate.cmd | 32 - .../data/RunScriptTemplate.sh | 21 - .../ApplyUpdateReferencedAssembly.csproj | 36 - .../MethodBody0.cs | 15 - .../MethodBody1.cs | 134 - .../MethodBody1_v1.cs | 141 - .../MethodBody1_v2.cs | 141 - .../deltascript.json | 7 - .../ApplyUpdateReferencedAssembly2.csproj | 35 - .../MethodBody2.cs | 17 - .../MethodBody2_v1.cs | 23 - .../MethodBody2_v2.cs | 29 - .../deltascript.json | 7 - .../ApplyUpdateReferencedAssembly3.csproj | 34 - .../MethodBody2.cs | 23 - .../MethodBody2_v1.cs | 25 - .../MethodBody2_v2.cs | 29 - .../deltascript.json | 7 - ...emblyChineseCharInPath\343\204\250.csproj" | 36 - .../MethodBody0.cs" | 15 - .../MethodBody1.cs" | 60 - .../MethodBody1_v1.cs" | 87 - .../MethodBody1_v2.cs" | 106 - .../deltascript.json" | 7 - .../debugger/tests/Directory.Build.props | 23 - .../debugger/tests/Directory.Build.targets | 4 - ...-chinese-char-in-path-\343\204\250.csproj" | 6 - .../test.cs" | 10 - .../debugger-test-special-char-in-path.csproj | 5 - ...on-ascii-test-\304\205\305\202\303\205.cs" | 10 - .../test#.cs | 10 - .../debugger-test-vb/debugger-test-vb.vb | 30 - .../debugger-test-vb/debugger-test-vb.vbproj | 8 - ...gger-test-with-colon-in-source-name.csproj | 1 - .../debugger-test-with-full-debug-type.csproj | 5 - .../test.cs | 20 - ...ugger-test-with-non-user-code-class.csproj | 4 - .../test.cs | 41 - .../debugger-test-with-pdb-deleted.csproj | 9 - .../debugger-test-with-pdb-deleted/test.cs | 23 - .../debugger-test-with-source-link.csproj | 15 - .../debugger-test-with-source-link/test.cs | 21 - ...-test-without-debug-symbols-to-load.csproj | 6 - .../test.cs | 35 - ...debugger-test-without-debug-symbols.csproj | 6 - .../test.cs | 23 - .../tests/debugger-test/BindStaticMethod.cs | 355 --- .../debugger-test/debugger-array-test.cs | 464 ---- .../debugger-test/debugger-assignment-test.cs | 234 -- .../debugger-test/debugger-async-step.cs | 60 - .../debugger-test/debugger-async-test.cs | 347 --- .../tests/debugger-test/debugger-cfo-test.cs | 83 - .../debugger-custom-view-test.cs | 124 - .../debugger-test/debugger-datetime-test.cs | 29 - .../tests/debugger-test/debugger-driver.html | 109 - .../debugger-test/debugger-evaluate-test.cs | 2317 ----------------- .../debugger-test/debugger-exception-test.cs | 91 - .../debugger-get-properties-test.cs | 424 --- .../tests/debugger-test/debugger-main.js | 68 - .../debugger-test/debugger-nullable-test.cs | 40 - .../debugger-test/debugger-pointers-test.cs | 112 - .../debugger-set-variable-value-test.cs | 27 - .../tests/debugger-test/debugger-test.cs | 1687 ------------ .../tests/debugger-test/debugger-test.csproj | 123 - .../tests/debugger-test/debugger-test2.cs | 141 - .../debugger-test/debugger-valuetypes-test.cs | 267 -- .../tests/debugger-test/dependency.cs | 46 - .../tests/debugger-test/non-wasm-page.html | 12 - .../debugger/tests/debugger-test/other.js | 103 - .../wasm-page-without-assets.html | 24 - .../debugger/tests/debugger-test/weather.json | 32 - ...-chinese-char-in-path-\343\204\250.csproj" | 2 - .../lazy-debugger-test.cs" | 25 - .../lazy-debugger-test-embedded.cs | 13 - .../lazy-debugger-test-embedded.csproj | 5 - .../lazy-debugger-test/lazy-debugger-test.cs | 25 - .../lazy-debugger-test.csproj | 2 - .../library-dependency-debugger-test1.cs | 27 - .../library-dependency-debugger-test1.csproj | 5 - .../library-dependency-debugger-test2.cs | 8 - .../library-dependency-debugger-test2.csproj | 2 - src/mono/wasi/Makefile | 16 - src/mono/wasm/sln/WasmBuild.sln | 8 - src/mono/wasm/threads.md | 7 - 130 files changed, 24207 deletions(-) delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/ArrayTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/AssignmentTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/AsyncTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/BadHarnessInitTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/BreakpointTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/BrowserLocator.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/CallFunctionOnTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/ChromeProvider.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/CustomViewTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/DateTimeTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestBase.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestFirefox.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/DelegateTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/Directory.Build.props delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/EnvironmentVariables.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrame2Tests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrameTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/FirefoxInspectorClient.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/FirefoxProvider.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/GetPropertiesTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/HarnessTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/HotReloadTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/InspectorClient.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/MonoJsTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/PointerTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/README.md delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/SetNextIpTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/SetVariableValueTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/Settings.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/SteppingTests.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/TestEnvironment.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/TestExtensions.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/TestHarnessOptions.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/TestHarnessProxy.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/TestHarnessStartup.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/WasmHostProvider.cs delete mode 100644 src/mono/browser/debugger/DebuggerTestSuite/appsettings.json delete mode 100644 src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.props delete mode 100644 src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.targets delete mode 100644 src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj delete mode 100644 src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.cmd delete mode 100644 src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.sh delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody0.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v1.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v2.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/deltascript.json delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/ApplyUpdateReferencedAssembly2.csproj delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v1.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v2.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/deltascript.json delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/ApplyUpdateReferencedAssembly3.csproj delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v1.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v2.cs delete mode 100644 src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/deltascript.json delete mode 100644 "src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250.csproj" delete mode 100644 "src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody0.cs" delete mode 100644 "src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1.cs" delete mode 100644 "src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v1.cs" delete mode 100644 "src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v2.cs" delete mode 100644 "src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/deltascript.json" delete mode 100644 src/mono/browser/debugger/tests/Directory.Build.props delete mode 100644 src/mono/browser/debugger/tests/Directory.Build.targets delete mode 100644 "src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/debugger-test-chinese-char-in-path-\343\204\250.csproj" delete mode 100644 "src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/test.cs" delete mode 100644 src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/debugger-test-special-char-in-path.csproj delete mode 100644 "src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/non-ascii-test-\304\205\305\202\303\205.cs" delete mode 100644 src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/test#.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vb delete mode 100644 src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vbproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-colon-in-source-name/debugger-test-with-colon-in-source-name.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/debugger-test-with-full-debug-type.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/debugger-test-with-pdb-deleted.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-source-link/debugger-test-with-source-link.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-with-source-link/test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/debugger-test-without-debug-symbols.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/BindStaticMethod.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-array-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-assignment-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-async-step.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-async-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-cfo-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-custom-view-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-datetime-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-driver.html delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-evaluate-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-exception-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-get-properties-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-main.js delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-nullable-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-pointers-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-set-variable-value-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-test2.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/debugger-valuetypes-test.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/dependency.cs delete mode 100644 src/mono/browser/debugger/tests/debugger-test/non-wasm-page.html delete mode 100644 src/mono/browser/debugger/tests/debugger-test/other.js delete mode 100644 src/mono/browser/debugger/tests/debugger-test/wasm-page-without-assets.html delete mode 100644 src/mono/browser/debugger/tests/debugger-test/weather.json delete mode 100644 "src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test-chinese-char-in-path-\343\204\250.csproj" delete mode 100644 "src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test.cs" delete mode 100644 src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.cs delete mode 100644 src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.csproj delete mode 100644 src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.cs delete mode 100644 src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.csproj delete mode 100644 src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.cs delete mode 100644 src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.csproj delete mode 100644 src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.cs delete mode 100644 src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.csproj diff --git a/src/mono/browser/Makefile b/src/mono/browser/Makefile index bb0b68dda75cd0..4bb2240a0c4385 100644 --- a/src/mono/browser/Makefile +++ b/src/mono/browser/Makefile @@ -135,18 +135,8 @@ submit-tests-helix: $(_MSBUILD_WASM_BUILD_ARGS) \ $(MSBUILD_ARGS) -run-debugger-tests: - rm -f $(TOP)/artifacts/bin/DebuggerTestSuite/x64/Debug/*log; \ - if [ ! -z "$(TEST_FILTER)" ]; then \ - $(DOTNET) test $(TOP)/src/mono/browser/debugger/DebuggerTestSuite $(MSBUILD_ARGS) "-l:trx;LogFileName=DebuggerTestsResults.xml" --results-directory $(LOG_PATH) --filter "category!=failing&FullyQualifiedName$(TEST_FILTER)" $(TEST_ARGS); \ - else \ - $(DOTNET) test $(TOP)/src/mono/browser/debugger/DebuggerTestSuite $(MSBUILD_ARGS) "-l:trx;LogFileName=DebuggerTestsResults.xml" --results-directory $(LOG_PATH) --filter "category!=failing" $(TEST_ARGS); \ - fi - build-dbg-proxy: $(DOTNET) build $(TOP)/src/mono/browser/debugger/BrowserDebugHost $(MSBUILD_ARGS) -build-dbg-testsuite: - $(DOTNET) build $(TOP)/src/mono/browser/debugger/DebuggerTestSuite $(MSBUILD_ARGS) build-app-host: $(DOTNET) build $(TOP)/src/mono/wasm/host $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS) diff --git a/src/mono/browser/debugger/DebuggerTestSuite/ArrayTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/ArrayTests.cs deleted file mode 100644 index 2c559ef98f195d..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/ArrayTests.cs +++ /dev/null @@ -1,771 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class ArrayTests : DebuggerTests - { - public ArrayTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [Theory] - [InlineData(19, 8, "DebuggerTests.ArrayTestsClass.PrimitiveTypeLocals", false, 0, false)] - [InlineData(19, 8, "DebuggerTests.ArrayTestsClass.PrimitiveTypeLocals", false, 0, true)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, false)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, true)] - public async Task InspectPrimitiveTypeArrayLocals(int line, int col, string method_name, bool test_prev_frame, int frame_idx, bool use_cfo) => await TestSimpleArrayLocals( - line, col, - entry_method_name: "[debugger-test] DebuggerTests.ArrayTestsClass:PrimitiveTypeLocals", - method_name: method_name, - etype_name: "int", - local_var_name_prefix: "int", - array: new[] { TNumber(4), TNumber(70), TNumber(1) }, - array_elem_props: null, - test_prev_frame: test_prev_frame, - frame_idx: frame_idx, - use_cfo: use_cfo); - - [Theory] - [InlineData(36, 8, "DebuggerTests.ArrayTestsClass.ValueTypeLocals", false, 0, false)] - [InlineData(36, 8, "DebuggerTests.ArrayTestsClass.ValueTypeLocals", false, 0, true)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, false)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, true)] - public async Task InspectValueTypeArrayLocals(int line, int col, string method_name, bool test_prev_frame, int frame_idx, bool use_cfo) => await TestSimpleArrayLocals( - line, col, - entry_method_name: "[debugger-test] DebuggerTests.ArrayTestsClass:ValueTypeLocals", - method_name: method_name, - etype_name: "DebuggerTests.Point", - local_var_name_prefix: "point", - array: new[] - { - TValueType("DebuggerTests.Point"), - TValueType("DebuggerTests.Point"), - }, - array_elem_props: new[] - { - TPoint(5, -2, "point_arr#Id#0", "Green"), - TPoint(123, 0, "point_arr#Id#1", "Blue") - }, - test_prev_frame: test_prev_frame, - frame_idx: frame_idx, - use_cfo: use_cfo); - - [Theory] - [InlineData(54, 8, "DebuggerTests.ArrayTestsClass.ObjectTypeLocals", false, 0, false)] - [InlineData(54, 8, "DebuggerTests.ArrayTestsClass.ObjectTypeLocals", false, 0, true)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, false)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, true)] - public async Task InspectObjectArrayLocals(int line, int col, string method_name, bool test_prev_frame, int frame_idx, bool use_cfo) => await TestSimpleArrayLocals( - line, col, - entry_method_name: "[debugger-test] DebuggerTests.ArrayTestsClass:ObjectTypeLocals", - method_name: method_name, - etype_name: "DebuggerTests.SimpleClass", - local_var_name_prefix: "class", - array: new[] - { - TObject("DebuggerTests.SimpleClass"), - TObject("DebuggerTests.SimpleClass", is_null : true), - TObject("DebuggerTests.SimpleClass") - }, - array_elem_props: new[] - { - TSimpleClass(5, -2, "class_arr#Id#0", "Green"), - null, // Element is null - TSimpleClass(123, 0, "class_arr#Id#2", "Blue") - }, - test_prev_frame: test_prev_frame, - frame_idx: frame_idx, - use_cfo: use_cfo); - - [Theory] - [InlineData(72, 8, "DebuggerTests.ArrayTestsClass.GenericTypeLocals", false, 0, false)] - [InlineData(72, 8, "DebuggerTests.ArrayTestsClass.GenericTypeLocals", false, 0, true)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, false)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, true)] - public async Task InspectGenericTypeArrayLocals(int line, int col, string method_name, bool test_prev_frame, int frame_idx, bool use_cfo) => await TestSimpleArrayLocals( - line, col, - entry_method_name: "[debugger-test] DebuggerTests.ArrayTestsClass:GenericTypeLocals", - method_name: method_name, - etype_name: "DebuggerTests.GenericClass", - local_var_name_prefix: "gclass", - array: new[] - { - TObject("DebuggerTests.GenericClass", is_null : true), - TObject("DebuggerTests.GenericClass"), - TObject("DebuggerTests.GenericClass") - }, - array_elem_props: new[] - { - null, // Element is null - new - { - Id = TString("gclass_arr#1#Id"), - Color = TEnum("DebuggerTests.RGB", "Red"), - Value = TNumber(5) - }, - new - { - Id = TString("gclass_arr#2#Id"), - Color = TEnum("DebuggerTests.RGB", "Blue"), - Value = TNumber(-12) - } - }, - test_prev_frame: test_prev_frame, - frame_idx: frame_idx, - use_cfo: use_cfo); - - [Theory] - [InlineData(89, 8, "DebuggerTests.ArrayTestsClass.GenericValueTypeLocals", false, 0, false)] - [InlineData(89, 8, "DebuggerTests.ArrayTestsClass.GenericValueTypeLocals", false, 0, true)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, false)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, true)] - public async Task InspectGenericValueTypeArrayLocals(int line, int col, string method_name, bool test_prev_frame, int frame_idx, bool use_cfo) => await TestSimpleArrayLocals( - line, col, - entry_method_name: "[debugger-test] DebuggerTests.ArrayTestsClass:GenericValueTypeLocals", - method_name: method_name, - etype_name: "DebuggerTests.SimpleGenericStruct", - local_var_name_prefix: "gvclass", - array: new[] - { - TValueType("DebuggerTests.SimpleGenericStruct"), - TValueType("DebuggerTests.SimpleGenericStruct") - }, - array_elem_props: new[] - { - new - { - Id = TString("gvclass_arr#1#Id"), - Color = TEnum("DebuggerTests.RGB", "Red"), - Value = TPoint(100, 200, "gvclass_arr#1#Value#Id", "Red") - }, - new - { - Id = TString("gvclass_arr#2#Id"), - Color = TEnum("DebuggerTests.RGB", "Blue"), - Value = TPoint(10, 20, "gvclass_arr#2#Value#Id", "Green") - } - }, - test_prev_frame: test_prev_frame, - frame_idx: frame_idx, - use_cfo: use_cfo); - - [Theory] - [InlineData(213, 8, "DebuggerTests.ArrayTestsClass.GenericValueTypeLocals2", false, 0, false)] - [InlineData(213, 8, "DebuggerTests.ArrayTestsClass.GenericValueTypeLocals2", false, 0, true)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, false)] - [InlineData(100, 8, "DebuggerTests.ArrayTestsClass.YetAnotherMethod", true, 2, true)] - public async Task InspectGenericValueTypeArrayLocals2(int line, int col, string method_name, bool test_prev_frame, int frame_idx, bool use_cfo) => await TestSimpleArrayLocals( - line, col, - entry_method_name: "[debugger-test] DebuggerTests.ArrayTestsClass:GenericValueTypeLocals2", - method_name: method_name, - etype_name: "DebuggerTests.SimpleGenericStruct", - local_var_name_prefix: "gvclass", - array: new[] - { - TValueType("DebuggerTests.SimpleGenericStruct"), - TValueType("DebuggerTests.SimpleGenericStruct") - }, - array_elem_props: new[] - { - new - { - Id = TString("gvclass_arr#0#Id"), - Color = TEnum("DebuggerTests.RGB", "Red"), - Value = new [] - { - TPoint(100, 200, "gvclass_arr#0#0#Value#Id", "Red"), - TPoint(100, 200, "gvclass_arr#0#1#Value#Id", "Green") - } - }, - new - { - Id = TString("gvclass_arr#1#Id"), - Color = TEnum("DebuggerTests.RGB", "Blue"), - Value = new [] - { - TPoint(100, 200, "gvclass_arr#1#0#Value#Id", "Green"), - TPoint(100, 200, "gvclass_arr#1#1#Value#Id", "Blue") - } - } - }, - test_prev_frame: test_prev_frame, - frame_idx: frame_idx, - use_cfo: use_cfo); - - async Task GetObjectWithCFO(string objectId, JObject fn_args = null) - { - var fn_decl = "function () { return this; }"; - var cfo_args = JObject.FromObject(new - { - functionDeclaration = fn_decl, - objectId = objectId - }); - - if (fn_args != null) - cfo_args["arguments"] = fn_args; - - // callFunctionOn - var result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - - return await GetProperties(result.Value["result"]["objectId"]?.Value(), fn_args); - } - - async Task TestSimpleArrayLocals(int line, int col, string entry_method_name, string method_name, string etype_name, - string local_var_name_prefix, object[] array, object[] array_elem_props, - bool test_prev_frame = false, int frame_idx = 0, bool use_cfo = false) - { - // FIXME: - if (!RunningOnChrome) - { - if (use_cfo) - { - await Task.CompletedTask; - return; - } - } - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - UseCallFunctionOnBeforeGetProperties = use_cfo; - - await SetBreakpoint(debugger_test_loc, line, col); - - var eval_expr = "window.setTimeout(function() { invoke_static_method (" + - $"'{entry_method_name}', { (test_prev_frame ? "true" : "false") }" + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, method_name); - - var locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - Assert.Equal(4, locals.Count()); - await CheckArray(locals, $"{local_var_name_prefix}_arr", $"{etype_name}[]", $"{etype_name}[{array?.Length ?? 0}]"); - await CheckArray(locals, $"{local_var_name_prefix}_arr_empty", $"{etype_name}[]", $"{etype_name}[0]"); - await CheckObject(locals, $"{local_var_name_prefix}_arr_null", $"{etype_name}[]", is_null: true); - await CheckBool(locals, "call_other", test_prev_frame); - - var local_arr_name = $"{local_var_name_prefix}_arr"; - - JToken prefix_arr; - if (use_cfo) - { // Use `Runtime.callFunctionOn` to get the properties - var frame = pause_location["callFrames"][frame_idx]; - var name = local_arr_name; - var fl = await GetProperties(frame["callFrameId"].Value()); - var l_obj = GetAndAssertObjectWithName(locals, name); - var l_objectId = l_obj["value"]["objectId"]?.Value(); - - Assert.True(!String.IsNullOrEmpty(l_objectId), $"No objectId found for {name}"); - - prefix_arr = await GetObjectWithCFO(l_objectId); - } - else - { - prefix_arr = await GetObjectOnFrame(pause_location["callFrames"][frame_idx], local_arr_name); - } - - await CheckProps(prefix_arr, array, local_arr_name); - - if (array_elem_props?.Length > 0) - { - for (int i = 0; i < array_elem_props.Length; i++) - { - var i_str = i.ToString(); - var label = $"{local_var_name_prefix}_arr[{i}]"; - if (array_elem_props[i] == null) - { - var act_i = prefix_arr.FirstOrDefault(jt => jt["name"]?.Value() == i_str); - Assert.True(act_i != null, $"[{label}] Couldn't find array element [{i_str}]"); - - await CheckValue(act_i["value"], TObject(etype_name, is_null: true), label); - } - else - { - await CompareObjectPropertiesFor(prefix_arr, i_str, array_elem_props[i], label: label); - } - } - } - - var props = await GetObjectOnFrame(pause_location["callFrames"][frame_idx], $"{local_var_name_prefix}_arr_empty"); - await CheckProps(props, new object[0], "${local_var_name_prefix}_arr_empty"); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectObjectArrayMembers(bool use_cfo) - { - int line = 227; - int col = 12; - string entry_method_name = "[debugger-test] DebuggerTests.ArrayTestsClass:ObjectArrayMembers"; - string method_name = "DebuggerTests.Container.PlaceholderMethod"; - int frame_idx = 1; - - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - await SetBreakpoint(debugger_test_loc, line, col); - - var eval_expr = "window.setTimeout(function() { invoke_static_method (" + - $"'{entry_method_name}'" + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, method_name); - var locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - Assert.Single(locals); - await CheckObject(locals, "c", "DebuggerTests.Container"); - - var c_props = await GetObjectOnFrame(pause_location["callFrames"][frame_idx], "c"); - await CheckProps(c_props, new - { - id = TString("c#id"), - ClassArrayProperty = TArray("DebuggerTests.SimpleClass[]", "DebuggerTests.SimpleClass[3]"), - ClassArrayField = TArray("DebuggerTests.SimpleClass[]", "DebuggerTests.SimpleClass[3]"), - PointsProperty = TArray("DebuggerTests.Point[]", "DebuggerTests.Point[2]"), - PointsField = TArray("DebuggerTests.Point[]", "DebuggerTests.Point[2]") - }, - "c" - ); - - await CompareObjectPropertiesFor(c_props, "ClassArrayProperty", - new[] - { - TSimpleClass(5, -2, "ClassArrayProperty#Id#0", "Green"), - TSimpleClass(30, 1293, "ClassArrayProperty#Id#1", "Green"), - TObject("DebuggerTests.SimpleClass", is_null : true) - }, - label: "InspectLocalsWithStructsStaticAsync"); - - await CompareObjectPropertiesFor(c_props, "ClassArrayField", - new[] - { - TObject("DebuggerTests.SimpleClass", is_null : true), - TSimpleClass(5, -2, "ClassArrayField#Id#1", "Blue"), - TSimpleClass(30, 1293, "ClassArrayField#Id#2", "Green") - }, - label: "c#ClassArrayField"); - - await CompareObjectPropertiesFor(c_props, "PointsProperty", - new[] - { - TPoint(5, -2, "PointsProperty#Id#0", "Green"), - TPoint(123, 0, "PointsProperty#Id#1", "Blue"), - }, - label: "c#PointsProperty"); - - await CompareObjectPropertiesFor(c_props, "PointsField", - new[] - { - TPoint(5, -2, "PointsField#Id#0", "Green"), - TPoint(123, 0, "PointsField#Id#1", "Blue"), - }, - label: "c#PointsField"); - } - - [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task InspectValueTypeArrayLocalsStaticAsync(bool use_cfo) - { - int line = 157; - int col = 12; - string entry_method_name = "[debugger-test] DebuggerTests.ArrayTestsClass:ValueTypeLocalsAsync"; - string method_name = "DebuggerTests.ArrayTestsClass.ValueTypeLocalsAsync"; - int frame_idx = 0; - - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - await SetBreakpoint(debugger_test_loc, line, col); - - var eval_expr = "window.setTimeout(function() { invoke_static_method_async (" + - $"'{entry_method_name}', false" // *false* here keeps us only in the static method - + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, method_name); - var frame_locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - call_other = TBool(false), - gvclass_arr = TArray("DebuggerTests.SimpleGenericStruct[]", "DebuggerTests.SimpleGenericStruct[2]"), - gvclass_arr_empty = TArray("DebuggerTests.SimpleGenericStruct[]", "DebuggerTests.SimpleGenericStruct[0]"), - gvclass_arr_null = TObject("DebuggerTests.SimpleGenericStruct[]", is_null: true), - gvclass = TValueType("DebuggerTests.SimpleGenericStruct"), - // BUG: this shouldn't be null! - points = TObject("DebuggerTests.Point[]", is_null: true) - }, "ValueTypeLocalsAsync#locals"); - - var local_var_name_prefix = "gvclass"; - await CompareObjectPropertiesFor(frame_locals, local_var_name_prefix, new - { - Id = TString(null), - Color = TEnum("DebuggerTests.RGB", "Red"), - Value = TPoint(0, 0, null, "Red") - }); - - await CompareObjectPropertiesFor(frame_locals, $"{local_var_name_prefix}_arr", - new[] - { - new - { - Id = TString("gvclass_arr#1#Id"), - Color = TEnum("DebuggerTests.RGB", "Red"), - Value = TPoint(100, 200, "gvclass_arr#1#Value#Id", "Red") - }, - new - { - Id = TString("gvclass_arr#2#Id"), - Color = TEnum("DebuggerTests.RGB", "Blue"), - Value = TPoint(10, 20, "gvclass_arr#2#Value#Id", "Green") - } - } - ); - await CompareObjectPropertiesFor(frame_locals, $"{local_var_name_prefix}_arr_empty", - new object[0]); - } - - // TODO: Check previous frame too - [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task InspectValueTypeArrayLocalsInstanceAsync(bool use_cfo) - { - //Collect events - int line = 170; - int col = 12; - string entry_method_name = "[debugger-test] DebuggerTests.ArrayTestsClass:ValueTypeLocalsAsync"; - int frame_idx = 0; - - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - await SetBreakpoint(debugger_test_loc, line, col); - - var eval_expr = "window.setTimeout(function() { invoke_static_method_async (" + - $"'{entry_method_name}', true" + - "); }, 1);"; - - // BUG: Should be InspectValueTypeArrayLocalsInstanceAsync - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, "DebuggerTests.ArrayTestsClass.InstanceMethodValueTypeLocalsAsync>"); - - var frame_locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - t1 = TObject("DebuggerTests.SimpleGenericStruct"), - @this = TObject("DebuggerTests.ArrayTestsClass"), - point_arr = TArray("DebuggerTests.Point[]", "DebuggerTests.Point[2]"), - point = TValueType("DebuggerTests.Point") - }, "InspectValueTypeArrayLocalsInstanceAsync#locals"); - - await CompareObjectPropertiesFor(frame_locals, "t1", - new - { - Id = TString("gvclass_arr#1#Id"), - Color = TEnum("DebuggerTests.RGB", "Red"), - Value = TPoint(100, 200, "gvclass_arr#1#Value#Id", "Red") - }); - - await CompareObjectPropertiesFor(frame_locals, "point_arr", - new[] - { - TPoint(5, -2, "point_arr#Id#0", "Red"), - TPoint(123, 0, "point_arr#Id#1", "Blue"), - } - ); - - await CompareObjectPropertiesFor(frame_locals, "point", - TPoint(45, 51, "point#Id", "Green")); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectValueTypeArrayLocalsInAsyncStaticStructMethod(bool use_cfo) - { - int line = 244; - int col = 12; - string entry_method_name = "[debugger-test] DebuggerTests.ArrayTestsClass:EntryPointForStructMethod"; - int frame_idx = 0; - - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - await SetBreakpoint(debugger_test_loc, line, col); - //await SetBreakpoint (debugger_test_loc, 143, 3); - - var eval_expr = "window.setTimeout(function() { invoke_static_method_async (" + - $"'{entry_method_name}', false" + - "); }, 1);"; - - // BUG: Should be InspectValueTypeArrayLocalsInstanceAsync - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, "DebuggerTests.Point.AsyncMethod"); - - var frame_locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - call_other = TBool(false), - local_i = TNumber(5), - sc = TSimpleClass(10, 45, "sc#Id", "Blue") - }, "InspectValueTypeArrayLocalsInAsyncStaticStructMethod#locals"); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectValueTypeArrayLocalsInAsyncInstanceStructMethod(bool use_cfo) - { - int line = 251; - int col = 12; - string entry_method_name = "[debugger-test] DebuggerTests.ArrayTestsClass:EntryPointForStructMethod"; - int frame_idx = 0; - - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - await SetBreakpoint(debugger_test_loc, line, col); - - var eval_expr = "window.setTimeout(function() { invoke_static_method_async (" + - $"'{entry_method_name}', true" + - "); }, 1);"; - - // BUG: Should be InspectValueTypeArrayLocalsInstanceAsync - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, "DebuggerTests.Point.AsyncInstanceMethod"); - - var frame_locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - sc_arg = TObject("DebuggerTests.SimpleClass"), - @this = TValueType("DebuggerTests.Point"), - local_gs = TValueType("DebuggerTests.SimpleGenericStruct") - }, - "locals#0"); - - await CompareObjectPropertiesFor(frame_locals, "local_gs", - new - { - Id = TString("local_gs#Id"), - Color = TEnum("DebuggerTests.RGB", "Green"), - Value = TNumber(4) - }, - label: "local_gs#0"); - - await CompareObjectPropertiesFor(frame_locals, "sc_arg", - TSimpleClass(10, 45, "sc_arg#Id", "Blue"), - label: "sc_arg#0"); - - await CompareObjectPropertiesFor(frame_locals, "this", - TPoint(90, -4, "point#Id", "Green"), - label: "this#0"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InvalidArrayId() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.Container", "PlaceholderMethod", 1, "DebuggerTests.Container.PlaceholderMethod", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ArrayTestsClass:ObjectArrayMembers'); }, 1);", - wait_for_event_fn: async (pause_location) => - { - int frame_idx = 1; - var frame_locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - var c_obj = GetAndAssertObjectWithName(frame_locals, "c"); - var c_obj_id = c_obj["value"]?["objectId"]?.Value(); - Assert.NotNull(c_obj_id); - - // Invalid format - await GetProperties("dotnet:array:4123", expect_ok: false); - - // Trying to access object as an array - if (!DotnetObjectId.TryParse(c_obj_id, out var id) || id.Scheme != "object") - Assert.True(false, "Unexpected object id format. Maybe this test is out of sync with the object id format in dotnet.es6.lib.js?"); - - await GetProperties($"dotnet:array:{id.Value}", expect_ok: false); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InvalidAccessors() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.Container", "PlaceholderMethod", 1, "DebuggerTests.Container.PlaceholderMethod", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ArrayTestsClass:ObjectArrayMembers'); }, 1);", - locals_fn: async (locals) => - { - var this_obj = GetAndAssertObjectWithName(locals, "this"); - var this_obj_id = this_obj["value"]?["objectId"]?.Value(); - Assert.NotNull(this_obj_id); - - var this_props = await GetProperties(this_obj_id); - - var pf_arr = GetAndAssertObjectWithName(this_props, "PointsField"); - - // Validate the way we test the accessors, with a valid one - var res = await InvokeGetter(pf_arr, "0", expect_ok: true); - await CheckValue(res.Value["result"], TValueType("DebuggerTests.Point"), "pf_arr[0]"); - var pf_arr0_props = await GetProperties(res.Value["result"]["objectId"]?.Value()); - await CheckProps(pf_arr0_props, new - { - X = TNumber(5) - }, "pf_arr0_props", num_fields: 4); - - var invalid_accessors = new object[] { "NonExistent", "10000", "-2", 10000, -2, null, String.Empty }; - foreach (var invalid_accessor in invalid_accessors) - { - // var res = await InvokeGetter (JObject.FromObject (new { value = new { objectId = obj_id } }), invalid_accessor, expect_ok: true); - res = await InvokeGetter(pf_arr, invalid_accessor, expect_ok: true); - AssertEqual("undefined", res.Value["result"]?["type"]?.ToString(), "Expected to get undefined result for non-existent accessor"); - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectPrimitiveTypeMultiArrayLocals(bool use_cfo) - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - var eval_expr = "window.setTimeout(function() { invoke_static_method (" + - $"'[debugger-test] DebuggerTests.MultiDimensionalArray:run'" + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, 343, 12, "DebuggerTests.MultiDimensionalArray.run"); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - Assert.Equal(3, locals.Count()); - var int_arr_1 = !use_cfo ? - await GetProperties(locals[0]["value"]["objectId"].Value()) : - await GetObjectWithCFO((locals[0]["value"]["objectId"].Value())); - - CheckNumber(int_arr_1, "0", 0); - CheckNumber(int_arr_1, "1", 1); - var int_arr_2 = !use_cfo ? - await GetProperties(locals[1]["value"]["objectId"].Value()) : - await GetObjectWithCFO((locals[1]["value"]["objectId"].Value())); - CheckNumber(int_arr_2, "0, 0", 0); - CheckNumber(int_arr_2, "0, 1", 1); - CheckNumber(int_arr_2, "0, 2", 2); - CheckNumber(int_arr_2, "1, 0", 10); - CheckNumber(int_arr_2, "1, 1", 11); - CheckNumber(int_arr_2, "1, 2", 12); - - var int_arr_3 = !use_cfo ? - await GetProperties(locals[2]["value"]["objectId"].Value()) : - await GetObjectWithCFO((locals[2]["value"]["objectId"].Value())); - CheckNumber(int_arr_3, "0, 0, 0", 0); - CheckNumber(int_arr_3, "0, 0, 1", 1); - CheckNumber(int_arr_3, "0, 0, 2", 2); - CheckNumber(int_arr_3, "0, 1, 0", 10); - CheckNumber(int_arr_3, "0, 1, 1", 11); - CheckNumber(int_arr_3, "0, 1, 2", 12); - CheckNumber(int_arr_3, "0, 2, 0", 20); - CheckNumber(int_arr_3, "0, 2, 1", 21); - CheckNumber(int_arr_3, "0, 2, 2", 22); - CheckNumber(int_arr_3, "1, 0, 0", 100); - CheckNumber(int_arr_3, "1, 0, 1", 101); - CheckNumber(int_arr_3, "1, 0, 2", 102); - CheckNumber(int_arr_3, "1, 1, 0", 110); - CheckNumber(int_arr_3, "1, 1, 1", 111); - CheckNumber(int_arr_3, "1, 1, 2", 112); - CheckNumber(int_arr_3, "1, 2, 0", 120); - CheckNumber(int_arr_3, "1, 2, 1", 121); - CheckNumber(int_arr_3, "1, 2, 2", 122); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("s")] - [InlineData("classWithInlineArrayField.myInlineArray")] - [InlineData("classWithInlineArrayField.InlineArrayProp")] - [InlineData("classWithInlineArrayField.myStructWithInlineArray.myInlineArray")] - public async Task InspectInlineArray(string varName) - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - var eval_expr = "window.setTimeout(function() { invoke_static_method (" + - $"'[debugger-test] DebuggerTests.InlineArray:run'" + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, 442, 12, "DebuggerTests.InlineArray.run"); - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ($"{varName}[0]", TObject("DebuggerTests.InlineArray.E")), - ($"{varName}[a]", TObject("DebuggerTests.InlineArray.E")), - ($"{varName}[b]", TObject("DebuggerTests.InlineArray.E")), - ($"{varName}[1]", TObject("DebuggerTests.InlineArray.E"))); - var (_, res) = await EvaluateOnCallFrame(id,$"{varName}[43]", expect_ok: false); - Assert.Equal($"Unable to evaluate element access '{varName}[43]': Index is outside the bounds of the inline array", res.Error["result"]?["description"]?.Value()); - - var (s_zero, _) = await EvaluateOnCallFrame(id, $"{varName}[0]"); - await CheckValue(s_zero, TObject("DebuggerTests.InlineArray.E"), nameof(s_zero)); - var s_zero_props = await GetProperties(s_zero["objectId"]?.Value()); - await CheckProps(s_zero_props, new - { - x = TNumber(1), - y = TNumber(2), - o = TObject("DebuggerTests.InlineArray.One") - }, "s_zero_props#1"); - - var (s_one, _) = await EvaluateOnCallFrame(id, $"{varName}[1]"); - await CheckValue(s_one, TObject("DebuggerTests.InlineArray.E"), nameof(s_one)); - var ss_one_props = await GetProperties(s_one["objectId"]?.Value()); - await CheckProps(ss_one_props, new - { - x = TNumber(3), - y = TNumber(4), - o = TObject("DebuggerTests.InlineArray.Two") - }, "s_one_props#1"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InspectInlineArray2() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-array-test.cs"; - - var eval_expr = "window.setTimeout(function() { invoke_static_method (" + - $"'[debugger-test] DebuggerTests.InlineArray:run2'" + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, 460, 12, "DebuggerTests.InlineArray.run2"); - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ($"a2[0]", TNumber(1)), - ($"a3[0]", TNumber(2)), - ($"a4[0]", TObject("DebuggerTests.InlineArray.E")), - ($"Arr4.myStaticField", TNumber(50)), - ($"a2.InlineMethod(1)", TNumber(101)) - ); - - var (_, res) = await EvaluateOnCallFrame(id,$"a3[1]", expect_ok: false); - Assert.Equal($"Unable to evaluate element access 'a3[1]': Index is outside the bounds of the inline array", res.Error["result"]?["description"]?.Value()); - - var (s_zero, _) = await EvaluateOnCallFrame(id, $"a4[0]"); - await CheckValue(s_zero, TObject("DebuggerTests.InlineArray.E"), nameof(s_zero)); - var s_zero_props = await GetProperties(s_zero["objectId"]?.Value()); - await CheckProps(s_zero_props, new - { - x = TNumber(1), - y = TNumber(2), - o = TObject("DebuggerTests.InlineArray.One") - }, "s_zero_props#1"); - - var (s_one, _) = await EvaluateOnCallFrame(id, $"a4[1]"); - await CheckValue(s_one, TObject("DebuggerTests.InlineArray.E"), nameof(s_one)); - var ss_one_props = await GetProperties(s_one["objectId"]?.Value()); - await CheckProps(ss_one_props, new - { - x = TNumber(3), - y = TNumber(4), - o = TObject("DebuggerTests.InlineArray.Two") - }, "s_one_props#1"); - - var (s_two, _) = await EvaluateOnCallFrame(id, $"a4"); - await CheckValue(s_two, TObject("DebuggerTests.InlineArray.Arr4"), nameof(s_two)); - var s_two_props = await GetProperties(s_two["objectId"]?.Value()); - await CheckProps(s_two_props, new - { - myStaticField = TNumber(50), - e = TObject("DebuggerTests.InlineArray.E"), - Length = TNumber(42) - }, "s_two_props#1"); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/AssignmentTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/AssignmentTests.cs deleted file mode 100644 index ea2fc12f67e084..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/AssignmentTests.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace DebuggerTests -{ - public class AssignmentTests : DebuggerTests - { - public AssignmentTests(ITestOutputHelper testOutput) - : base(testOutput) - {} - - public static TheoryData GetTestData => new() - { - { "MONO_TYPE_OBJECT", TObject("object", is_null: true), TObject("object"), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_CLASS", TObject("DebuggerTests.MONO_TYPE_CLASS", is_null: true), TObject("DebuggerTests.MONO_TYPE_CLASS"), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_BOOLEAN", TBool(default), TBool(true), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_CHAR", TChar('\u0000'), TChar('a'), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_STRING", TString(default), TString("hello"), "DebuggerTests.StepInTest.TestedMethod"}, - - // [ActiveIssue("https://github.com/dotnet/runtime/issues/64188")] - // { "MONO_TYPE_ENUM", TEnum("DebuggerTests.RGB", "Red"), TEnum("DebuggerTests.RGB", "Blue"), "DebuggerTests.StepInTest.TestedMethod"}, - - { "MONO_TYPE_ARRAY", TObject("byte[]", is_null: true), TArray("byte[]", "byte[2]"), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_VALUETYPE", TValueType("DebuggerTests.Point"), TValueType("DebuggerTests.Point"), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_VALUETYPE2", TValueType("System.Decimal","0"), TValueType("System.Decimal", "1.1"), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_GENERICINST", TObject("System.Func", is_null: true), TDelegate("System.Func", "int Prepare ()"), "DebuggerTests.StepInTest>.TestedMethod"}, - - // Disabled due to https://github.com/dotnet/runtime/issues/65881 - //{ "MONO_TYPE_FNPTR", TPointer("*()", is_null: true), TPointer("*()") }, - - { "MONO_TYPE_PTR", TPointer("int*", is_null: true), TPointer("int*"), "DebuggerTests.MONO_TYPE_PTR.TestedMethod"}, - { "MONO_TYPE_I1", TNumber(0), TNumber(-1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_I2", TNumber(0), TNumber(-1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_I4", TNumber(0), TNumber(-1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_I8", TNumber(0), TNumber(-1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_U1", TNumber(0), TNumber(1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_U2", TNumber(0), TNumber(1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_U4", TNumber(0), TNumber(1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_U8", TNumber(0), TNumber(1), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_R4", TNumber(0), TNumber("3.1415"), "DebuggerTests.StepInTest.TestedMethod"}, - { "MONO_TYPE_R8", TNumber(0), TNumber("3.1415"), "DebuggerTests.StepInTest.TestedMethod"} - }; - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData("GetTestData")] - public async Task InspectVariableBeforeAndAfterAssignment(string clazz, JObject checkDefault, JObject checkValue, string methodName) - { - await SetBreakpointInMethod("debugger-test", "DebuggerTests." + clazz, "Prepare", 2); - await EvaluateAndCheck("window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests." + clazz + ":Prepare'); })", null, -1, -1, $"DebuggerTests.{clazz}.Prepare"); - - // 1) check un-assigned variables - await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-assignment-test.cs", -1, -1, methodName, - locals_fn: async (locals) => - { - int numLocals = locals.Count(); - if (numLocals != 2) - throw new XunitException($"Expected two locals but got {numLocals}. Locals: {locals}"); - await Check(locals, "r", checkDefault); - await Task.CompletedTask; - } - ); - - // 2) check assigned variables - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-assignment-test.cs", -1, -1, methodName, times: 3, - locals_fn: async (locals) => - { - int numLocals = locals.Count(); - if (numLocals != 2) - throw new XunitException($"Expected two locals but got {numLocals}. Locals: {locals}"); - await Check(locals, "r", checkValue); - await Task.CompletedTask; - } - ); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/AsyncTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/AsyncTests.cs deleted file mode 100644 index 592f6efec673d8..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/AsyncTests.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class AsyncTests : DebuggerTests - { - public AsyncTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - // FIXME: method with multiple async blocks - so that we have two separate classes for that method! - // FIXME: nested blocks - // FIXME: Confirm the actual bp location - // FIXME: check object properties.. - - //FIXME: function name - [ConditionalTheory(nameof(WasmSingleThreaded), nameof(RunningOnChrome))] - [InlineData("ContinueWithStaticAsync", "DebuggerTests.AsyncTests.ContinueWithTests.ContinueWithStaticAsync.AnonymousMethod__3_0")] - [InlineData("ContinueWithInstanceAsync", "DebuggerTests.AsyncTests.ContinueWithTests.ContinueWithInstanceAsync.AnonymousMethod__5_0")] - public async Task AsyncLocalsInContinueWith(string method_name, string expected_method_name) => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.AsyncTests.ContinueWithTests", method_name, 5, expected_method_name, - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - t = TObject("System.Threading.Tasks.Task.DelayPromise"), - code = TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), - @this = TObject("DebuggerTests.AsyncTests.ContinueWithTests.<>c"), - dt = TDateTime(new DateTime(4513, 4, 5, 6, 7, 8)) - }, "locals"); - - var res = await InvokeGetter(GetAndAssertObjectWithName(frame_locals, "t"), "Status"); - await CheckValue(res.Value["result"], TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), "t.Status"); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task AsyncLocalsInContinueWithInstanceUsingThisBlock() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.AsyncTests.ContinueWithTests", "ContinueWithInstanceUsingThisAsync", 5, "DebuggerTests.AsyncTests.ContinueWithTests.ContinueWithInstanceUsingThisAsync.AnonymousMethod__6_0", - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - t = TObject("System.Threading.Tasks.Task.DelayPromise"), - code = TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), - dt = TDateTime(new DateTime(4513, 4, 5, 6, 7, 8)), - @this = TObject("DebuggerTests.AsyncTests.ContinueWithTests") - }, "locals"); - - var res = await InvokeGetter(GetAndAssertObjectWithName(frame_locals, "t"), "Status"); - await CheckValue(res.Value["result"], TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), "t.Status"); - - res = await InvokeGetter(GetAndAssertObjectWithName(frame_locals, "this"), "Date"); - await CheckValue(res.Value["result"], TDateTime(new DateTime(2510, 1, 2, 3, 4, 5)), "this.Date"); - }); - - [Fact] // NestedContinueWith - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task AsyncLocalsInNestedContinueWithStaticBlock() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.AsyncTests.ContinueWithTests", "NestedContinueWithStaticAsync", 5, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithStaticAsync", - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - t = TObject("System.Threading.Tasks.Task.DelayPromise"), - code = TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion"), - str = TString("foobar"), - @this = TObject("DebuggerTests.AsyncTests.ContinueWithTests.<>c__DisplayClass4_0"), - ncs_dt0 = TDateTime(new DateTime(3412, 4, 6, 8, 0, 2)) - }, "locals"); - }); - - [ConditionalTheory(nameof(WasmSingleThreaded), nameof(RunningOnChrome))] - [InlineData("Run", 246, 16, 252, 16, "RunCSharpScope")] - [InlineData("RunContinueWith", 277, 20, 283, 20, "RunContinueWithSameVariableName")] - [InlineData("RunNestedContinueWith", 309, 24, 315, 24, "RunNestedContinueWithSameVariableName.AnonymousMethod__1")] - [InlineData("RunNonAsyncMethod", 334, 16, 340, 16, "RunNonAsyncMethodSameVariableName")] - public async Task InspectLocalsWithSameNameInDifferentScopesInAsyncMethod_CSharp(string method_to_run, int line1, int col1, int line2, int col2, string func_to_pause) - => await InspectLocalsWithSameNameInDifferentScopesInAsyncMethod( - $"[debugger-test] DebuggerTests.AsyncTests.VariablesWithSameNameDifferentScopes:{method_to_run}", - "dotnet://debugger-test.dll/debugger-async-test.cs", - line1, - col1, - line2, - col2, - $"DebuggerTests.AsyncTests.VariablesWithSameNameDifferentScopes.{func_to_pause}", - "testCSharpScope"); - - [Theory] - [InlineData("[debugger-test-vb] DebuggerTestVB.TestVbScope:Run", 14, 12, 22, 12, "DebuggerTestVB.TestVbScope.RunVBScope", "testVbScope")] - public async Task InspectLocalsWithSameNameInDifferentScopesInAsyncMethod_VB(string method_to_run, int line1, int col1, int line2, int col2, string func_to_pause, string variable_to_inspect) - => await InspectLocalsWithSameNameInDifferentScopesInAsyncMethod( - method_to_run, - "dotnet://debugger-test-vb.dll/debugger-test-vb.vb", - line1, - col1, - line2, - col2, - func_to_pause, - variable_to_inspect); - - private async Task InspectLocalsWithSameNameInDifferentScopesInAsyncMethod(string method_to_run, string source_to_pause, int line1, int col1, int line2, int col2, string func_to_pause, string variable_to_inspect) - { - var expression = $"{{ invoke_static_method('{method_to_run}'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - source_to_pause, line1, col1, - func_to_pause, - locals_fn: async (locals) => - { - await CheckString(locals, variable_to_inspect, "hello"); - await CheckString(locals, "onlyInFirstScope", "only-in-first-scope"); - Assert.False(locals.Any(jt => jt["name"]?.Value() == "onlyInSecondScope")); - } - ); - await StepAndCheck(StepKind.Resume, source_to_pause, line2, col2, func_to_pause, - locals_fn: async (locals) => - { - await CheckString(locals, variable_to_inspect, "hi"); - await CheckString(locals, "onlyInSecondScope", "only-in-second-scope"); - Assert.False(locals.Any(jt => jt["name"]?.Value() == "onlyInFirstScope")); - } - ); - } - - [Fact] - public async Task InspectLocalsInAsyncVBMethod() - { - var expression = $"{{ invoke_static_method('[debugger-test-vb] DebuggerTestVB.TestVbScope:Run'); }}"; - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test-vb.dll/debugger-test-vb.vb", 14, 12, - "DebuggerTestVB.TestVbScope.RunVBScope", - locals_fn: async (locals) => - { - await CheckString(locals, "testVbScope", "hello"); - CheckNumber(locals, "a", 10); - CheckNumber(locals, "data", 10); - } - ); - } - - [ConditionalFact(nameof(WasmSingleThreaded), nameof(RunningOnChrome))] - public async Task StepOutOfAsyncMethod() - { - await SetJustMyCode(true); - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "TestAsyncStepOut2", 2); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:TestAsyncStepOut'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 21, 12, - "DebuggerTests.AsyncStepClass.TestAsyncStepOut2"); - - await StepAndCheck(StepKind.Out, source_file, 16, 8, "DebuggerTests.AsyncStepClass.TestAsyncStepOut"); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/BadHarnessInitTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/BadHarnessInitTests.cs deleted file mode 100644 index a88aff6af4ed19..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/BadHarnessInitTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Xunit; -using Xunit.Abstractions; - -#nullable enable - -namespace DebuggerTests -{ - public class BadHarnessInitTests : DebuggerTests - { - public BadHarnessInitTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - public override async Task InitializeAsync() => await Task.CompletedTask; - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InvalidInitCommands() - { - var bad_cmd_name = "non-existent.command"; - - Func)>> fn = (client, token) => - new List<(string, Task)> - { - ("Profiler.enable", client.SendCommand("Profiler.enable", null, token)), - (bad_cmd_name, client.SendCommand(bad_cmd_name, null, token)) - }; - - await Ready(); - - var ae = await Assert.ThrowsAsync(async () => await insp.OpenSessionAsync(fn, "", TestTimeout)); - Assert.Contains(bad_cmd_name, ae.Message); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/BreakpointTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/BreakpointTests.cs deleted file mode 100644 index b5e10eec917f15..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/BreakpointTests.cs +++ /dev/null @@ -1,923 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using System.IO; -using Xunit; -using Xunit.Sdk; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - - public class BreakpointTests : DebuggerTests - { - public BreakpointTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateGoodBreakpoint() - { - var bp1_res = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - - Assert.EndsWith("debugger-test.cs", bp1_res.Value["breakpointId"].ToString()); - Assert.Equal(1, bp1_res.Value["locations"]?.Value()?.Count); - - var loc = bp1_res.Value["locations"]?.Value()[0]; - - Assert.NotNull(loc["scriptId"]); - Assert.Equal("dotnet://debugger-test.dll/debugger-test.cs", scripts[loc["scriptId"]?.Value()]); - Assert.Equal(10, (int)loc["lineNumber"]); - Assert.Equal(8, (int)loc["columnNumber"]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateJSBreakpoint() - { - // Test that js breakpoints get set correctly - // 13 4 - // 14 4 - var bp1_res = await SetBreakpoint("/debugger-driver.html", 13, 4); - - Assert.EndsWith("debugger-driver.html", bp1_res.Value["breakpointId"].ToString()); - Assert.Equal(1, bp1_res.Value["locations"]?.Value()?.Count); - - var loc = bp1_res.Value["locations"]?.Value()[0]; - - Assert.NotNull(loc["scriptId"]); - Assert.Equal(13, (int)loc["lineNumber"]); - Assert.Equal(4, (int)loc["columnNumber"]); - - var bp2_res = await SetBreakpoint("/debugger-driver.html", 14, 4); - - Assert.EndsWith("debugger-driver.html", bp2_res.Value["breakpointId"].ToString()); - Assert.Equal(1, bp2_res.Value["locations"]?.Value()?.Count); - - var loc2 = bp2_res.Value["locations"]?.Value()[0]; - - Assert.NotNull(loc2["scriptId"]); - Assert.Equal(14, (int)loc2["lineNumber"]); - Assert.Equal(4, (int)loc2["columnNumber"]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateJS0Breakpoint() - { - // 13 4 - // 14 4 - var bp1_res = await SetBreakpoint("/debugger-driver.html", 13, 0); - - Assert.EndsWith("debugger-driver.html", bp1_res.Value["breakpointId"].ToString()); - Assert.Equal(1, bp1_res.Value["locations"]?.Value()?.Count); - - var loc = bp1_res.Value["locations"]?.Value()[0]; - - Assert.NotNull(loc["scriptId"]); - Assert.Equal(13, (int)loc["lineNumber"]); - Assert.Equal(4, (int)loc["columnNumber"]); - - var bp2_res = await SetBreakpoint("/debugger-driver.html", 14, 0); - - Assert.EndsWith("debugger-driver.html", bp2_res.Value["breakpointId"].ToString()); - Assert.Equal(1, bp2_res.Value["locations"]?.Value()?.Count); - - var loc2 = bp2_res.Value["locations"]?.Value()[0]; - - Assert.NotNull(loc2["scriptId"]); - Assert.Equal(14, (int)loc2["lineNumber"]); - Assert.Equal(4, (int)loc2["columnNumber"]); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(0)] - [InlineData(50)] - public async Task CheckMultipleBreakpointsOnSameLine(int col) - { - var bp1_res = await SetBreakpoint("dotnet://debugger-test.dll/debugger-array-test.cs", 219, col); - Assert.EndsWith("debugger-array-test.cs", bp1_res.Value["breakpointId"].ToString()); - Assert.Equal(1, bp1_res.Value["locations"]?.Value()?.Count); - - var loc = bp1_res.Value["locations"]?.Value()[0]; - - CheckLocation("dotnet://debugger-test.dll/debugger-array-test.cs", 219, 50, scripts, loc); - - var bp2_res = await SetBreakpoint("dotnet://debugger-test.dll/debugger-array-test.cs", 219, 55); - Assert.EndsWith("debugger-array-test.cs", bp2_res.Value["breakpointId"].ToString()); - Assert.Equal(1, bp2_res.Value["locations"]?.Value()?.Count); - - var loc2 = bp2_res.Value["locations"]?.Value()[0]; - - CheckLocation("dotnet://debugger-test.dll/debugger-array-test.cs", 219, 55, scripts, loc2); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateBadBreakpoint() - { - var bp1_req = JObject.FromObject(new - { - lineNumber = 8, - columnNumber = 2, - url = "dotnet://debugger-test.dll/this-file-doesnt-exist.cs", - }); - - var bp1_res = await cli.SendCommand("Debugger.setBreakpointByUrl", bp1_req, token); - - Assert.True(bp1_res.IsOk); - Assert.Empty(bp1_res.Value["locations"].Values()); - //Assert.Equal ((int)MonoErrorCodes.BpNotFound, bp1_res.Error ["code"]?.Value ()); - } - - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/96734")] - public async Task CreateGoodBreakpointAtPartialClass() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 1667, 8); - Assert.NotEmpty(bp.Value["locations"]); - // ToDo: add hit action like in CreateGoodBreakpointAndHit when bp works - } - - [Fact] - public async Task CreateGoodBreakpointAndHit() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd", - wait_for_event_fn: (pause_location) => - { - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - Assert.Equal("Math.IntAdd", top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - - //now check the scope - var scope = top_frame["scopeChain"][0]; - Assert.Equal("local", scope["type"]); - Assert.Equal("Math.IntAdd", scope["name"]); - - Assert.Equal("object", scope["object"]["type"]); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); - - foreach (var frame in pause_location["callFrames"]) - { - Assert.Equal(false, frame["url"].Value().EndsWith(".wasm", StringComparison.Ordinal)); - Assert.Equal(false, frame["url"].Value().Contains("wasm://")); - } - return Task.CompletedTask; - } - ); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateGoodBreakpointWithoutColumnAndHit() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, -1); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd" - ); - } - - public static TheoryData FalseConditions = new TheoryData - { - { "invoke_add()", "IntAdd", "0.0", false }, - { "invoke_add()", "IntAdd", "c == 40", false }, - { "invoke_add()", "IntAdd", "c < 0", false }, - }; - - public static TheoryData TrueConditions = new TheoryData - { - { "invoke_add()", "IntAdd", "c == 30", true }, - /*{ "invoke_add()", "IntAdd", "true", true }, - { "invoke_add()", "IntAdd", "5", true }, - { "invoke_add()", "IntAdd", "c < 40", true }, - { "invoke_use_complex()", "UseComplex", "complex.A == 10", true }, - { "invoke_add()", "IntAdd", "1.0", true }, - { "invoke_add()", "IntAdd", "\"foo\"", true }, - { "invoke_add()", "IntAdd", "\"true\"", true }, - { "invoke_add()", "IntAdd", "\"false\"", true },*/ - }; - - public static TheoryData InvalidConditions = new TheoryData - { - { "invoke_add()", "IntAdd", "foo.bar", false }, - { "invoke_add()", "IntAdd", "Math.IntAdd()", false }, - { "invoke_add()", "IntAdd", "c == \"xyz\"", false }, - { "invoke_add()", "IntAdd", "Math.NonExistentProperty", false }, - { "invoke_add()", "IntAdd", "g == 40", false }, - { "invoke_add()", "IntAdd", "null", false }, - }; - - [Theory] - [MemberData(nameof(FalseConditions))] - [MemberData(nameof(TrueConditions))] - [MemberData(nameof(InvalidConditions))] - public async Task ConditionalBreakpoint2(string function_to_call, string method_to_stop, string condition, bool bp_stop_expected) - { - Result [] bps = new Result[2]; - bps[0] = await SetBreakpointInMethod("debugger-test.dll", "Math", method_to_stop, 3, condition:condition); - bps[1] = await SetBreakpointInMethod("debugger-test.dll", "Math", method_to_stop, 4); - await EvaluateAndCheck( - "window.setTimeout(function() { " + function_to_call + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bps[bp_stop_expected ? 0 : 1].Value["locations"][0]["lineNumber"].Value(), - bps[bp_stop_expected ? 0 : 1].Value["locations"][0]["columnNumber"].Value(), - "Math." + method_to_stop); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("c == 15", 79, 3, 79, 11)] - [InlineData("c == 17", 79, 3, 80, 11)] - [InlineData("true", 79, 3, 79, 11)] - [InlineData("\"false\"", 79, 3, 79, 11)] - [InlineData("\"true\"", 79, 3, 79, 11)] - [InlineData("5", 79, 3, 79, 11)] - [InlineData("p", 79, 3, 80, 11)] - [InlineData("0.0", 79, 3, 80, 11)] - public async Task JSConditionalBreakpoint(string condition, int line_bp, int column_bp, int line_expected, int column_expected) - { - await SetBreakpoint("/debugger-driver.html", line_bp, column_bp, condition: condition); - await SetBreakpoint("/debugger-driver.html", 80, 11); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { conditional_breakpoint_test(5, 10, null); }, 1);", - "debugger-driver.html", line_expected, column_expected, "conditional_breakpoint_test"); - } - - [Theory] - [InlineData("invoke_add_with_parms(10, 20)", "invoke_add_with_parms(10, 20)", "IntAdd", "c == 30", true, true)] - [InlineData("invoke_add_with_parms(5, 10)", "invoke_add_with_parms(10, 20)", "IntAdd", "c == 30", false, true)] - [InlineData("invoke_add_with_parms(10, 20)", "invoke_add_with_parms(5, 10)", "IntAdd", "c == 30", true, false)] - public async Task ConditionalBreakpointHitTwice(string function_to_call, string function_to_call2, string method_to_stop, string condition, bool bp_stop_expected, bool bp_stop_expected2) - { - Result [] bps = new Result[2]; - bps[0] = await SetBreakpointInMethod("debugger-test.dll", "Math", method_to_stop, 3, condition:condition); - bps[1] = await SetBreakpointInMethod("debugger-test.dll", "Math", method_to_stop, 4); - await EvaluateAndCheck( - "window.setTimeout(function() { " + function_to_call + "; " + function_to_call2 + ";}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bps[bp_stop_expected ? 0 : 1].Value["locations"][0]["lineNumber"].Value(), - bps[bp_stop_expected ? 0 : 1].Value["locations"][0]["columnNumber"].Value(), - "Math." + method_to_stop); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bps[bp_stop_expected2 ? 0 : 1].Value["locations"][0]["lineNumber"].Value(), - bps[bp_stop_expected2 ? 0 : 1].Value["locations"][0]["columnNumber"].Value(), - "Math." + method_to_stop); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task BreakOnDebuggerBreak() - { - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] UserBreak:BreakOnDebuggerBreakCommand'); }, 1);", - "dotnet://debugger-test.dll/debugger-test2.cs", 58, 8, - "UserBreak.BreakOnDebuggerBreakCommand", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 59, 8, "UserBreak.BreakOnDebuggerBreakCommand", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 60, 8, "UserBreak.BreakOnDebuggerBreakCommand", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 61, 8, "UserBreak.BreakOnDebuggerBreakCommand", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 50); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test2.cs", 62, 4, "UserBreak.BreakOnDebuggerBreakCommand", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 100); - await Task.CompletedTask; - } - ); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task BreakpointInAssemblyUsingTypeFromAnotherAssembly_BothDynamicallyLoaded() - { - int line = 7; - - // Start the task earlier than loading the assemblies, so we don't miss the event - Task bpResolved = WaitForBreakpointResolvedEvent(); - await SetBreakpoint(".*/library-dependency-debugger-test1.cs$", line, 0, use_regex: true); - await LoadAssemblyDynamically( - Path.Combine(DebuggerTestAppPath, "library-dependency-debugger-test2.dll"), - Path.Combine(DebuggerTestAppPath, "library-dependency-debugger-test2.pdb")); - await LoadAssemblyDynamically( - Path.Combine(DebuggerTestAppPath, "library-dependency-debugger-test1.dll"), - Path.Combine(DebuggerTestAppPath, "library-dependency-debugger-test1.pdb")); - - var source_location = "dotnet://library-dependency-debugger-test1.dll/library-dependency-debugger-test1.cs"; - Assert.Contains(source_location, scripts.Values); - - await bpResolved; - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function () { invoke_static_method('[library-dependency-debugger-test1] TestDependency:IntAdd', 5, 10); }, 1);", - source_location, line, 8, - "TestDependency.IntAdd"); - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 5); - CheckNumber(locals, "b", 10); - } - - [Fact] - public async Task ConditionalBreakpointInALoop() - { - var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i == 3"); - var bp_check = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 5); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 3); - await Task.CompletedTask; - } - ); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bp_check.Value["locations"][0]["lineNumber"].Value(), - bp_check.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak"); - } - - [Fact] - public async Task ConditionalBreakpointInALoopStopMoreThanOnce() - { - var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i % 3 == 0"); - var bp_check = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 5); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 0); - await Task.CompletedTask; - } - ); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 3); - await Task.CompletedTask; - }); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 6); - await Task.CompletedTask; - }); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 9); - await Task.CompletedTask; - }); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bp_check.Value["locations"][0]["lineNumber"].Value(), - bp_check.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak"); - } - - [Fact] - public async Task ConditionalBreakpointNoStopInALoop() - { - var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i == \"10\""); - var bp_check = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 5); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_check.Value["locations"][0]["lineNumber"].Value(), - bp_check.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak" - ); - } - - [Fact] - public async Task ConditionalBreakpointNotBooleanInALoop() - { - var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "LoopClass", "LoopToBreak", 4, condition:"i + 4"); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] LoopClass:LoopToBreak'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 0); - await Task.CompletedTask; - } - ); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 1); - await Task.CompletedTask; - }); - - await SendCommandAndCheck(null, "Debugger.resume", - null, - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "LoopClass.LoopToBreak", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 2); - await Task.CompletedTask; - }); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("load_non_wasm_page")] - public async Task CreateGoodBreakpointAndHitGoToNonWasmPageComeBackAndHitAgain(string func_name) - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd"); - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - Assert.Equal("Math.IntAdd", top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - - //now check the scope - var scope = top_frame["scopeChain"][0]; - Assert.Equal("local", scope["type"]); - Assert.Equal("Math.IntAdd", scope["name"]); - - Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); - - await cli.SendCommand("Debugger.resume", null, token); - - var run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { " + func_name + "(); }, 1);" - }); - await cli.SendCommand("Runtime.evaluate", run_method, token); - await WaitForEventAsync("Runtime.executionContextCreated"); - - run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { reload_wasm_page(); }, 1);" - }); - await cli.SendCommand("Runtime.evaluate", run_method, token); - await insp.WaitFor(Inspector.APP_READY); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd", - wait_for_event_fn: (pause_location) => - { - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - Assert.Equal("Math.IntAdd", top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - - //now check the scope - var scope = top_frame["scopeChain"][0]; - Assert.Equal("local", scope["type"]); - Assert.Equal("Math.IntAdd", scope["name"]); - - Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); - return Task.CompletedTask; - } - ); - } - - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("RunDebuggerHidden", "HiddenMethod")] - [InlineData("RunStepThroughWithHidden", "StepThroughWithHiddenBp")] // debuggerHidden shadows the effect of stepThrough - [InlineData("RunNonUserCodeWithHidden", "NonUserCodeWithHiddenBp")] // and nonUserCode - public async Task DebuggerHiddenNoStopOnBp(string evalFunName, string decoratedFunName) - { - var bp_hidden = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", decoratedFunName, 1); - var bp_final = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 2); - Assert.Empty(bp_hidden.Value["locations"]); - await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] DebuggerAttribute:{evalFunName}'); }}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_final.Value["locations"][0]["lineNumber"].Value(), - bp_final.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute." + evalFunName - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("RunDebuggerHidden")] - [InlineData("RunStepThroughWithHidden")] // debuggerHidden shadows the effect of stepThrough - [InlineData("RunNonUserCodeWithHidden")] // and nonUserCode - public async Task DebuggerHiddenStopOnUserBp(string evalFunName) - { - var bp_init = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 2); - var bp_final = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 3); - var init_location = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] DebuggerAttribute:{evalFunName}'); }}, 2);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_init.Value["locations"][0]["lineNumber"].Value(), - bp_init.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute." + evalFunName - ); - await SendCommandAndCheck(null, "Debugger.resume", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_init.Value["locations"][0]["lineNumber"].Value(), - bp_init.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute." + evalFunName); - await SendCommandAndCheck(null, "Debugger.resume", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_final.Value["locations"][0]["lineNumber"].Value(), - bp_final.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute." + evalFunName); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false, "RunStepThrough", "DebuggerAttribute", 1, 847, 8, "DebuggerAttribute.RunStepThrough")] - [InlineData(true, "RunStepThrough", "DebuggerAttribute", 1, 847, 8, "DebuggerAttribute.RunStepThrough")] - [InlineData(false, "RunNonUserCode", "DebuggerAttribute", 1, 852, 4, "DebuggerAttribute.NonUserCodeBp")] - [InlineData(true, "RunNonUserCode", "DebuggerAttribute", 1, 867, 8, "DebuggerAttribute.RunNonUserCode")] - [InlineData(false, "RunStepThroughWithNonUserCode", "DebuggerAttribute", 1, 933, 8, "DebuggerAttribute.RunStepThroughWithNonUserCode")] - [InlineData(true, "RunStepThroughWithNonUserCode", "DebuggerAttribute", 1, 933, 8, "DebuggerAttribute.RunStepThroughWithNonUserCode")] - [InlineData(false, "EvaluateStepThroughAttr", "DefaultInterfaceMethod", 2, 1110, 4, "DefaultInterfaceMethod.EvaluateStepThroughAttr")] - [InlineData(true, "EvaluateStepThroughAttr", "DefaultInterfaceMethod", 2, 1110, 4, "DefaultInterfaceMethod.EvaluateStepThroughAttr")] - [InlineData(false, "EvaluateNonUserCodeAttr", "DefaultInterfaceMethod", 2, 1067, 4, "IExtendIDefaultInterface.NonUserCodeDefaultMethod")] - [InlineData(true, "EvaluateNonUserCodeAttr", "DefaultInterfaceMethod", 2, 1116, 4, "DefaultInterfaceMethod.EvaluateNonUserCodeAttr")] - public async Task StepThroughOrNonUserCodeAttributeStepInNoBp2(bool justMyCodeEnabled, string evalFunName, string evalClassName, int bpLine, int line, int col, string funcName="") - { - var bp_init = await SetBreakpointInMethod("debugger-test.dll", evalClassName, evalFunName, bpLine); - var init_location = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] {evalClassName}:{evalFunName}'); }}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_init.Value["locations"][0]["lineNumber"].Value(), - bp_init.Value["locations"][0]["columnNumber"].Value(), - evalClassName + "." + evalFunName - ); - await SetJustMyCode(justMyCodeEnabled); - await SendCommandAndCheck(null, "Debugger.stepInto", "dotnet://debugger-test.dll/debugger-test.cs", line, col, funcName); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false, "RunStepThrough", "StepThroughBp", "", 846, 8)] - [InlineData(true, "RunStepThrough", "StepThroughBp", "RunStepThrough", 847, 8)] - [InlineData(false, "RunNonUserCode", "NonUserCodeBp", "NonUserCodeBp", 852, 4)] - [InlineData(true, "RunNonUserCode", "NonUserCodeBp", "RunNonUserCode", 867, 8)] - [InlineData(false, "RunStepThroughWithNonUserCode", "StepThroughWithNonUserCodeBp", "", 932, 8)] - [InlineData(true, "RunStepThroughWithNonUserCode", "StepThroughWithNonUserCodeBp", "RunStepThroughWithNonUserCode", 933, 8)] - public async Task StepThroughOrNonUserCodeAttributeStepInWithBp( - bool justMyCodeEnabled, string evalFunName, string decoratedFunName, - string funName, int line, int col) - { - var bp_init = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 1); - var init_location = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] DebuggerAttribute:{evalFunName}'); }}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_init.Value["locations"][0]["lineNumber"].Value(), - bp_init.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute." + evalFunName - ); - - await SetJustMyCode(justMyCodeEnabled); - if (!justMyCodeEnabled && funName == "") - { - var bp1_decorated_fun = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", decoratedFunName, 1); - var bp2_decorated_fun = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", decoratedFunName, 3); - var line1 = bp1_decorated_fun.Value["locations"][0]["lineNumber"].Value(); - var line2 = bp2_decorated_fun.Value["locations"][0]["lineNumber"].Value(); - await SendCommandAndCheck(null, "Debugger.stepInto", "dotnet://debugger-test.dll/debugger-test.cs", line1, 8, "DebuggerAttribute." + decoratedFunName); - await SendCommandAndCheck(null, "Debugger.stepInto", "dotnet://debugger-test.dll/debugger-test.cs", line2, 8, "DebuggerAttribute." + decoratedFunName); - funName = evalFunName; - } - await SendCommandAndCheck(null, "Debugger.stepInto", "dotnet://debugger-test.dll/debugger-test.cs", line, col, "DebuggerAttribute." + funName); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false, "RunStepThrough", "StepThroughBp")] - [InlineData(true, "RunStepThrough", "StepThroughBp")] - [InlineData(true, "RunNonUserCode", "NonUserCodeBp")] - [InlineData(false, "RunNonUserCode", "NonUserCodeBp")] - [InlineData(false, "RunStepThroughWithNonUserCode", "StepThroughWithNonUserCodeBp")] - [InlineData(true, "RunStepThroughWithNonUserCode", "StepThroughWithNonUserCodeBp")] - public async Task StepThroughOrNonUserCodeAttributeResumeWithBp(bool justMyCodeEnabled, string evalFunName, string decoratedFunName) - { - var bp_init = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 1); - var init_location = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] DebuggerAttribute:{evalFunName}'); }}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_init.Value["locations"][0]["lineNumber"].Value(), - bp_init.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute." + evalFunName - ); - - await SetJustMyCode(justMyCodeEnabled); - if (!justMyCodeEnabled) - { - var bp1_decorated_fun = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", decoratedFunName, 1); - var line1 = bp1_decorated_fun.Value["locations"][0]["lineNumber"].Value(); - await SendCommandAndCheck(null, "Debugger.resume", "dotnet://debugger-test.dll/debugger-test.cs", line1, 8, "DebuggerAttribute." + decoratedFunName); - } - var bp_outside_decorated_fun = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 2); - var line2 = bp_outside_decorated_fun.Value["locations"][0]["lineNumber"].Value(); - await SendCommandAndCheck(null, "Debugger.resume", "dotnet://debugger-test.dll/debugger-test.cs", line2, 8, "DebuggerAttribute." + evalFunName); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false, "Debugger.stepInto", "RunStepThrough", "StepThroughUserBp", 841, 8, "RunStepThrough", 848, 4)] - [InlineData(true, "Debugger.stepInto", "RunStepThrough", "RunStepThrough", -1, 8, "RunStepThrough", -1, 4)] - [InlineData(false, "Debugger.resume", "RunStepThrough", "StepThroughUserBp", 841, 8, "RunStepThrough", 848, 4)] - [InlineData(true, "Debugger.resume", "RunStepThrough", "RunStepThrough", -1, 8, "RunStepThrough", -1, 4)] - [InlineData(false, "Debugger.stepInto", "RunNonUserCode", "NonUserCodeUserBp", 860, 4, "NonUserCodeUserBp", 861, 8)] - [InlineData(true, "Debugger.stepInto", "RunNonUserCode", "RunNonUserCode", -1, 8, "RunNonUserCode", -1, 4)] - [InlineData(false, "Debugger.resume", "RunNonUserCode", "NonUserCodeUserBp", 861, 8, "RunNonUserCode", -1, 4)] - [InlineData(true, "Debugger.resume", "RunNonUserCode", "RunNonUserCode", -1, 8, "RunNonUserCode", -1, 4)] - [InlineData(false, "Debugger.stepInto", "RunStepThroughWithNonUserCode", "StepThroughWithNonUserCodeUserBp", 927, 8, "RunStepThroughWithNonUserCode", 934, 4)] - [InlineData(true, "Debugger.stepInto", "RunStepThroughWithNonUserCode", "RunStepThroughWithNonUserCode", -1, 8, "RunStepThroughWithNonUserCode", -1, 4)] - [InlineData(false, "Debugger.resume", "RunStepThroughWithNonUserCode", "StepThroughWithNonUserCodeUserBp", 927, 8, "RunStepThroughWithNonUserCode", -1, 4)] - [InlineData(true, "Debugger.resume", "RunStepThroughWithNonUserCode", "RunStepThroughWithNonUserCode", -1, 8, "RunStepThroughWithNonUserCode", -1, 4)] - public async Task StepThroughOrNonUserCodeAttributeWithUserBp( - bool justMyCodeEnabled, string debuggingFunction, string evalFunName, - string functionNameCheck1, int line1, int col1, - string functionNameCheck2, int line2, int col2) - { - var bp_init = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 2); - var bp_outside_decorated_fun = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", evalFunName, 3); - - var init_location = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] DebuggerAttribute:{evalFunName}'); }}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_init.Value["locations"][0]["lineNumber"].Value(), - bp_init.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute." + evalFunName - ); - - await SetJustMyCode(justMyCodeEnabled); - if (line1 == -1) - line1 = bp_outside_decorated_fun.Value["locations"][0]["lineNumber"].Value() - 1; - if (line2 == -1) - line2 = bp_outside_decorated_fun.Value["locations"][0]["lineNumber"].Value(); - - await SendCommandAndCheck(null, debuggingFunction, "dotnet://debugger-test.dll/debugger-test.cs", line1, col1, "DebuggerAttribute." + functionNameCheck1); - await SendCommandAndCheck(null, debuggingFunction, "dotnet://debugger-test.dll/debugger-test.cs", line2, col2, "DebuggerAttribute." + functionNameCheck2); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("DebuggerAttribute", "RunNoBoundary", "DebuggerAttribute", "Debugger.stepInto", 1, 2, false)] - [InlineData("DebuggerAttribute", "RunNoBoundary", "DebuggerAttribute", "Debugger.stepInto", 1, 2, true)] - [InlineData("DebuggerAttribute", "RunNoBoundary", "DebuggerAttribute", "Debugger.resume", 1, 2, true)] - [InlineData("DebuggerAttribute", "RunNoBoundary", "DebuggerAttribute", "Debugger.stepInto", 2, 3, false, true)] - [InlineData("DebuggerAttribute", "RunNoBoundary", "DebuggerAttribute", "Debugger.resume", 2, 3, false, true)] - [InlineData("DefaultInterfaceMethod", "EvaluateStepperBoundaryAttr", "IExtendIDefaultInterface", "Debugger.stepInto", 2, 3, false)] - [InlineData("DefaultInterfaceMethod", "EvaluateStepperBoundaryAttr", "IExtendIDefaultInterface", "Debugger.stepInto", 2, 3, true)] - [InlineData("DefaultInterfaceMethod", "EvaluateStepperBoundaryAttr", "IExtendIDefaultInterface", "Debugger.resume", 2, 3, true)] - public async Task StepperBoundary( - string className, string evalFunName, string decoratedMethodClassName, string debuggingAction, int lineBpInit, int lineBpFinal, bool hasBpInDecoratedFun, bool isTestingUserBp = false) - { - // behavior of StepperBoundary is the same for JMC enabled and disabled - // but the effect of NonUserCode escape is better visible for JMC: enabled - await SetJustMyCode(true); - var bp_init = await SetBreakpointInMethod("debugger-test.dll", className, evalFunName, lineBpInit); - var init_location = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] {className}:{evalFunName}'); }}, {lineBpInit});", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_init.Value["locations"][0]["lineNumber"].Value(), - bp_init.Value["locations"][0]["columnNumber"].Value(), - className + "." + evalFunName - ); - var bp_final = await SetBreakpointInMethod("debugger-test.dll", className, evalFunName, lineBpFinal); - if (hasBpInDecoratedFun) - { - var bp_decorated_fun = await SetBreakpointInMethod("debugger-test.dll", decoratedMethodClassName, "BoundaryBp", 2); - var line_decorated_fun = bp_decorated_fun.Value["locations"][0]["lineNumber"].Value(); - var col_decorated_fun = bp_decorated_fun.Value["locations"][0]["columnNumber"].Value(); - await SendCommandAndCheck(null, debuggingAction, "dotnet://debugger-test.dll/debugger-test.cs", line_decorated_fun, col_decorated_fun, decoratedMethodClassName + ".BoundaryBp"); - } - if (isTestingUserBp) - await SendCommandAndCheck(null, debuggingAction, "dotnet://debugger-test.dll/debugger-test.cs", 879, 8, decoratedMethodClassName + ".BoundaryUserBp"); - - var line = bp_final.Value["locations"][0]["lineNumber"].Value(); - var col = bp_final.Value["locations"][0]["columnNumber"].Value(); - await SendCommandAndCheck(null, debuggingAction, "dotnet://debugger-test.dll/debugger-test.cs", line, col, className + "." + evalFunName); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateGoodBreakpointAndHitGoToWasmPageWithoutAssetsComeBackAndHitAgain() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd"); - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - Assert.Equal("Math.IntAdd", top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - - //now check the scope - var scope = top_frame["scopeChain"][0]; - Assert.Equal("local", scope["type"]); - Assert.Equal("Math.IntAdd", scope["name"]); - - Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); - - await cli.SendCommand("Debugger.resume", null, token); - - var run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { load_wasm_page_without_assets(); }, 1);" - }); - await cli.SendCommand("Runtime.evaluate", run_method, token); - await insp.WaitFor(Inspector.APP_READY); - - run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { reload_wasm_page(); }, 1);" - }); - await cli.SendCommand("Runtime.evaluate", run_method, token); - await insp.WaitFor(Inspector.APP_READY); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd", - wait_for_event_fn: async (pause_location) => - { - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - Assert.Equal("Math.IntAdd", top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - - //now check the scope - var scope = top_frame["scopeChain"][0]; - Assert.Equal("local", scope["type"]); - Assert.Equal("Math.IntAdd", scope["name"]); - - Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); - await Task.CompletedTask; - } - ); - } - - [Theory] - [InlineData("IDefaultInterface", "DefaultMethod", "Evaluate", "DefaultInterfaceMethod.Evaluate", 1089, 1005, 1003, 1007)] - [InlineData("IExtendIDefaultInterface", "IDefaultInterface.DefaultMethodToOverride", "Evaluate", "DefaultInterfaceMethod.Evaluate", 1090, 1049, 1047, 1051)] - [InlineData("IDefaultInterface", "DefaultMethodAsync", "EvaluateAsync", "DefaultInterfaceMethod.EvaluateAsync", 1097, 1018, 1016, 1020)] - [InlineData("IDefaultInterface", "DefaultMethodStatic", "EvaluateStatic", "DefaultInterfaceMethod.EvaluateStatic", 1126, 1024, 1022, 1026)] - [InlineData("IDefaultInterface", "DefaultMethodAsyncStatic", "EvaluateAsyncStatic", "DefaultInterfaceMethod.EvaluateAsyncStatic", 1131, 1033, 1031, 1035)] - public async Task BreakInDefaultInterfaceMethod( - string dimClassName, string dimName, string entryMethod, string prevFrameInDim, int evaluateAsPrevFrameLine, int dimAsPrevFrameLine, int functionLocationLine, int functionEndLine) - { - string assembly = "dotnet://debugger-test.dll/debugger-test.cs"; - var bpDim = await SetBreakpointInMethod("debugger-test.dll", dimClassName, dimName, 1); - var pauseInDim = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] DefaultInterfaceMethod:{entryMethod}'); }}, 1);", - assembly, - bpDim.Value["locations"][0]["lineNumber"].Value(), - bpDim.Value["locations"][0]["columnNumber"].Value(), - dimClassName + "." + dimName, - wait_for_event_fn: async (pause_location) => { await CheckDefaultMethod(pause_location, dimClassName + "." + dimName); } - ); - - // check prev frame in DIM - Assert.Equal(pauseInDim["callFrames"][1]["functionName"].Value(), prevFrameInDim); - CheckLocationLine(pauseInDim["callFrames"][1]["location"], evaluateAsPrevFrameLine); - - string funCalledFromDim = "MethodForCallingFromDIM"; - var bpFunCalledFromDim = await SetBreakpointInMethod("debugger-test.dll", "DefaultInterfaceMethod", funCalledFromDim, 1); - - // check prev frame in method called from DIM - var pauseInFunCalledFromDim = await SendCommandAndCheck(null, "Debugger.resume", - null, - bpFunCalledFromDim.Value["locations"][0]["lineNumber"].Value(), - bpFunCalledFromDim.Value["locations"][0]["columnNumber"].Value(), - "DefaultInterfaceMethod." + funCalledFromDim); - - string prevFrameFromDim = dimName; - Assert.Equal(pauseInFunCalledFromDim["callFrames"][1]["functionName"].Value(), dimClassName + "." + prevFrameFromDim); - CheckLocationLine(pauseInFunCalledFromDim["callFrames"][1]["location"], dimAsPrevFrameLine); - - async Task CheckDefaultMethod(JObject pause_location, string methodName) - { - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bpDim.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - Assert.Equal(methodName, top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation(assembly, functionLocationLine, 4, scripts, top_frame["functionLocation"]); - - var scope = top_frame["scopeChain"][0]; - Assert.Equal("local", scope["type"]); - Assert.Equal(methodName, scope["name"]); - - Assert.Equal("object", scope["object"]["type"]); - CheckLocation(assembly, functionLocationLine, 4, scripts, scope["startLocation"]); - CheckLocation(assembly, functionEndLine, 4, scripts, scope["endLocation"]); - await Task.CompletedTask; - } - } - - [Fact] - public async Task CheckDefaultInterfaceMethodHiddenAttribute() - { - string methodName = "EvaluateHiddenAttr"; - string assembly = "dotnet://debugger-test.dll/debugger-test.cs"; - var hidden_bp = await SetBreakpointInMethod("debugger-test.dll", "IExtendIDefaultInterface", "HiddenDefaultMethod", 1); - var final_bp = await SetBreakpointInMethod("debugger-test.dll", "DefaultInterfaceMethod", methodName, 3); - // check if bp in hidden DIM was ignored: - var final_location = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] DefaultInterfaceMethod:{methodName}'); }}, 1);", - assembly, - final_bp.Value["locations"][0]["lineNumber"].Value(), - final_bp.Value["locations"][0]["columnNumber"].Value(), - "DefaultInterfaceMethod." + methodName - ); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/BrowserLocator.cs b/src/mono/browser/debugger/DebuggerTestSuite/BrowserLocator.cs deleted file mode 100644 index 70a9bd87c56f93..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/BrowserLocator.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#nullable enable - -using System; -using System.IO; -using System.Linq; -using System.Collections.Generic; - -namespace Wasm.Tests.Internal; - -internal static class BrowserLocator -{ - public static string FindChrome(string artifactsBinDir, string envVarName) - => GetBrowserPath(GetChromePathsToProbe(artifactsBinDir), envVarName); - - public static string FindFirefox(string artifactsBinDir, string envVarName) - => GetBrowserPath(GetFirefoxPathsToProbe(artifactsBinDir), envVarName); - - private static string GetBrowserPath(IEnumerable pathsToProbe, string envVarName) - { - string? browserPath = FindBrowserPath(); - if (!string.IsNullOrEmpty(browserPath)) - return Path.GetFullPath(browserPath); - - throw new Exception($"Could not find an installed browser to use. Tried paths: {string.Join(", ", pathsToProbe)}"); - - string? FindBrowserPath() - { - if (!string.IsNullOrEmpty(envVarName) && - Environment.GetEnvironmentVariable(envVarName) is string _browserPath_env_var && - !string.IsNullOrEmpty(_browserPath_env_var)) - { - if (File.Exists(_browserPath_env_var)) - return _browserPath_env_var; - - Console.WriteLine ($"warning: Could not find {envVarName}={_browserPath_env_var}"); - } - - return pathsToProbe.FirstOrDefault(p => File.Exists(p)); - } - } - - private static IEnumerable GetChromePathsToProbe(string artifactsBinDir) - { - List paths = new(); - if (!string.IsNullOrEmpty(artifactsBinDir)) - { - // Look for a browser installed in artifacts, for local runs - paths.Add(Path.Combine(artifactsBinDir, "chrome", "chrome-linux", "chrome")); - paths.Add(Path.Combine(artifactsBinDir, "chrome", "chrome-win", "chrome.exe")); - } - - paths.AddRange(new[] - { - "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", - "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge", - "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary", - "/usr/bin/chromium", - "C:/Program Files/Google/Chrome/Application/chrome.exe", - "/usr/bin/chromium-browser" - }); - - return paths; - } - - private static IEnumerable GetFirefoxPathsToProbe(string artifactsBinDir) - { - List paths = new(); - if (!string.IsNullOrEmpty(artifactsBinDir)) - { - // Look for a browser installed in artifacts, for local runs - paths.Add(Path.Combine(artifactsBinDir, "firefox", "firefox", "firefox")); - paths.Add(Path.Combine(artifactsBinDir, "firefox", "firefox", "firefox.exe")); - } - - paths.AddRange(new[] - { - "C:/Program Files/Mozilla Firefox/firefox.exe", - "/Applications/Firefox.app/Contents/MacOS/firefox", - }); - - return paths; - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/CallFunctionOnTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/CallFunctionOnTests.cs deleted file mode 100644 index d0bb4339369c8c..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/CallFunctionOnTests.cs +++ /dev/null @@ -1,964 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - - public class CallFunctionOnTests : DebuggerTests - { - public CallFunctionOnTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - // This tests `callFunctionOn` with a function that the vscode-js-debug extension uses - // Using this here as a non-trivial test case - [ConditionalTheory(nameof(RunningOnChrome))] - // [InlineData("big_array_js_test (10);", "/other.js", 10, 1, 10, false)] - ActiveIssue https://github.com/dotnet/runtime/issues/95950 - // [InlineData("big_array_js_test (0);", "/other.js", 10, 1, 0, true)] - ActiveIssue https://github.com/dotnet/runtime/issues/95950 - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, 10, false)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 0);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, 0, true)] - public async Task CheckVSCodeTestFunction1(string eval_fn, string bp_loc, int line, int col, int len, bool roundtrip) - { - string vscode_fn0 = "function(){const e={__proto__:this.__proto__},t=Object.getOwnPropertyNames(this);for(let r=0;r>>0;if(String(i>>>0)===n&&i>>>0!=4294967295)continue;const a=Object.getOwnPropertyDescriptor(this,n);a&&Object.defineProperty(e,n,a)}return e}"; - - await RunCallFunctionOn(eval_fn, vscode_fn0, "big", bp_loc, line, col, res_array_len: len, roundtrip: roundtrip, - test_fn: async (result) => - { - - var is_js = bp_loc.EndsWith(".js", StringComparison.Ordinal); - var obj_accessors = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = true, - ownProperties = false - }), token); - if (is_js) - await CheckProps(obj_accessors.Value["result"], new { __proto__ = TIgnore() }, "obj_accessors"); - else - AssertEqual(0, obj_accessors.Value["result"]?.Count(), "obj_accessors-count"); - - // Check for a __proto__ object - // isOwn = true, accessorPropertiesOnly = false - var obj_own = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = false, - ownProperties = true - }), token); - - await CheckProps(obj_own.Value["result"], new - { - length = TNumber(len), - // __proto__ = TArray (type, 0) // Is this one really required? - }, $"obj_own"); - - }); - } - - void CheckJFunction(JToken actual, string className, string label) - { - AssertEqual("function", actual["type"]?.Value(), $"{label}-type"); - AssertEqual(className, actual["className"]?.Value(), $"{label}-className"); - } - - // This tests `callFunctionOn` with a function that the vscode-js-debug extension uses - // Using this here as a non-trivial test case - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, 10)] - [InlineData("big_array_js_test (0);", "/other.js", 10, 1, 0)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, 10)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 0);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, 0)] - public async Task CheckVSCodeTestFunction2(string eval_fn, string bp_loc, int line, int col, int len) - { - var fetch_start_idx = 2; - var num_elems_fetch = 3; - string vscode_fn1 = "function(e,t){const r={},n=-1===e?0:e,i=-1===t?this.length:e+t;for(let e=n;e - { - - var is_js = bp_loc.EndsWith(".js", StringComparison.Ordinal); - - // isOwn = false, accessorPropertiesOnly = true - var obj_accessors = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = true, - ownProperties = false - }), token); - - if (is_js) - await CheckProps(obj_accessors.Value["result"], new { __proto__ = TIgnore() }, "obj_accessors"); - else - AssertEqual(0, obj_accessors.Value["result"]?.Count(), "obj_accessors-count"); - - // isOwn = true, accessorPropertiesOnly = false - var obj_own = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = false, - ownProperties = true - }), token); - - var obj_own_val = obj_own.Value["result"]; - var num_elems_recd = len == 0 ? 0 : num_elems_fetch; - AssertEqual(num_elems_recd, obj_own_val.Count(), $"obj_own-count"); - - for (int i = fetch_start_idx; i < fetch_start_idx + num_elems_recd; i++) - CheckNumber(obj_own_val, i.ToString(), 1000 + i); - }); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, false)] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, true)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, false)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, true)] - public async Task RunOnArrayReturnEmptyArray(string eval_fn, string bp_loc, int line, int col, bool roundtrip) - { - var ret_len = 0; - - await RunCallFunctionOn(eval_fn, - "function () { return []; }", - "big", bp_loc, line, col, - res_array_len: ret_len, - roundtrip: roundtrip, - test_fn: async (result) => - { - var is_js = bp_loc.EndsWith(".js", StringComparison.Ordinal); - - // getProperties (isOwn = false, accessorPropertiesOnly = true) - var obj_accessors = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = true, - ownProperties = false - }), token); - if (is_js) - await CheckProps(obj_accessors.Value["result"], new { __proto__ = TIgnore() }, "obj_accessors"); - else - AssertEqual(0, obj_accessors.Value["result"]?.Count(), "obj_accessors-count"); - - // getProperties (isOwn = true, accessorPropertiesOnly = false) - var obj_own = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = false, - ownProperties = true - }), token); - - await CheckProps(obj_own.Value["result"], new - { - length = TNumber(ret_len), - }, $"obj_own"); - }); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, false)] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, true)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, false)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, true)] - public async Task RunOnArrayReturnArray(string eval_fn, string bp_loc, int line, int col, bool roundtrip) - { - var ret_len = 5; - await RunCallFunctionOn(eval_fn, - "function (m) { return Object.values (this).filter ((k, i) => i%m == 0); }", - "big", bp_loc, line, col, - fn_args: JArray.FromObject(new[] { new { value = 2 } }), - res_array_len: ret_len, - roundtrip: roundtrip, - test_fn: async (result) => - { - var is_js = bp_loc.EndsWith(".js"); - - // getProperties (own=false) - var obj_accessors = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = true, - ownProperties = false - }), token); - - if (is_js) - await CheckProps(obj_accessors.Value["result"], new { __proto__ = TIgnore() }, "obj_accessors"); - else - AssertEqual(0, obj_accessors.Value["result"]?.Count(), "obj_accessors-count"); - - // getProperties (own=true) - // isOwn = true, accessorPropertiesOnly = false - var obj_own = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = false, - ownProperties = true - }), token); - - // AssertEqual (2, obj_own.Value ["result"].Count (), $"{label}-obj_own.count"); - - var obj_own_val = obj_own.Value["result"]; - await CheckProps(obj_own_val, new - { - length = TNumber(ret_len), - }, $"obj_own", num_fields: (ret_len + 1)); - - for (int i = 0; i < ret_len; i++) - CheckNumber(obj_own_val, i.ToString(), i * 2 + 1000); - }); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task RunOnVTArray(bool roundtrip) => await RunCallFunctionOn( - "invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", - "function (m) { return Object.values (this).filter ((k, i) => i%m == 0); }", - "ss_arr", - "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, - fn_args: JArray.FromObject(new[] { new { value = 2 } }), - res_array_len: 5, - roundtrip: roundtrip, - test_fn: async (result) => - { - var ret_len = 5; - - // getProperties (own=false) - var obj_accessors = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = true, - ownProperties = false - }), token); - - AssertEqual(0, obj_accessors.Value["result"]?.Count(), "obj_accessors-count"); - - // getProperties (own=true) - // isOwn = true, accessorPropertiesOnly = false - var obj_own = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = false, - ownProperties = true - }), token); - - var obj_own_val = obj_own.Value["result"]; - await CheckProps(obj_own_val, new - { - length = TNumber(ret_len), - // __proto__ returned by JS - }, "obj_own", num_fields: ret_len + 1); - - for (int i = 0; i < ret_len; i++) - { - var act_i = await CheckValueType(obj_own_val, i.ToString(), "Math.SimpleStruct"); - - // Valuetypes can get sent as part of the container's getProperties, so ensure that we can access it - var act_i_props = await GetProperties(act_i["value"]["objectId"]?.Value()); - await CheckProps(act_i_props, new - { - dt = TDateTime(new DateTime(2020 + (i * 2), 1, 2, 3, 4, 5)), - gs = TValueType("Math.GenericStruct") - }, "obj_own ss_arr[{i}]"); - - var gs_props = await GetObjectOnLocals(act_i_props, "gs"); - await CheckProps(gs_props, new - { - List = TObject("System.Collections.Generic.List", is_null: true), - StringField = TString($"ss_arr # {i * 2} # gs # StringField") - }, "obj_own ss_arr[{i}].gs"); - - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task RunOnCFOValueTypeResult(bool roundtrip) => await RunCallFunctionOn( - eval_fn: "invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", - fn_decl: "function () { return this; }", - local_name: "simple_struct", - bp_loc: "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, - roundtrip: roundtrip, - test_fn: async (result) => - { - - // getProperties (own=false) - var obj_accessors = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = true, - ownProperties = false - }), token); - AssertEqual(0, obj_accessors.Value["result"].Count(), "obj_accessors-count"); - - // getProperties (own=true) - // isOwn = true, accessorPropertiesOnly = false - var obj_own = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = false, - ownProperties = true - }), token); - - var obj_own_val = obj_own.Value["result"]; - var dt = new DateTime(2020, 1, 2, 3, 4, 5); - await CheckProps(obj_own_val, new - { - dt = TDateTime(dt), - gs = TValueType("Math.GenericStruct") - }, $"obj_own-props"); - - var gs_props = await GetObjectOnLocals(obj_own_val, "gs"); - await CheckProps(gs_props, new - { - List = TObject("System.Collections.Generic.List", is_null: true), - StringField = TString($"simple_struct # gs # StringField") - }, "simple_struct.gs-props"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task RunOnJSObject(bool roundtrip) => await RunCallFunctionOn( - "object_js_test ();", - "function () { return this; }", - "obj", "/other.js", 19, 1, - fn_args: JArray.FromObject(new[] { new { value = 2 } }), - roundtrip: roundtrip, - test_fn: async (result) => - { - - // getProperties (own=false) - var obj_accessors = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = true, - ownProperties = false - }), token); - - await CheckProps(obj_accessors.Value["result"], new { __proto__ = TIgnore() }, "obj_accessors"); - - // getProperties (own=true) - // isOwn = true, accessorPropertiesOnly = false - var obj_own = await cli.SendCommand("Runtime.getProperties", JObject.FromObject(new - { - objectId = result.Value["result"]["objectId"].Value(), - accessorPropertiesOnly = false, - ownProperties = true - }), token); - - var obj_own_val = obj_own.Value["result"]; - await CheckProps(obj_own_val, new - { - a_obj = TObject("Object"), - b_arr = TArray("Array", "Array(2)") - }, "obj_own"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, false)] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, true)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, false)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, true)] - public async Task RunOnArrayReturnObjectArrayByValue(string eval_fn, string bp_loc, int line, int col, bool roundtrip) - { - var ret_len = 5; - await RunCallFunctionOn(eval_fn, - "function () { return Object.values (this).filter ((k, i) => i%2 == 0); }", - "big", bp_loc, line, col, returnByValue: true, roundtrip: roundtrip, - test_fn: async (result) => - { - // Check cfo result - AssertEqual(JTokenType.Object, result.Value["result"].Type, "cfo-result-jsontype"); - AssertEqual("object", result.Value["result"]["type"]?.Value(), "cfo-res-type"); - - AssertEqual(JTokenType.Array, result.Value["result"]["value"].Type, "cfo-res-value-jsontype"); - var actual = result.Value["result"]?["value"].Values().ToArray(); - AssertEqual(ret_len, actual.Length, "cfo-res-value-length"); - - for (int i = 0; i < ret_len; i++) - { - var exp_num = i * 2 + 1000; - if (bp_loc.EndsWith(".js", StringComparison.Ordinal)) - AssertEqual(exp_num, actual[i].Value(), $"[{i}]"); - else - { - AssertEqual("number", actual[i]?["type"]?.Value(), $"[{i}]-type"); - AssertEqual(exp_num.ToString(), actual[i]?["description"]?.Value(), $"[{i}]-description"); - AssertEqual(exp_num, actual[i]?["value"]?.Value(), $"[{i}]-value"); - } - } - await Task.CompletedTask; - }); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, false)] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, true)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, false)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, true)] - public async Task RunOnArrayReturnArrayByValue(string eval_fn, string bp_loc, int line, int col, bool roundtrip) => await RunCallFunctionOn(eval_fn, - "function () { return Object.getOwnPropertyNames (this); }", - "big", bp_loc, line, col, returnByValue: true, - roundtrip: roundtrip, - test_fn: async (result) => - { - // Check cfo result - AssertEqual("object", result.Value["result"]["type"]?.Value(), "cfo-res-type"); - - var exp = new JArray(); - for (int i = 0; i < 10; i++) - exp.Add(i.ToString()); - exp.Add("length"); - - var actual = result.Value["result"]?["value"]; - if (!JObject.DeepEquals(exp, actual)) - { - Assert.True(false, $"Results don't match.\nExpected: {exp}\nActual: {actual}"); - } - await Task.CompletedTask; - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, false)] - [InlineData("big_array_js_test (10);", "/other.js", 10, 1, true)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, false)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, true)] - public async Task RunOnArrayReturnPrimitive(string eval_fn, string bp_loc, int line, int col, bool return_by_val) - { - await SetBreakpoint(bp_loc, line, col); - - // callFunctionOn - var eval_expr = $"window.setTimeout(function() {{ {eval_fn} }}, 1);"; - var result = await cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), token); - var pause_location = await insp.WaitFor(Inspector.PAUSE); - - // Um for js we get "scriptId": "6" - // CheckLocation (bp_loc, line, col, scripts, pause_location ["callFrames"][0]["location"]); - - // Check the object at the bp - var frame_locals = await GetProperties(pause_location["callFrames"][0]["scopeChain"][0]["object"]["objectId"].Value()); - var obj = GetAndAssertObjectWithName(frame_locals, "big"); - var obj_id = obj["value"]["objectId"].Value(); - - var cfo_args = JObject.FromObject(new - { - functionDeclaration = "function () { return 5; }", - objectId = obj_id - }); - - // value of @returnByValue doesn't matter, as the returned value - // is a primitive - if (return_by_val) - cfo_args["returnByValue"] = return_by_val; - - // callFunctionOn - result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - await CheckValue(result.Value["result"], TNumber(5), "cfo-res"); - - cfo_args = JObject.FromObject(new - { - functionDeclaration = "function () { return 'test value'; }", - objectId = obj_id - }); - - // value of @returnByValue doesn't matter, as the returned value - // is a primitive - if (return_by_val) - cfo_args["returnByValue"] = return_by_val; - - // callFunctionOn - result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - await CheckValue(result.Value["result"], JObject.FromObject(new { type = "string", value = "test value" }), "cfo-res"); - - cfo_args = JObject.FromObject(new - { - functionDeclaration = "function () { return null; }", - objectId = obj_id - }); - - // value of @returnByValue doesn't matter, as the returned value - // is a primitive - if (return_by_val) - cfo_args["returnByValue"] = return_by_val; - - // callFunctionOn - result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - await CheckValue(result.Value["result"], JObject.Parse("{ type: 'object', subtype: 'null', value: null }"), "cfo-res"); - } - - public static TheoryData SilentErrorsTestData(bool? silent) => new TheoryData - { { "invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:LocalsTest', 10);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 23, 12, silent }, - { "big_array_js_test (10);", "/other.js", 10, 1, silent } - }; - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(SilentErrorsTestData), null)] - [MemberData(nameof(SilentErrorsTestData), false)] - [MemberData(nameof(SilentErrorsTestData), true)] - public async Task CFOWithSilentReturnsErrors(string eval_fn, string bp_loc, int line, int col, bool? silent) - { - await SetBreakpoint(bp_loc, line, col); - - // callFunctionOn - var eval_expr = "window.setTimeout(function() { " + eval_fn + " }, 1);"; - var result = await cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), token); - var pause_location = await insp.WaitFor(Inspector.PAUSE); - - var frame_locals = await GetProperties(pause_location["callFrames"][0]["scopeChain"][0]["object"]["objectId"].Value()); - var obj = GetAndAssertObjectWithName(frame_locals, "big"); - var big_obj_id = obj["value"]["objectId"].Value(); - var error_msg = "#This is an error message#"; - - // Check the object at the bp - var cfo_args = JObject.FromObject(new - { - functionDeclaration = $"function () {{ throw Error ('{error_msg}'); }}", - objectId = big_obj_id - }); - - if (silent.HasValue) - cfo_args["silent"] = silent; - - // callFunctionOn, Silent does not change the result, except that the error - // doesn't get reported, and the execution is NOT paused even with setPauseOnException=true - result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - Assert.False(result.IsOk, "result.IsOk"); - - var hasErrorMessage = result.Error["exceptionDetails"]?["exception"]?["description"]?.Value()?.Contains(error_msg); - Assert.True((hasErrorMessage ?? false), "Exception message not found"); - } - - public static TheoryData, string, bool> GettersTestData(string local_name, bool use_cfo) => new TheoryData, string, bool> - { - // Chrome sends this one - { - "invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTest');", - "DebuggerTests.CallFunctionOnTest.PropertyGettersTest", - 30, - 12, - "function invokeGetter(arrayStr){ let result=this; const properties=JSON.parse(arrayStr); for(let i=0,n=properties.length;i JArray.FromObject(arg_strs).ToString(), - local_name, - use_cfo - }, - { - "invoke_static_method_async ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTestAsync');", - "DebuggerTests.CallFunctionOnTest.PropertyGettersTestAsync", - 38, - 12, - "function invokeGetter(arrayStr){ let result=this; const properties=JSON.parse(arrayStr); for(let i=0,n=properties.length;i JArray.FromObject(arg_strs).ToString(), - local_name, - use_cfo - }, - - // VSCode sends this one - { - "invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTest');", - "DebuggerTests.CallFunctionOnTest.PropertyGettersTest", - 30, - 12, - "function(e){return this[e]}", - (args_str) => args_str?.Length > 0 ? args_str[0] : String.Empty, - local_name, - use_cfo - }, - { - "invoke_static_method_async ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTestAsync');", - "DebuggerTests.CallFunctionOnTest.PropertyGettersTestAsync", - 38, - 12, - "function(e){return this[e]}", - (args_str) => args_str?.Length > 0 ? args_str[0] : String.Empty, - local_name, - use_cfo - } - }; - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(GettersTestData), "ptd", false)] - [MemberData(nameof(GettersTestData), "ptd", true)] - [MemberData(nameof(GettersTestData), "swp", false)] - [MemberData(nameof(GettersTestData), "swp", true)] - public async Task PropertyGettersTest(string eval_fn, string method_name, int line, int col, string cfo_fn, Func get_args_fn, string local_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-cfo-test.cs", line, col, - method_name, - $"window.setTimeout(function() {{ {eval_fn} }}, 1);", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - await CheckProps(frame_locals, new - { - ptd = TObject("DebuggerTests.ClassWithProperties"), - swp = TObject("DebuggerTests.StructWithProperties") - }, "locals#0"); - - var obj = GetAndAssertObjectWithName(frame_locals, local_name); - - var dt = new DateTime(4, 5, 6, 7, 8, 9); - var obj_props = await GetProperties(obj?["value"]?["objectId"]?.Value()); - await CheckProps(obj_props, new - { - V = TNumber(0xDEADBEEF), - Int = TGetter("Int"), - String = TGetter("String"), - DT = TGetter("DT"), - IntArray = TGetter("IntArray"), - DTArray = TGetter("DTArray"), - StringField = TString(null), - - // Auto properties show w/o getters, because they have - // a backing field - DTAutoProperty = TDateTime(dt), - - // Static properties - PublicStaticDTProp = TGetter("PublicStaticDTProp"), - PrivateStaticDTProp = TGetter("PrivateStaticDTProp"), - InternalStaticDTProp = TGetter("InternalStaticDTProp"), - }, local_name); - - // Invoke getters, and check values - - dt = new DateTime(3, 4, 5, 6, 7, 8); - var res = await InvokeGetter(obj, get_args_fn(new[] { "Int" }), cfo_fn); - await CheckValue(res.Value["result"], JObject.FromObject(new { type = "number", value = (0xDEADBEEF + (uint)dt.Month) }), $"{local_name}.Int"); - - res = await InvokeGetter(obj, get_args_fn(new[] { "String" }), cfo_fn); - await CheckValue(res.Value["result"], JObject.FromObject(new { type = "string", value = $"String property, V: 0xDEADBEEF" }), $"{local_name}.String"); - - res = await InvokeGetter(obj, get_args_fn(new[] { "DT" }), cfo_fn); - await CheckValue(res.Value["result"], TDateTime(dt), $"{local_name}.DT"); - - // Check arrays through getters - - res = await InvokeGetter(obj, get_args_fn(new[] { "IntArray" }), cfo_fn); - await CheckValue(res.Value["result"], TArray("int[]", "int[2]"), $"{local_name}.IntArray"); - { - var arr_elems = await GetProperties(res.Value["result"]?["objectId"]?.Value()); - var exp_elems = new[] - { - TNumber(10), - TNumber(20) - }; - - await CheckProps(arr_elems, exp_elems, $"{local_name}.IntArray"); - } - - res = await InvokeGetter(obj, get_args_fn(new[] { "DTArray" }), cfo_fn); - await CheckValue(res.Value["result"], TArray("System.DateTime[]", "System.DateTime[2]"), $"{local_name}.DTArray"); - { - var dt0 = new DateTime(6, 7, 8, 9, 10, 11); - var dt1 = new DateTime(1, 2, 3, 4, 5, 6); - - var arr_elems = await GetProperties(res.Value["result"]?["objectId"]?.Value()); - var exp_elems = new[] - { - TDateTime(dt0), - TDateTime(dt1) - }; - - await CheckProps(arr_elems, exp_elems, $"{local_name}.DTArray"); - - res = await InvokeGetter(arr_elems[0], "Date"); - await CheckDateTimeValue(res.Value["result"], dt0.Date); - } - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InvokeInheritedAndPrivateGetters() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.GetPropertiesTests.DerivedClass", "InstanceMethod", 1, "DebuggerTests.GetPropertiesTests.DerivedClass.InstanceMethod", - $"window.setTimeout(function() {{ invoke_static_method_async ('[debugger-test] DebuggerTests.GetPropertiesTests.DerivedClass:run'); }})", - wait_for_event_fn: async (pause_location) => - { - var frame_id = pause_location["callFrames"][0]["callFrameId"].Value(); - var frame_locals = await GetProperties(frame_id); - var this_obj = GetAndAssertObjectWithName(frame_locals, "this"); - - var args = new[] - { - // private - ("_DTProp", TDateTime(new DateTime(2200, 5, 6, 7, 8, 9))), - - // overridden - ("DateTimeForOverride", TDateTime(new DateTime(2190, 9, 7, 5, 3, 2))), - ("FirstName", TString("DerivedClass#FirstName")), - ("StringPropertyForOverrideWithAutoProperty", TString("DerivedClass#StringPropertyForOverrideWithAutoProperty")), - - // inherited - ("_base_dateTime", TDateTime(new DateTime(2134, 5, 7, 1, 9, 2))) - }; - - foreach (var (name, expected) in args) - { - var res = await InvokeGetter(this_obj, name); - await CheckValue(res.Value["result"], expected, name); - } - }); - - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("invoke_static_method_async ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTestAsync');", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 38, 12, true)] - [InlineData("invoke_static_method_async ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTestAsync');", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 38, 12, false)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTest');", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 30, 12, true)] - [InlineData("invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:PropertyGettersTest');", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 30, 12, false)] - [InlineData("invoke_getters_js_test ();", "/other.js", 32, 1, false)] - [InlineData("invoke_getters_js_test ();", "/other.js", 32, 1, true)] - public async Task CheckAccessorsOnObjectsWithCFO(string eval_fn, string bp_loc, int line, int col, bool roundtrip) - { - await RunCallFunctionOn( - eval_fn, "function() { return this; }", "ptd", - bp_loc, line, col, - roundtrip: roundtrip, - test_fn: async (result) => - { - - var is_js = bp_loc.EndsWith(".js"); - - // Check with `accessorPropertiesOnly=true` - - var id = result.Value?["result"]?["objectId"]?.Value(); - var get_prop_req = JObject.FromObject(new - { - objectId = id, - accessorPropertiesOnly = true - }); - - var res = await GetPropertiesAndCheckAccessors(get_prop_req, 5); - Assert.False(res.Value["result"].Any(jt => jt["name"]?.Value() == "StringField"), "StringField shouldn't be returned for `accessorPropertiesOnly`"); - - // Check with `accessorPropertiesOnly` unset, == false - get_prop_req = JObject.FromObject(new - { - objectId = id, - }); - - res = await GetPropertiesAndCheckAccessors(get_prop_req, 7); - Assert.True(res.Value["result"].Any(jt => jt["name"]?.Value() == "StringField"), "StringField should be returned for `accessorPropertiesOnly=false`"); - }); - - async Task GetPropertiesAndCheckAccessors(JObject get_prop_req, int num_fields) - { - var res = await cli.SendCommand("Runtime.getProperties", get_prop_req, token); - if (!res.IsOk) - Assert.True(false, $"Runtime.getProperties failed for {get_prop_req.ToString()}, with Result: {res}"); - - var accessors = new string[] { "Int", "String", "DT", "IntArray", "DTArray" }; - foreach (var name in accessors) - { - var prop = GetAndAssertObjectWithName(res.Value["result"], name); - Assert.True(prop["value"] == null, $"{name} shouldn't have a `value`"); - - await CheckValue(prop, TGetter(name), $"{name}"); - } - - return res; - } - } - - public static TheoryData NegativeTestsData(bool use_cfo = false) => new TheoryData - { { "invoke_static_method ('[debugger-test] DebuggerTests.CallFunctionOnTest:MethodForNegativeTests', null);", "dotnet://debugger-test.dll/debugger-cfo-test.cs", 45, 12, use_cfo }, - { "negative_cfo_test ();", "/other.js", 64, 1, use_cfo } - }; - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(NegativeTestsData), false)] - public async Task RunOnInvalidCfoId(string eval_fn, string bp_loc, int line, int col, bool use_cfo) => await RunCallFunctionOn( - eval_fn, "function() { return this; }", "ptd", - bp_loc, line, col, - test_fn: async (cfo_result) => - { - var ptd_id = cfo_result.Value?["result"]?["objectId"]?.Value(); - - var cfo_args = JObject.FromObject(new - { - functionDeclaration = "function () { return 0; }", - objectId = ptd_id + "_invalid" - }); - - var res = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - Assert.False(res.IsOk); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(NegativeTestsData), false)] - public async Task RunOnInvalidThirdSegmentOfObjectId(string eval_fn, string bp_loc, int line, int col, bool use_cfo) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - await SetBreakpoint(bp_loc, line, col); - - // callFunctionOn - var eval_expr = $"window.setTimeout(function() {{ {eval_fn} }}, 1);"; - var result = await cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), token); - var pause_location = await insp.WaitFor(Inspector.PAUSE); - - var frame_locals = await GetProperties(pause_location["callFrames"][0]["scopeChain"][0]["object"]["objectId"].Value()); - var ptd = GetAndAssertObjectWithName(frame_locals, "ptd"); - var ptd_id = ptd["value"]["objectId"].Value(); - - var cfo_args = JObject.FromObject(new - { - functionDeclaration = "function () { return 0; }", - objectId = ptd_id + "_invalid" - }); - - var res = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - Assert.False(res.IsOk); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(NegativeTestsData), false)] - [MemberData(nameof(NegativeTestsData), true)] - public async Task InvalidPropertyGetters(string eval_fn, string bp_loc, int line, int col, bool use_cfo) - { - await SetBreakpoint(bp_loc, line, col); - UseCallFunctionOnBeforeGetProperties = use_cfo; - - // callFunctionOn - var eval_expr = $"window.setTimeout(function() {{ {eval_fn} }}, 1);"; - await SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr })); - var pause_location = await insp.WaitFor(Inspector.PAUSE); - - var frame_locals = await GetProperties(pause_location["callFrames"][0]["scopeChain"][0]["object"]["objectId"].Value()); - var ptd = GetAndAssertObjectWithName(frame_locals, "ptd"); - var ptd_id = ptd["value"]["objectId"].Value(); - - var invalid_args = new object[] { "NonExistent", String.Empty, null, 12310 }; - foreach (var invalid_arg in invalid_args) - { - var getter_res = await InvokeGetter(JObject.FromObject(new { value = new { objectId = ptd_id } }), invalid_arg); - AssertEqual("undefined", getter_res.Value["result"]?["type"]?.ToString(), $"Expected to get undefined result for non-existent accessor - {invalid_arg}"); - } - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(NegativeTestsData), false)] - public async Task ReturnNullFromCFO(string eval_fn, string bp_loc, int line, int col, bool use_cfo) => await RunCallFunctionOn( - eval_fn, "function() { return this; }", "ptd", - bp_loc, line, col, - test_fn: async (result) => - { - var is_js = bp_loc.EndsWith(".js"); - var ptd = JObject.FromObject(new { value = new { objectId = result.Value?["result"]?["objectId"]?.Value() } }); - - var null_value_json = JObject.Parse("{ 'type': 'object', 'subtype': 'null', 'value': null }"); - foreach (var returnByValue in new bool?[] { null, false, true }) - { - var res = await InvokeGetter(ptd, "StringField", returnByValue: returnByValue); - if (is_js) - { - // In js case, it doesn't know the className, so the result looks slightly different - Assert.True( - JObject.DeepEquals(res.Value["result"], null_value_json), - $"[StringField#returnByValue = {returnByValue}] Json didn't match. Actual: {res.Value["result"]} vs {null_value_json}"); - } - else - { - await CheckValue(res.Value["result"], TString(null), "StringField"); - } - } - }); - - /* - * 1. runs `Runtime.callFunctionOn` on the objectId, - * if @roundtrip == false, then - * -> calls @test_fn for that result (new objectId) - * else - * -> runs it again on the *result's* objectId. - * -> calls @test_fn on the *new* result objectId - * - * Returns: result of `Runtime.callFunctionOn` - */ - async Task RunCallFunctionOn(string eval_fn, string fn_decl, string local_name, string bp_loc, int line, int col, int res_array_len = -1, - Func test_fn = null, bool returnByValue = false, JArray fn_args = null, bool roundtrip = false) - { - await SetBreakpoint(bp_loc, line, col); - - // callFunctionOn - var eval_expr = $"window.setTimeout(function() {{ {eval_fn} }}, 1);"; - var result = await cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), token); - var pause_location = await insp.WaitFor(Inspector.PAUSE); - - // Um for js we get "scriptId": "6" - // CheckLocation (bp_loc, line, col, scripts, pause_location ["callFrames"][0]["location"]); - - // Check the object at the bp - var frame_locals = await GetProperties(pause_location["callFrames"][0]["scopeChain"][0]["object"]["objectId"].Value()); - var obj = GetAndAssertObjectWithName(frame_locals, local_name); - var obj_id = obj["value"]["objectId"].Value(); - - var cfo_args = JObject.FromObject(new - { - functionDeclaration = fn_decl, - objectId = obj_id - }); - - if (fn_args != null) - cfo_args["arguments"] = fn_args; - - if (returnByValue) - cfo_args["returnByValue"] = returnByValue; - - // callFunctionOn - result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - await CheckCFOResult(result); - - // If it wasn't `returnByValue`, then try to run a new function - // on that *returned* object - // This second function, just returns the object as-is, so the same - // test_fn is re-usable. - if (!returnByValue && roundtrip) - { - cfo_args = JObject.FromObject(new - { - functionDeclaration = "function () { return this; }", - objectId = result.Value["result"]["objectId"]?.Value() - }); - - if (fn_args != null) - cfo_args["arguments"] = fn_args; - - result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - - await CheckCFOResult(result); - } - - if (test_fn != null) - await test_fn(result); - - return; - - async Task CheckCFOResult(Result result) - { - if (returnByValue) - return; - - if (res_array_len < 0) - { - await CheckValue(result.Value["result"], TObject("Object"), $"cfo-res"); - } - else - { - // "result" value is purely JS and might diverge from debuggerProxy's messages on each devtool protocol change - var jsArray = JObject.FromObject(new { type = "object", className = "Array", description = $"Array({res_array_len})" }); - await CheckValue(result.Value["result"], jsArray, $"cfo-res"); - } - } - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/ChromeProvider.cs b/src/mono/browser/debugger/DebuggerTestSuite/ChromeProvider.cs deleted file mode 100644 index 1da9fbca98075d..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/ChromeProvider.cs +++ /dev/null @@ -1,178 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.IO; -using System.Net.Http; -using System.Net.WebSockets; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; -using Microsoft.WebAssembly.Diagnostics; -using System.Threading; -using System.Collections.Generic; -using Wasm.Tests.Internal; -using System.Linq; - -#nullable enable - -namespace DebuggerTests; - -internal class ChromeProvider : WasmHostProvider -{ - static readonly Regex s_parseConnection = new (@"listening on (ws?s://[^\s]*)"); - private WebSocket? _ideWebSocket; - private DebuggerProxy? _debuggerProxy; - private static readonly Lazy s_browserPath = new(() => - { - string artifactsBinDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", "..")); - return BrowserLocator.FindChrome(artifactsBinDir, "CHROME_PATH_FOR_TESTS"); - }); - private static readonly string[] s_messagesToFilterOut = new[] - { - "Received unexpected number of handles", - "Failed to connect to the bus:", - }; - - public ChromeProvider(string id, ILogger logger) : base(id, logger) - { - } - - public async Task StartBrowserAndProxyAsync(HttpContext context, - string targetUrl, - int remoteDebuggingPort, - string messagePrefix, - ILoggerFactory loggerFactory, - CancellationTokenSource cts, - int browserReadyTimeoutMs = 20000, - string locale = "en-US") - { - string? line; - try - { - // for WIndows setting --lang arg is enough - if (!OperatingSystem.IsWindows()) - Environment.SetEnvironmentVariable("LANGUAGE", locale); - ProcessStartInfo psi = GetProcessStartInfo(s_browserPath.Value, GetInitParms(remoteDebuggingPort, locale), "about:blank"); - line = await LaunchHostAsync( - psi, - context, - str => - { - if (string.IsNullOrEmpty(str)) - return null; - - Match match = s_parseConnection.Match(str); - return match.Success - ? match.Groups[1].Captures[0].Value - : null; - }, - messagePrefix, - browserReadyTimeoutMs, - cts.Token).ConfigureAwait(false); - - if (_process is null || line is null) - throw new Exception($"Failed to launch chrome"); - } - catch (Exception ex) - { - TestHarnessProxy.RegisterProxyExitState(Id, new(RunLoopStopReason.Exception, ex)); - throw; - } - - string con_str = await ExtractConnUrl(line, _logger); - - _logger.LogInformation($"{messagePrefix} launching proxy for {con_str}"); - - var options = new ProxyOptions(); - options.JustMyCode = true; - _debuggerProxy = new DebuggerProxy(loggerFactory, loggerId: Id, options: options); - TestHarnessProxy.RegisterNewProxy(Id, _debuggerProxy); - var browserUri = new Uri(con_str); - WebSocket? ideSocket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false); - await _debuggerProxy.Run(browserUri, ideSocket, cts).ConfigureAwait(false); - } - - public override void Dispose() - { - if (_isDisposed || _isDisposing) - return; - - _isDisposing = true; - _debuggerProxy?.Shutdown(); - base.Dispose(); - - if (_ideWebSocket is not null) - { - _ideWebSocket.Abort(); - _ideWebSocket.Dispose(); - _ideWebSocket = null; - } - - _isDisposed = true; - _isDisposing = false; - } - - protected override bool ShouldMessageBeLogged(string prefix, string? msg) - { - if (msg is null || !prefix.Contains("browser-stderr")) - return true; - - return !s_messagesToFilterOut.Any(f => msg.Contains(f)); - } - - private async Task ExtractConnUrl (string str, ILogger logger) - { - var client = new HttpClient(); - var start = DateTime.Now; - JArray? obj = null; - - while (true) - { - // Unfortunately it does look like we have to wait - // for a bit after getting the response but before - // making the list request. We get an empty result - // if we make the request too soon. - await Task.Delay(100); - - var res = await client.GetStringAsync(new Uri(new Uri(str), "/json/list")); - logger.LogTrace("res is {0}", res); - - if (!string.IsNullOrEmpty(res)) - { - // Sometimes we seem to get an empty array `[ ]` - obj = JArray.Parse(res); - if (obj != null && obj.Count >= 1) - break; - } - - var elapsed = DateTime.Now - start; - if (elapsed.Milliseconds > 5000) - { - string message = $"Unable to get DevTools /json/list response in {elapsed.Seconds} seconds, stopping"; - logger.LogError(message); - throw new Exception(message); - } - } - - string? wsURl = obj[0]?["webSocketDebuggerUrl"]?.Value(); - if (wsURl is null) - throw new Exception($"Could not get the webSocketDebuggerUrl in {obj}"); - - logger.LogTrace(">>> {0}", wsURl); - - return wsURl; - } - - private static string GetInitParms(int port, string lang="en-US") - { - string str = $"--headless --disable-gpu --lang={lang} --incognito --remote-debugging-port={port}"; - // `/.dockerenv` - is to check if this is running in a codespace - if (DebuggerTestBase.IsRunningInContainer) - str = "--no-sandbox " + str; - return str; - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/CustomViewTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/CustomViewTests.cs deleted file mode 100644 index 0024d46dad4e60..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/CustomViewTests.cs +++ /dev/null @@ -1,146 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using System.Threading; -using Xunit; -using System.Collections.Generic; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - - public class CustomViewTests : DebuggerTests - { - public CustomViewTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task UsingDebuggerDisplay() - { - var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 15); - 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", - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - "DebuggerTests.DebuggerCustomViewTest.run"); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckObject(locals, "a", "DebuggerTests.WithDisplayString", description:"Some one Value 2 End"); - await CheckObject(locals, "c", "DebuggerTests.DebuggerDisplayMethodTest", description: "First Int = 32, Second Int = 43"); - await CheckObject(locals, "myList", "System.Collections.Generic.List", description: "Count = 4"); - await CheckObject(locals, "person1", "DebuggerTests.Person", description: "FirstName = Anton, SurName = Mueller, Age = 44"); - await CheckObject(locals, "person2", "DebuggerTests.Person", description: "FirstName = Lisa, SurName = M\u00FCller, Age = 41"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task UsingDebuggerTypeProxy() - { - var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest", "run", 16); - 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", - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - "DebuggerTests.DebuggerCustomViewTest.run"); - - var frame = pause_location["callFrames"][0]; - var locals = await GetProperties(frame["callFrameId"].Value()); - await CheckObject(locals, "myList", "System.Collections.Generic.List", description: "Count = 4"); - var props = await GetObjectOnFrame(frame, "myList"); - Assert.Equal(1, props.Count()); - - await CheckArray(props, "Items", "int[]", "int[4]"); - - await CheckObject(locals, "b", "DebuggerTests.WithProxy", description:"DebuggerTests.WithProxy"); - props = await GetObjectOnFrame(frame, "b"); - await CheckString(props, "Val2", "one"); - - await CheckValueType(locals, "bs", "DebuggerTests.WithProxyStruct", description:"DebuggerTests.WithProxyStruct"); - props = await GetObjectOnFrame(frame, "bs"); - await CheckString(props, "Val2", "one struct"); - - await CheckObject(locals, "openWith", "System.Collections.Generic.Dictionary", description: "Count = 3"); - props = await GetObjectOnFrame(frame, "openWith"); - Assert.Equal(1, props.Count()); - - await EvaluateOnCallFrameAndCheck(frame["callFrameId"].Value(), - ("listToTestToList.ToList()", TObject("System.Collections.Generic.List", description: "Count = 11"))); - - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task UsingDebuggerDisplayConcurrent() - { - async Task CheckProperties(JObject pause_location) - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var l = GetAndAssertObjectWithName(locals, "myList"); - var val = l["value"]; - if (val["description"].Value() != "Count = 0") - return false; - return true; - } - - var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.DebuggerCustomViewTest2", "run", 2); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DebuggerCustomViewTest2:run'); }, 1);", - "dotnet://debugger-test.dll/debugger-custom-view-test.cs", - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - "DebuggerTests.DebuggerCustomViewTest2.run"); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-custom-view-test.cs", bp.Value["locations"][0]["lineNumber"].Value()+2, bp.Value["locations"][0]["columnNumber"].Value(), "DebuggerTests.DebuggerCustomViewTest2.run"); - - List> tasks = new(); - for (int i = 0 ; i < 10; i++) - { - var task = CheckProperties(pause_location); - tasks.Add(task); - } - await Task.WhenAll(tasks); - foreach(Task task in tasks) - { - //FIXME: blocks - Assert.True(task.Result); - } - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InspectObjectOfTypeWithToStringOverridden() - { - var expression = $"{{ invoke_static_method('[debugger-test] ToStringOverridden:Run'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1561, 8, - "ToStringOverridden.Run", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("a", TObject("ToStringOverridden", description:"helloToStringOverridden")), - ("b", TObject("ToStringOverridden.ToStringOverriddenB", description:"helloToStringOverriddenA")), - ("c", TObject("ToStringOverridden.ToStringOverriddenD", description:"helloToStringOverriddenD")), - ("d", TObject("ToStringOverridden.ToStringOverriddenE", description:"helloToStringOverriddenE")), - ("e", TObject("ToStringOverridden.ToStringOverriddenB", description:"helloToStringOverriddenA")), - ("f", TObject("ToStringOverridden.ToStringOverriddenB", description:"helloToStringOverriddenA")), - ("g", TObject("ToStringOverridden.ToStringOverriddenG", description:"helloToStringOverriddenG")), - ("h", TObject("ToStringOverridden.ToStringOverriddenH", description:"helloToStringOverriddenH")), - ("i", TObject("ToStringOverridden.ToStringOverriddenI", description:"ToStringOverridden.ToStringOverriddenI")), - ("j", TObject("ToStringOverridden.ToStringOverriddenJ", description:"helloToStringOverriddenJ")), - ("k", TObject("ToStringOverridden.ToStringOverriddenK", description:"ToStringOverridden.ToStringOverriddenK")), - ("l", TObject("ToStringOverridden.ToStringOverriddenL", description:"helloToStringOverriddenL")), - ("m", TObject("ToStringOverridden.ToStringOverriddenM", description:"ToStringOverriddenM { }")), - ("n", TObject("ToStringOverridden.ToStringOverriddenN", description:"helloToStringOverriddenN")) - ); - } - ); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/DateTimeTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/DateTimeTests.cs deleted file mode 100644 index b6a7e45e0091be..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/DateTimeTests.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class DateTimeTestsCJK : DebuggerTests - { - public DateTimeTestsCJK(ITestOutputHelper testOutput) : base(testOutput, locale: "ja-JA") - {} - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("ja-JP", "yyyy\u5E74M\u6708d\u65E5dddd H:mm:ss", "yyyy\u5E74M\u6708d\u65E5dddd", "H:mm:ss", "yyyy/MM/dd", "H:mm")] - public async Task CheckDateTimeLocale(string locale, string fdtp, string ldp, string ltp, string sdp, string stp) - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-datetime-test.cs"; - - await SetBreakpointInMethod("debugger-test", "DebuggerTests.DateTimeTest", "LocaleTest", 15); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DateTimeTest:LocaleTest'," + - $"'{locale}'); }}, 1);", - debugger_test_loc, 25, 12, "DebuggerTests.DateTimeTest.LocaleTest", - locals_fn: async (locals) => - { - DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(locale).DateTimeFormat; - CultureInfo.CurrentCulture = new CultureInfo(locale, false); - - await CheckProps(locals, new - { - fdtp = TString(fdtp), - ldp = TString(ldp), - ltp = TString(ltp), - sdp = TString(sdp), - stp = TString(stp), - dt = TDateTime(new DateTime(2020, 1, 2, 3, 4, 5)) - }, "locals", num_fields: 8); - } - ); - } - - } - - public class DateTimeTestsEFIGS : DebuggerTests - { - public DateTimeTestsEFIGS(ITestOutputHelper testOutput) : base(testOutput) - {} - - [Theory] - [InlineData("en-US", "dddd, MMMM d, yyyy h:mm:ss tt", "dddd, MMMM d, yyyy", "h:mm:ss tt", "M/d/yyyy", "h:mm tt")] - [InlineData("es-ES", "dddd, d 'de' MMMM 'de' yyyy H:mm:ss", "dddd, d 'de' MMMM 'de' yyyy", "H:mm:ss", "d/M/yyyy", "H:mm")] - [InlineData("de-DE", "dddd, d. MMMM yyyy HH:mm:ss", "dddd, d. MMMM yyyy", "HH:mm:ss", "dd.MM.yyyy", "HH:mm")] - public async Task CheckDateTimeLocale(string locale, string fdtp, string ldp, string ltp, string sdp, string stp) - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-datetime-test.cs"; - - await SetBreakpointInMethod("debugger-test", "DebuggerTests.DateTimeTest", "LocaleTest", 15); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.DateTimeTest:LocaleTest'," + - $"'{locale}'); }}, 1);", - debugger_test_loc, 25, 12, "DebuggerTests.DateTimeTest.LocaleTest", - locals_fn: async (locals) => - { - DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(locale).DateTimeFormat; - CultureInfo.CurrentCulture = new CultureInfo(locale, false); - - await CheckProps(locals, new - { - fdtp = TString(fdtp), - ldp = TString(ldp), - ltp = TString(ltp), - sdp = TString(sdp), - stp = TString(stp), - dt = TDateTime(new DateTime(2020, 1, 2, 3, 4, 5)) - }, "locals", num_fields: 8); - } - ); - } - - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestBase.cs b/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestBase.cs deleted file mode 100644 index a7ee3962e28f08..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestBase.cs +++ /dev/null @@ -1,1714 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Sdk; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class DebuggerTests : -#if RUN_IN_CHROME - DebuggerTestBase -#else - DebuggerTestFirefox -#endif - { - public const string WebcilInWasmExtension = ".wasm"; - - public DebuggerTests(ITestOutputHelper testOutput, string locale = "en-US", string driver = "debugger-driver.html") - : base(testOutput, locale, driver) - {} - } - - public class DebuggerTestBase : IAsyncLifetime - { - public static WasmHost RunningOn -#if RUN_IN_CHROME - => WasmHost.Chrome; -#else - => WasmHost.Firefox; -#endif - public static bool ReleaseRuntime -#if RELEASE_RUNTIME - => true; -#else - => false; -#endif - public static bool WasmMultiThreaded => EnvironmentVariables.WasmEnableThreads; - - public static bool WasmSingleThreaded => !WasmMultiThreaded; - - public static bool RunningOnChrome => RunningOn == WasmHost.Chrome; - - public static bool RunningOnChromeAndLinux => RunningOn == WasmHost.Chrome && PlatformDetection.IsLinux; - public static bool IsRunningInContainer { get; private set; } - - public const int FirefoxProxyPort = 6002; - - internal InspectorClient cli; - internal Inspector insp; - protected CancellationToken token; - protected Dictionary scripts; - protected Task startTask; - - public bool UseCallFunctionOnBeforeGetProperties; - - private const int DefaultTestTimeoutMs = 1 * 60 * 1000; - protected TimeSpan TestTimeout = TimeSpan.FromMilliseconds(DefaultTestTimeoutMs); - protected ITestOutputHelper _testOutput; - protected readonly TestEnvironment _env; - - static string s_debuggerTestAppPath; - static int s_idCounter = -1; - - public int Id { get; set; } - public string driver; - - public static string DebuggerTestAppPath - { - get - { - if (s_debuggerTestAppPath == null) - s_debuggerTestAppPath = FindTestPath(); - - return s_debuggerTestAppPath; - } - } - - static protected string FindTestPath() - { - string test_app_path = EnvironmentVariables.DebuggerTestPath; - - if (string.IsNullOrEmpty(test_app_path)) - { - var asm_dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); -#if DEBUG - var config="Debug"; -#else - var config="Release"; -#endif - test_app_path = Path.Combine(asm_dir, "..", "..", "..", "debugger-test", config); - - if (string.IsNullOrEmpty(test_app_path)) - throw new Exception("Could not figure out debugger-test app path from the 'DEBUGGER_TEST_PATH' " + - $"environment variable, or based on the test suite location ({asm_dir})"); - } - - if (!string.IsNullOrEmpty(test_app_path)) - test_app_path = Path.Combine(test_app_path, "AppBundle"); - - if (File.Exists(Path.Combine(test_app_path, "debugger-driver.html"))) - return test_app_path; - - throw new Exception($"Cannot find 'debugger-driver.html' in {test_app_path}"); - } - - internal virtual string UrlToRemoteDebugging() => "http://localhost:0"; - - static string s_testLogPath = null; - public static string TestLogPath - { - get - { - if (s_testLogPath == null) - { - string logPathVar = EnvironmentVariables.TestLogPath; - logPathVar = string.IsNullOrEmpty(logPathVar) ? Environment.CurrentDirectory : logPathVar; - Interlocked.CompareExchange(ref s_testLogPath, logPathVar, null); - } - - return s_testLogPath; - } - } - - public static string TempPath => Path.Combine(Path.GetTempPath(), "dbg-tests-tmp"); - static DebuggerTestBase() - { - if (Directory.Exists(TempPath)) - Directory.Delete(TempPath, recursive: true); - - if (File.Exists("/.dockerenv")) - { - Console.WriteLine ("Detected a container, disabling sandboxing for debugger tests."); - IsRunningInContainer = true; - } - } - - public DebuggerTestBase(ITestOutputHelper testOutput, string locale, string _driver = "debugger-driver.html") - { - _env = new TestEnvironment(testOutput); - _testOutput = testOutput; - Id = Interlocked.Increment(ref s_idCounter); - // the debugger is working in locale of the debugged application. For example Datetime.ToString() - // we want the test to mach it. We are also starting chrome with --lang=en-US - System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo(locale); - - insp = new Inspector(Id, _testOutput); - cli = insp.Client; - driver = _driver; - scripts = SubscribeToScripts(insp); - startTask = TestHarnessProxy.Start(DebuggerTestAppPath, driver, UrlToRemoteDebugging(), testOutput, locale); - } - - public virtual async Task InitializeAsync() - { - bool retry = true; - Func)>> fn = (client, token) => - { - Func)> getInitCmdFn = (cmd, args) => (cmd, client.SendCommand(cmd, args, token)); - var init_cmds = new List<(string, Task)> - { - getInitCmdFn("Profiler.enable", null), - getInitCmdFn("Runtime.enable", null), - getInitCmdFn("Debugger.enable", null), - getInitCmdFn("Runtime.runIfWaitingForDebugger", null), - getInitCmdFn("Debugger.setAsyncCallStackDepth", JObject.FromObject(new { maxDepth = 32 })), - getInitCmdFn("Target.setAutoAttach", JObject.FromObject(new { autoAttach = true, waitForDebuggerOnStart = true, flatten = true })) - //getInitCmdFn("ServiceWorker.enable", null) - }; - return init_cmds; - }; - - await Ready(); - try { - await insp.OpenSessionAsync(fn, $"http://{TestHarnessProxy.Endpoint.Authority}/{driver}", TestTimeout); - } - catch (Exception exc) //if failed some reason let's try again - { - if (!retry) - throw new Exception($"Debugger inspector session opening failed and will not be retried: {exc}"); - retry = false; - _testOutput.WriteLine($"Let's retry: {exc.ToString()}"); - try - { - Id = Interlocked.Increment(ref s_idCounter); - insp = new Inspector(Id, _testOutput); - cli = insp.Client; - scripts = SubscribeToScripts(insp); - await insp.OpenSessionAsync(fn, $"http://{TestHarnessProxy.Endpoint.Authority}/{driver}", TestTimeout); - } - catch (Exception secondEx) - { - throw new Exception($"Debugger inspector session opening failed: {secondEx}"); - } - } - } - - public virtual async Task DisposeAsync() - { - await insp.ShutdownAsync().ConfigureAwait(false); - _env.Dispose(); - } - - public Task Ready() => startTask; - - internal Dictionary dicScriptsIdToUrl; - internal Dictionary dicFileToUrl; - internal virtual Dictionary SubscribeToScripts(Inspector insp) - { - dicScriptsIdToUrl = new Dictionary(); - dicFileToUrl = new Dictionary(); - insp.On("Debugger.scriptParsed", DefaultScriptParsedHandler); - return dicScriptsIdToUrl; - } - - protected Task DefaultScriptParsedHandler(JObject args, CancellationToken token) - { - var script_id = args?["scriptId"]?.Value(); - var url = args["url"]?.Value(); - script_id += args["sessionId"]?.Value(); - if (script_id.StartsWith("dotnet://")) - { - var dbgUrl = args["dotNetUrl"]?.Value(); - var arrStr = dbgUrl.Split("/"); - dbgUrl = arrStr[0] + "/" + arrStr[1] + "/" + arrStr[2] + "/" + arrStr[arrStr.Length - 1]; - dicScriptsIdToUrl[script_id] = dbgUrl; - dicFileToUrl[dbgUrl] = args["url"]?.Value(); - } - else if (url.StartsWith("cdp://")) - { - //ignore them as it's done by the browser and vscode-js-debug - } - else if (!String.IsNullOrEmpty(url)) - { - var dbgUrl = args["url"]?.Value(); - var arrStr = dbgUrl.Split("/"); - dicScriptsIdToUrl[script_id] = arrStr[arrStr.Length - 1]; - dicFileToUrl[new Uri(url).AbsolutePath] = url; - } - return Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - } - - internal async Task CheckInspectLocalsAtBreakpointSite(string url_key, int line, int column, string function_name, string eval_expression, - Func test_fn = null, Func wait_for_event_fn = null, bool use_cfo = false) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - - var bp = await SetBreakpoint(url_key, line, column); - - await EvaluateAndCheck( - eval_expression, url_key, line, column, - function_name, - wait_for_event_fn: async (pause_location) => - { - //make sure we're on the right bp - - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location!["callFrames"]?[0]; - - var scope = top_frame!["scopeChain"]?[0]; - if (wait_for_event_fn != null) - await wait_for_event_fn(pause_location); - else - await Task.CompletedTask; - }, - locals_fn: async (locals) => - { - if (test_fn != null) - await test_fn(locals); - } - ); - } - - internal virtual string EvaluateCommand() - { - return "Runtime.evaluate"; - } - - internal virtual JObject CreateEvaluateArgs(string expression) - => JObject.FromObject(new { expression }); - - internal virtual async Task WaitFor(string what) - { - try - { - var timeout = Task.Delay(10000); - var waitForTask = insp.WaitFor(what); - var completedTask = await Task.WhenAny(waitForTask, timeout); - if (completedTask == timeout) - { - throw new TimeoutException($"Debugger inspector waiting for {what} timed out after 10 seconds"); - } - return await waitForTask; - } - catch - { - throw new Exception($"Debugger inspector waiting for {what} failed"); - } - } - - public async Task WaitForConsoleMessage(string message) - { - object llock = new(); - var tcs = new TaskCompletionSource(); - insp.On("Runtime.consoleAPICalled", async (args, c) => - { - (string line, string type) = insp.FormatConsoleAPICalled(args); - if (string.IsNullOrEmpty(line)) - return await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - - lock (llock) - { - try - { - if (line == message) - { - tcs.SetResult(); - } - } - catch (Exception ex) - { - tcs.SetException(ex); - } - } - - return tcs.Task.IsCompleted - ? await Task.FromResult(ProtocolEventHandlerReturn.RemoveHandler) - : await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - }); - - await tcs.Task; - } - public async Task WaitForScriptParsedEventsAsync(params string[] paths) - { - object llock = new(); - List pathsList = new(paths); - var tcs = new TaskCompletionSource(); - insp.On("Debugger.scriptParsed", async (args, c) => - { - await DefaultScriptParsedHandler(args, c); - - string url = args["url"]?.Value(); - if (string.IsNullOrEmpty(url)) - return await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - - lock (llock) - { - try - { - int idx = pathsList.FindIndex(p => url?.EndsWith(p) == true); - if (idx >= 0) - { - pathsList.RemoveAt(idx); - if (pathsList.Count == 0) - { - tcs.SetResult(); - } - } - } - catch (Exception ex) - { - tcs.SetException(ex); - } - } - - return tcs.Task.IsCompleted - ? await Task.FromResult(ProtocolEventHandlerReturn.RemoveHandler) - : await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - }); - - await tcs.Task; - } - - // sets breakpoint by method name and line offset - internal async Task CheckInspectLocalsAtBreakpointSite(string type, string method, int line_offset, string bp_function_name, string eval_expression, - Func locals_fn = null, Func wait_for_event_fn = null, bool use_cfo = false, string assembly = "debugger-test", int col = 0) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - - var bp = await SetBreakpointInMethod(assembly, type, method, line_offset, col); - var res = await cli.SendCommand(EvaluateCommand(), CreateEvaluateArgs(eval_expression), token); - if (!res.IsOk) - { - _testOutput.WriteLine($"Failed to run command {method} with args: {CreateEvaluateArgs(eval_expression)?.ToString()}\nresult: {res.Error.ToString()}"); - Assert.True(false, $"SendCommand for {method} failed with {res.Error.ToString()}"); - } - var pause_location = await WaitFor(Inspector.PAUSE); - - if (bp_function_name != null) - Assert.Equal(bp_function_name, pause_location["callFrames"]?[0]?["functionName"]?.Value()); - - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location!["callFrames"]?[0]; - - var scope = top_frame?["scopeChain"]?[0]; - - if (wait_for_event_fn != null) - await wait_for_event_fn(pause_location); - - if (locals_fn != null) - { - var locals = await GetProperties(pause_location?["callFrames"]?[0]?["callFrameId"]?.Value()); - await locals_fn(locals); - } - } - - internal virtual void CheckLocation(string script_loc, int line, int column, Dictionary scripts, JToken location) - { - var loc_str = $"{ scripts[location["scriptId"].Value()+cli.CurrentSessionId.sessionId] }" + - $"#{ location["lineNumber"].Value() }" + - $"#{ location["columnNumber"].Value() }"; - - var expected_loc_str = $"{script_loc}#{line}#{column}"; - Assert.Equal(expected_loc_str, loc_str); - } - - internal virtual void CheckLocationLine(JToken location, int line) - { - Assert.Equal(location["lineNumber"].Value(), line); - } - - internal void CheckNumber(JToken locals, string name, T value) - { - foreach (var l in locals) - { - if (name != l["name"]?.Value()) - continue; - var val = l["value"]; - Assert.Equal("number", val["type"]?.Value()); - Assert.Equal(value, val["value"].Value()); - Assert.Equal(value.ToString(), val["description"].Value().ToString()); - return; - } - Assert.True(false, $"Could not find variable '{name}'"); - } - - internal void CheckNumberAsString(JToken locals, string name, string value) - { - foreach (var l in locals) - { - if (name != l["name"]?.Value()) - continue; - var val = l["value"]; - Assert.Equal("number", val["type"]?.Value()); - Assert.Equal(value, val["value"].ToString()); - return; - } - Assert.True(false, $"Could not find variable '{name}'"); - } - - internal async Task CheckString(JToken locals, string name, string value) - { - var l = GetAndAssertObjectWithName(locals, name); - await CheckValue(l["value"], TString(value), name); - } - - internal async Task CheckSymbol(JToken locals, string name, char value) - { - var l = GetAndAssertObjectWithName(locals, name); - await CheckValue(l["value"], TChar(value), name); - return l; - } - - internal async Task Check(JToken locals, string name, JObject expected) - { - var l = GetAndAssertObjectWithName(locals, name); - await CheckValue(l["value"], expected, name); - return l; - } - - internal async Task CheckObject(JToken locals, string name, string class_name, string subtype = null, bool is_null = false, string description = null) - { - var l = GetAndAssertObjectWithName(locals, name); - var val = l["value"]; - await CheckValue(val, TObject(class_name, is_null: is_null, description: description), name); - Assert.True(val["isValueType"] == null || !val["isValueType"].Value()); - - return l; - } - - internal async Task CheckPointerValue(JToken locals, string name, JToken expected, string label = null) - { - var l = GetAndAssertObjectWithName(locals, name); - await CheckValue(l["value"], expected, $"{label ?? String.Empty}-{name}"); - return l; - } - - internal async Task CheckDateTime(JToken value, DateTime expected, string label = "") - { - await CheckValue(value, TValueType("System.DateTime", expected.ToString()), label); - await CheckDateTimeValue(value, expected, label); - } - - internal async Task CheckDateTime(JToken locals, string name, DateTime expected, string label = "") - { - var obj = GetAndAssertObjectWithName(locals, name, label); - await CheckDateTimeValue(obj["value"], expected, label); - } - - async Task CheckDateTimeMembers(JToken v, DateTime exp_dt, string label = "") - { - AssertEqual("System.DateTime", v["className"]?.Value(), $"{label}#className"); - AssertEqual(exp_dt.ToString(), v["description"]?.Value(), $"{label}#description"); - - var members = await GetProperties(v["objectId"]?.Value()); - - // not checking everything - CheckNumber(members, "Year", exp_dt.Year); - CheckNumber(members, "Month", exp_dt.Month); - CheckNumber(members, "Day", exp_dt.Day); - CheckNumber(members, "Hour", exp_dt.Hour); - CheckNumber(members, "Minute", exp_dt.Minute); - CheckNumber(members, "Second", exp_dt.Second); - } - - internal virtual async Task CheckDateTimeGetter(JToken value, DateTime expected, string label = "") - { - var res = await InvokeGetter(JObject.FromObject(new { value = value }), "Date"); - await CheckDateTimeMembers(res.Value["result"], expected.Date, label); - } - - internal async Task CheckDateTimeValue(JToken value, DateTime expected, string label = "") - { - await CheckDateTimeMembers(value, expected, label); - - await CheckDateTimeGetter(value, expected, label); - } - - internal async Task CheckBool(JToken locals, string name, bool expected) - { - var l = GetAndAssertObjectWithName(locals, name); - await CheckValue(l["value"], TBool(expected), name); - return l; - } - - internal void CheckContentValue(JToken token, string value) - { - var val = token["value"].Value(); - Assert.Equal(value, val); - } - - internal void CheckContainsJObject(JToken locals, JToken comparedTo, string name) - { - var val = GetAndAssertObjectWithName(locals, name); - JObject refValue = (JObject)val["value"]; - refValue?.Property("objectId")?.Remove(); - JObject comparedToValue = (JObject)comparedTo["value"]; - comparedToValue?.Property("objectId")?.Remove(); - Assert.Equal(val, comparedTo); - } - - internal async Task CheckValueType(JToken locals, string name, string class_name, string description=null) - { - var l = GetAndAssertObjectWithName(locals, name); - await CheckValue(l["value"], TValueType(class_name, description: description), name); - return l; - } - - internal async Task CheckEnum(JToken locals, string name, string class_name, string descr) - { - var l = GetAndAssertObjectWithName(locals, name); - await CheckValue(l["value"], TEnum(class_name, descr), name); - return l; - } - - internal async Task CheckArray(JToken locals, string name, string class_name, string description) - => await CheckValue( - GetAndAssertObjectWithName(locals, name)["value"], - TArray(class_name, description), name); - - internal JToken GetAndAssertObjectWithName(JToken obj, string name, string label = "") - { - var l = obj.FirstOrDefault(jt => jt["name"]?.Value() == name); - if (l == null) - Assert.True(false, $"[{label}] Could not find variable '{name}'"); - return l; - } - - internal async Task SendCommand(string method, JObject args) - { - var res = await cli.SendCommand(method, args, token); - if (!res.IsOk) - { - _testOutput.WriteLine($"Failed to run command {method} with args: {args?.ToString()}\nresult: {res.Error.ToString()}"); - Assert.True(false, $"SendCommand for {method} failed with {res.Error.ToString()}"); - } - return res; - } - - internal async Task Evaluate(string expression) - { - return await SendCommand(EvaluateCommand(), CreateEvaluateArgs(expression)); - } - - internal void AssertLocation(JObject args, string methodName) - { - Assert.Equal(methodName, args["callFrames"]?[0]?["functionName"]?.Value()); - } - - // Place a breakpoint in the given method and run until its hit - // Return the Debugger.paused data - internal async Task RunUntil(string methodName) - { - await SetBreakpointInMethod("debugger-test", "DebuggerTest", methodName); - // This will run all the tests until it hits the bp - await Evaluate("window.setTimeout(function() { invoke_run_all (); }, 1);"); - var wait_res = await WaitFor(Inspector.PAUSE); - AssertLocation(wait_res, "DebuggerTest.locals_inner"); - return wait_res; - } - - internal async Task InvokeGetter(JToken obj, object arguments, string fn = "function(e){return this[e]}", bool expect_ok = true, bool? returnByValue = null) - { - var req = JObject.FromObject(new - { - functionDeclaration = fn, - objectId = obj["value"]?["objectId"]?.Value(), - arguments = new[] { new { value = arguments } } - }); - if (returnByValue != null) - req["returnByValue"] = returnByValue.Value; - - var res = await cli.SendCommand("Runtime.callFunctionOn", req, token); - Assert.True(expect_ok == res.IsOk, $"InvokeGetter failed for {req} with {res}"); - - return res; - } - - internal async Task SetValueOnObject(JToken obj, string property, string newvalue, string fn = "function(a, b) { this[a] = b; }", bool expect_ok = true) - { - var req = JObject.FromObject(new - { - functionDeclaration = fn, - objectId = obj["value"]?["objectId"]?.Value(), - arguments = new[] { new { value = property }, new { value = newvalue } }, - silent = true - }); - var res = await cli.SendCommand("Runtime.callFunctionOn", req, token); - Assert.True(expect_ok == res.IsOk, $"SetValueOnObject failed for {req} with {res}"); - - return res; - } - - internal virtual async Task StepAndCheck(StepKind kind, string script_loc, int line, int column, string function_name, - Func wait_for_event_fn = null, Func locals_fn = null, int times = 1) - { - string method = (kind == StepKind.Resume ? "Debugger.resume" : $"Debugger.step{kind}"); - for (int i = 0; i < times - 1; i++) - { - await SendCommandAndCheck(null, method, null, -1, -1, null); - } - - // Check for method/line etc only at the last step - return await SendCommandAndCheck( - null, method, script_loc, line, column, function_name, - wait_for_event_fn: wait_for_event_fn, - locals_fn: locals_fn); - } - - internal async Task SetNextIPAndCheck(string script_id, string script_loc, int line, int column, string function_name, - Func wait_for_event_fn = null, Func locals_fn = null, bool expected_error = false) - { - var setNextIPArgs = JObject.FromObject(new - { - scriptId = script_id, - lineNumber = line, - columnNumber = column - }); - - if (!expected_error) - { - return await SendCommandAndCheck( - JObject.FromObject(new { location = setNextIPArgs }), "DotnetDebugger.setNextIP", script_loc, line, column, function_name, - wait_for_event_fn: wait_for_event_fn, - locals_fn: locals_fn); - } - - var res = await cli.SendCommand("DotnetDebugger.setNextIP", JObject.FromObject(new { location = setNextIPArgs }), token); - Assert.False(res.IsOk); - return JObject.FromObject(res); - } - - internal virtual async Task EvaluateAndCheck( - string expression, string script_loc, int line, int column, string function_name, - Func wait_for_event_fn = null, Func locals_fn = null) - => await SendCommandAndCheck( - CreateEvaluateArgs(expression), - "Runtime.evaluate", script_loc, line, column, function_name, - wait_for_event_fn: wait_for_event_fn, - locals_fn: locals_fn); - - internal virtual async Task SendCommandAndCheck(JObject args, string method, string script_loc, int line, int column, string function_name, - Func wait_for_event_fn = null, Func locals_fn = null, string waitForEvent = Inspector.PAUSE) - { - var res = await cli.SendCommand(method, args, token); - if (!res.IsOk) - { - _testOutput.WriteLine($"Failed to run command {method} with args: {args?.ToString()}\nresult: {res.Error.ToString()}"); - Assert.True(false, $"SendCommand for {method} failed with {res.Error.ToString()}"); - } - - var wait_res = await WaitFor(waitForEvent); - JToken top_frame = wait_res["callFrames"]?[0]; - if (function_name != null) - { - AssertEqual(function_name, wait_res["callFrames"]?[0]?["functionName"]?.Value(), top_frame?.ToString()); - } - - if (script_loc != null && line >= 0) - CheckLocation(script_loc, line, column, scripts, top_frame["location"]); - - if (wait_for_event_fn != null) - await wait_for_event_fn(wait_res); - - if (locals_fn != null) - { - var locals = await GetProperties(wait_res["callFrames"][0]["callFrameId"].Value()); - try - { - await locals_fn(locals); - } - catch (System.AggregateException ex) - { - throw new AggregateException(ex.Message + " \n" + locals.ToString(), ex); - } - } - - return wait_res; - } - - internal async Task CheckDelegate(JToken locals, string name, string className, string target) - { - var l = GetAndAssertObjectWithName(locals, name); - var val = l["value"]; - - await CheckDelegate(l, TDelegate(className, target), name); - } - - internal async Task CheckDelegate(JToken actual_val, JToken exp_val, string label) - { - AssertEqual("object", actual_val["type"]?.Value(), $"{label}-type"); - AssertEqual(exp_val["className"]?.Value(), actual_val["className"]?.Value(), $"{label}-className"); - - var actual_target = actual_val["description"]?.Value(); - Assert.True(actual_target != null, $"${label}-description"); - var exp_target = exp_val["target"].Value(); - - CheckDelegateTarget(actual_target, exp_target); - - var del_props = await GetProperties(actual_val["objectId"]?.Value()); - AssertEqual(1, del_props.Count(), $"${label}-delegate-properties-count"); - - var obj = del_props.Where(jt => jt["name"]?.Value() == "Target").FirstOrDefault(); - Assert.True(obj != null, $"[{label}] Property named 'Target' found found in delegate properties"); - - AssertEqual("symbol", obj["value"]?["type"]?.Value(), $"{label}#Target#type"); - CheckDelegateTarget(obj["value"]?["value"]?.Value(), exp_target); - - return; - - void CheckDelegateTarget(string actual_target, string exp_target) - { - var parts = exp_target.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - if (parts.Length == 1) - { - // not a generated method - AssertEqual(exp_target, actual_target, $"{label}-description"); - } - else - { - bool prefix = actual_target.StartsWith(parts[0], StringComparison.Ordinal); - Assert.True(prefix, $"{label}-description, Expected target to start with '{parts[0]}'. Actual: '{actual_target}'"); - - var remaining = actual_target.Substring(parts[0].Length); - bool suffix = remaining.EndsWith(parts[1], StringComparison.Ordinal); - Assert.True(prefix, $"{label}-description, Expected target to end with '{parts[1]}'. Actual: '{remaining}'"); - } - } - } - - internal async Task CheckCustomType(JToken actual_val, JToken exp_val, string label) - { - var ctype = exp_val["__custom_type"].Value(); - switch (ctype) - { - case "delegate": - await CheckDelegate(actual_val, exp_val, label); - break; - - case "pointer": - { - - if (exp_val["is_null"]?.Value() == true) - { - AssertEqual("symbol", actual_val["type"]?.Value(), $"{label}-type"); - - var exp_val_str = $"({exp_val["type_name"]?.Value()}) 0"; - AssertEqual(exp_val_str, actual_val["value"]?.Value(), $"{label}-value"); - AssertEqual(exp_val_str, actual_val["description"]?.Value(), $"{label}-description"); - } - else if (exp_val["is_void"]?.Value() == true) - { - AssertEqual("symbol", actual_val["type"]?.Value(), $"{label}-type"); - - var exp_val_str = $"({exp_val["type_name"]?.Value()})"; - AssertStartsWith(exp_val_str, actual_val["value"]?.Value(), $"{label}-value"); - AssertStartsWith(exp_val_str, actual_val["description"]?.Value(), $"{label}-description"); - } - else - { - AssertEqual("object", actual_val["type"]?.Value(), $"{label}-type"); - - var exp_prefix = $"({exp_val["type_name"]?.Value()})"; - AssertStartsWith(exp_prefix, actual_val["className"]?.Value(), $"{label}-className"); - AssertStartsWith(exp_prefix, actual_val["description"]?.Value(), $"{label}-description"); - Assert.False(actual_val["className"]?.Value() == $"{exp_prefix} 0", $"[{label}] Expected a non-null value, but got {actual_val}"); - } - break; - } - - case "getter": - { - // For getter, `actual_val` is not `.value`, instead it's the container object - // which has a `.get` instead of a `.value` - var get = actual_val?["get"]; - Assert.True(get != null, $"[{label}] No `get` found. {(actual_val != null ? "Make sure to pass the container object for testing getters, and not the ['value']" : String.Empty)}"); - - AssertEqual("Function", get["className"]?.Value(), $"{label}-className"); - AssertStartsWith($"get {exp_val["type_name"]?.Value()} ()", get["description"]?.Value(), $"{label}-description"); - AssertEqual("function", get["type"]?.Value(), $"{label}-type"); - var expectedValue = exp_val["value"]; - if (expectedValue.Type != JTokenType.Null) - { - var valueAfterRunGet = await GetProperties(get["objectId"]?.Value()); - await CheckValue(valueAfterRunGet[0]["value"], expectedValue, exp_val["type_name"]?.Value()); - } - break; - } - - case "datetime": - { - var dateTime = DateTime.FromBinary(exp_val["binary"].Value()); - await CheckDateTime(actual_val, dateTime, label); - break; - } - - case "ignore_me": - // nothing to check ;) - break; - - default: - throw new ArgumentException($"{ctype} not supported"); - } - } - - internal async Task CheckProps(JToken actual, object exp_o, string label, int num_fields = -1, bool skip_num_fields_check = false) - { - if (exp_o.GetType().IsArray || exp_o is JArray) - { - if (!(actual is JArray actual_arr)) - { - Assert.True(false, $"[{label}] Expected to get an array here but got {actual}"); - return; - } - - var exp_v_arr = JArray.FromObject(exp_o); - AssertEqual(exp_v_arr.Count, actual_arr.Count(), $"{label}-count"); - - for (int i = 0; i < exp_v_arr.Count; i++) - { - var exp_i = exp_v_arr[i]; - var act_i = actual_arr[i]; - - string exp_name = exp_i["name"]?.Value(); - if (string.IsNullOrEmpty(exp_name)) - exp_name = i.ToString(); - - AssertEqual(exp_name, act_i["name"]?.Value(), $"{label}-[{i}].name"); - if (exp_i != null) - { - await CheckValue(act_i["value"], - ((JObject)exp_i).GetValue("value")?.HasValues == true ? exp_i["value"] : exp_i, - $"{label}-{i}th value"); - } - } - return; - } - // Not an array - var exp = exp_o as JObject; - if (exp == null) - exp = JObject.FromObject(exp_o); - - if (!skip_num_fields_check) - { - num_fields = num_fields < 0 ? exp.Values().Count() : num_fields; - var expected_str = string.Join(", ", - exp.Children() - .Select(e => e is JProperty jprop ? jprop.Name : e["name"]?.Value()) - .Where(e => !string.IsNullOrEmpty(e)) - .OrderBy(e => e)); - - var actual_str = string.Join(", ", - actual.Children() - .Select(e => e["name"]?.Value()) - .Where(e => !string.IsNullOrEmpty(e)) - .OrderBy(e => e)); - Assert.True(num_fields == actual.Count(), $"[{label}] Number of fields don't match, Expected: {num_fields}, Actual: {actual.Count()}.{Environment.NewLine}" - + $" Expected: {expected_str}{Environment.NewLine}" - + $" Actual: {actual_str}"); - } - - foreach (var kvp in exp) - { - var exp_name = kvp.Key; - var exp_val = kvp.Value; - - var actual_obj = actual.FirstOrDefault(jt => jt["name"]?.Value() == exp_name); - if (actual_obj == null) - { - Assert.True(actual_obj != null, $"[{label}] Could not find property named '{exp_name}'"); - } - - Assert.True(actual_obj != null, $"[{label}] not value found for property named '{exp_name}'"); - - if (exp_val.Type == JTokenType.Array) - { - var actual_props = await GetProperties(actual_obj["value"]["objectId"]?.Value()); - await CheckProps(actual_props, exp_val, $"{label}-{exp_name}"); - } - else if (exp_val["__custom_type"] != null && exp_val["__custom_type"]?.Value() == "getter") - { - // hack: for getters, actual won't have a .value - await CheckCustomType(actual_obj, exp_val, $"{label}#{exp_name}"); - } - else - { - await CheckValue(actual_obj["value"], exp_val, $"{label}#{exp_name}"); - } - } - } - - internal virtual bool SkipProperty(string propertyName) - { - return false; - } - - internal async Task CheckValue(JToken actual_val, JToken exp_val, string label) - { - if (exp_val["__custom_type"] != null) - { - await CheckCustomType(actual_val, exp_val, label); - return; - } - - if (exp_val["type"] == null && actual_val["objectId"] != null) - { - var new_val = await GetProperties(actual_val["objectId"].Value()); - await CheckProps(new_val, exp_val, $"{label}-{actual_val["objectId"]?.Value()}"); - return; - } - - try - { - foreach (var jp in exp_val.Values()) - { - if (SkipProperty(jp.Name)) - continue; - if (jp.Value.Type == JTokenType.Object) - { - var new_val = await GetProperties(actual_val["objectId"].Value()); - await CheckProps(new_val, jp.Value, $"{label}-{actual_val["objectId"]?.Value()}"); - - continue; - } - - var exp_val_str = jp.Value.Value(); - bool null_or_empty_exp_val = String.IsNullOrEmpty(exp_val_str); - var actual_field_val = actual_val?.Values()?.FirstOrDefault(a_jp => a_jp.Name == jp.Name); - var actual_field_val_str = actual_field_val?.Value?.Value(); - if (null_or_empty_exp_val && String.IsNullOrEmpty(actual_field_val_str)) - continue; - - Assert.True(actual_field_val != null, $"[{label}] Could not find value field named {jp.Name}"); - AssertEqual(exp_val_str, actual_field_val_str, $"[{label}] Value for json property named {jp.Name} didn't match."); - } - } - catch (Exception ex) - { - _testOutput.WriteLine($"{ex.Message} \nExpected: {exp_val} \nActual: {actual_val}"); - throw; - } - } - - internal async Task GetLocalsForFrame(JToken frame, string script_loc, int line, int column, string function_name) - { - CheckLocation(script_loc, line, column, scripts, frame["location"]); - Assert.Equal(function_name, frame["functionName"].Value()); - - return await GetProperties(frame["callFrameId"].Value()); - } - - internal async Task GetObjectOnFrame(JToken frame, string name) - { - var locals = await GetProperties(frame["callFrameId"].Value()); - return await GetObjectOnLocals(locals, name); - } - - // Find an object with @name, *fetch* the object, and check against @o - internal async Task CompareObjectPropertiesFor(JToken locals, string name, object o, string label = null, int num_fields = -1, bool skip_num_fields_check = false) - { - if (label == null) - label = name; - var props = await GetObjectOnLocals(locals, name); - try - { - if (o != null) - await CheckProps(props, o, label, num_fields, skip_num_fields_check); - return props; - } - catch - { - throw; - } - } - - internal async Task GetObjectOnLocals(JToken locals, string name) - { - var obj = GetAndAssertObjectWithName(locals, name); - var objectId = obj["value"]["objectId"]?.Value(); - Assert.True(!String.IsNullOrEmpty(objectId), $"No objectId found for {name}"); - - return await GetProperties(objectId); - } - - internal void AssertInternalUseFieldsAreRemoved(JToken item) - { - if (item is JObject jobj && jobj.Count != 0) - { - foreach (JProperty jp in jobj.Properties()) - { - Assert.False(InternalUseFieldName.IsKnown(jp.Name), - $"Property {jp.Name} of object: {jobj} is for internal proxy use and should not be exposed externally."); - } - } - } - - /* @fn_args is for use with `Runtime.callFunctionOn` only */ - internal virtual async Task GetProperties(string id, JToken fn_args = null, bool? own_properties = null, bool? accessors_only = null, bool expect_ok = true) - { - if (UseCallFunctionOnBeforeGetProperties && !id.StartsWith("dotnet:scope:")) - { - var fn_decl = "function () { return this; }"; - var cfo_args = JObject.FromObject(new - { - functionDeclaration = fn_decl, - objectId = id - }); - if (fn_args != null) - cfo_args["arguments"] = fn_args; - - var result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - AssertEqual(expect_ok, result.IsOk, $"Runtime.getProperties returned {result.IsOk} instead of {expect_ok}, for {cfo_args.ToString()}, with Result: {result}"); - if (!result.IsOk) - return null; - id = result.Value["result"]?["objectId"]?.Value(); - } - - var get_prop_req = JObject.FromObject(new - { - objectId = id - }); - if (own_properties.HasValue) - { - get_prop_req["ownProperties"] = own_properties.Value; - } - if (accessors_only.HasValue) - { - get_prop_req["accessorPropertiesOnly"] = accessors_only.Value; - } - - var frame_props = await cli.SendCommand("Runtime.getProperties", get_prop_req, token); - AssertEqual(expect_ok, frame_props.IsOk, $"Runtime.getProperties returned {frame_props.IsOk} instead of {expect_ok}, for {get_prop_req}, with Result: {frame_props}"); - if (!frame_props.IsOk) - return null; - - var locals = frame_props.Value["result"]; - var locals_internal = frame_props.Value["internalProperties"]; - var locals_private = frame_props.Value["privateProperties"]; - - if (locals_internal != null) - locals = new JArray(locals.Union(locals_internal)); - if (locals_private != null) - locals = new JArray(locals.Union(locals_private)); - // FIXME: Should be done when generating the list in dotnet.es6.lib.js, but not sure yet - // whether to remove it, and how to do it correctly. - if (locals is JArray) - { - foreach (var p in locals) - { - AssertInternalUseFieldsAreRemoved(p); - if (p["name"]?.Value() == "length" && p["enumerable"]?.Value() != true) - { - p.Remove(); - break; - } - } - } - return locals; - } - - internal async Task<(JToken, JToken)> GetPropertiesSortedByProtectionLevels(string id, JToken fn_args = null, bool? own_properties = null, bool? accessors_only = null, bool expect_ok = true) - { - if (UseCallFunctionOnBeforeGetProperties && !id.StartsWith("dotnet:scope:")) - { - var fn_decl = "function () { return this; }"; - var cfo_args = JObject.FromObject(new - { - functionDeclaration = fn_decl, - objectId = id - }); - if (fn_args != null) - cfo_args["arguments"] = fn_args; - - var result = await cli.SendCommand("Runtime.callFunctionOn", cfo_args, token); - AssertEqual(expect_ok, result.IsOk, $"Runtime.getProperties returned {result.IsOk} instead of {expect_ok}, for {cfo_args.ToString()}, with Result: {result}"); - if (!result.IsOk) - return (null, null); - id = result.Value["result"]?["objectId"]?.Value(); - } - - var get_prop_req = JObject.FromObject(new - { - objectId = id - }); - if (own_properties.HasValue) - { - get_prop_req["ownProperties"] = own_properties.Value; - } - if (accessors_only.HasValue) - { - get_prop_req["accessorPropertiesOnly"] = accessors_only.Value; - } - - var frame_props = await cli.SendCommand("Runtime.getProperties", get_prop_req, token); - AssertEqual(expect_ok, frame_props.IsOk, $"Runtime.getProperties returned {frame_props.IsOk} instead of {expect_ok}, for {get_prop_req}, with Result: {frame_props}"); - if (!frame_props.IsOk) - return (null, null);; - - var locals = frame_props.Value["result"]; - var locals_private = frame_props.Value["privateProperties"]; - - // FIXME: Should be done when generating the list in dotnet.es6.lib.js, but not sure yet - // whether to remove it, and how to do it correctly. - if (locals is JArray) - { - foreach (var p in locals) - { - AssertInternalUseFieldsAreRemoved(p); - if (p["name"]?.Value() == "length" && p["enumerable"]?.Value() != true) - { - p.Remove(); - break; - } - } - } - - return (locals, locals_private); - } - - internal virtual async Task<(JToken, Result)> EvaluateOnCallFrame(string id, string expression, bool expect_ok = true) - { - var evaluate_req = JObject.FromObject(new - { - callFrameId = id, - expression = expression - }); - - var res = await cli.SendCommand("Debugger.evaluateOnCallFrame", evaluate_req, token); - AssertEqual(expect_ok, res.IsOk, $"Debugger.evaluateOnCallFrame ('{expression}', scope: {id}) returned {res.IsOk} instead of {expect_ok}, with Result: {res}"); - if (res.IsOk) - return (res.Value["result"], res); - - return (null, res); - } - - internal async Task RuntimeEvaluateAndCheck(params (string expression, JObject expected)[] args) - { - foreach (var arg in args) - { - var (eval_val, _) = await RuntimeEvaluate(arg.expression); - try - { - await CheckValue(eval_val, arg.expected, arg.expression); - } - catch - { - _testOutput.WriteLine($"CheckValue failed for {arg.expression}. Expected: {arg.expected}, vs {eval_val}"); - throw; - } - } - } - internal async Task<(JToken, Result)> RuntimeEvaluate(string expression, bool expect_ok = true) - { - var evaluate_req = JObject.FromObject(new - { - expression = expression - }); - - var res = await cli.SendCommand("Runtime.evaluate", evaluate_req, token); - AssertEqual(expect_ok, res.IsOk, $"Runtime.evaluate ('{expression}') returned {res.IsOk} instead of {expect_ok}, with Result: {res}"); - if (res.IsOk) - return (res.Value["result"], res); - - return (null, res); - } - - internal async Task<(JToken, Result)> SetVariableValueOnCallFrame(JObject parms, bool expect_ok = true) - { - var res = await cli.SendCommand("Debugger.setVariableValue", parms, token); - AssertEqual(expect_ok, res.IsOk, $"Debugger.setVariableValue ('{parms}') returned {res.IsOk} instead of {expect_ok}, with Result: {res}"); - if (res.IsOk) - return (res.Value["result"], res); - - return (null, res); - } - - internal async Task RemoveBreakpoint(string id, bool expect_ok = true) - { - var remove_bp = JObject.FromObject(new - { - breakpointId = id - }); - - var res = await cli.SendCommand("Debugger.removeBreakpoint", remove_bp, token); - Assert.True(expect_ok ? res.IsOk : !res.IsOk); - - return res; - } - - internal virtual async Task SetBreakpoint(string url_key, int line, int column, bool expect_ok = true, bool use_regex = false, string condition = "") - { - JObject bp1_req; - if (column != -1) - { - bp1_req = !use_regex ? - JObject.FromObject(new { lineNumber = line, columnNumber = column, url = dicFileToUrl[url_key], condition }) : - JObject.FromObject(new { lineNumber = line, columnNumber = column, urlRegex = url_key, condition }); - } - else - { - bp1_req = !use_regex ? - JObject.FromObject(new { lineNumber = line, url = dicFileToUrl[url_key], condition }) : - JObject.FromObject(new { lineNumber = line, urlRegex = url_key, condition }); - } - - var bp1_res = await cli.SendCommand("Debugger.setBreakpointByUrl", bp1_req, token); - Assert.True(expect_ok ? bp1_res.IsOk : !bp1_res.IsOk); - - return bp1_res; - } - - internal async Task SetPauseOnException(string state) - { - var exc_res = await cli.SendCommand("Debugger.setPauseOnExceptions", JObject.FromObject(new { state = state }), token); - return exc_res; - } - - internal virtual async Task SetBreakpointInMethod(string assembly, string type, string method, int lineOffset = 0, int col = 0, string condition = "") - { - var req = JObject.FromObject(new { assemblyName = assembly, typeName = type, methodName = method, lineOffset = lineOffset }); - - // Protocol extension - var res = await cli.SendCommand("DotnetDebugger.getMethodLocation", req, token); - Assert.True(res.IsOk); - - var m_url = res.Value["result"]["url"].Value(); - var m_line = res.Value["result"]["line"].Value(); - - var bp1_req = JObject.FromObject(new - { - lineNumber = m_line + lineOffset, - columnNumber = col, - url = m_url, - condition - }); - - res = await cli.SendCommand("Debugger.setBreakpointByUrl", bp1_req, token); - Assert.True(res.IsOk); - return res; - } - - internal async Task EvaluateOnCallFrameAndCheck(string call_frame_id, params (string expression, JObject expected)[] args) - { - foreach (var arg in args) - { - var (eval_val, _) = await EvaluateOnCallFrame(call_frame_id, arg.expression).ConfigureAwait(false); - try - { - await CheckValue(eval_val, arg.expected, arg.expression); - } - catch - { - _testOutput.WriteLine($"CheckValue failed for {arg.expression}. Expected: {arg.expected}, vs {eval_val}"); - throw; - } - } - } - - protected async Task EvaluateOnCallFrameFail(string call_frame_id, params (string expression, string class_name)[] args) - { - foreach (var arg in args) - { - var (_, res) = await EvaluateOnCallFrame(call_frame_id, arg.expression, expect_ok: false); - if (arg.class_name != null) - AssertEqual(arg.class_name, res.Error["result"]?["className"]?.Value(), $"Error className did not match for expression '{arg.expression}'"); - } - } - - - internal void AssertEqual(object expected, object actual, string label) - { - if (expected?.Equals(actual) == true) - return; - - throw EqualException.ForMismatchedValues( - expected, actual, - $"[{label}]\n"); - } - - internal void AssertStartsWith(string expected, string actual, string label) => Assert.True(actual?.StartsWith(expected), $"[{label}] Does not start with the expected string\nExpected: {expected}\nActual: {actual}"); - - internal static Func TSimpleClass = (X, Y, Id, Color) => new - { - X = TNumber(X), - Y = TNumber(Y), - Id = TString(Id), - Color = TEnum("DebuggerTests.RGB", Color), - PointWithCustomGetter = TGetter("PointWithCustomGetter") - }; - - internal static Func TPoint = (X, Y, Id, Color) => new - { - X = TNumber(X), - Y = TNumber(Y), - Id = TString(Id), - Color = TEnum("DebuggerTests.RGB", Color), - }; - - //FIXME: um maybe we don't need to convert jobject right here! - internal static JObject TString(string value) => - value == null ? - JObject.FromObject(new { type = "object", className = "string", subtype = "null" }) : - JObject.FromObject(new { type = "string", value = @value }); - - internal static JObject TNumber(int value) => - JObject.FromObject(new { type = "number", value = @value.ToString(), description = value.ToString() }); - - internal static JObject TNumber(uint value) => - JObject.FromObject(new { type = "number", value = @value.ToString(), description = value.ToString() }); - - // If is decimal, skip description due to culture-specific separators. - // They depend on user's settings and we are not able to detect them here - internal static JObject TNumber(string value, bool isDecimal = false) => - isDecimal ? - JObject.FromObject(new { type = "number", value = @value.ToString() }) : - JObject.FromObject(new { type = "number", value = @value.ToString(), description = double.Parse(value, System.Globalization.CultureInfo.InvariantCulture).ToString() }); - - internal static JObject TValueType(string className, string description = null, object members = null) => - JObject.FromObject(new { type = "object", isValueType = true, className = className, description = description ?? className }); - - internal static JObject TEnum(string className, string descr, object members = null) => - JObject.FromObject(new { type = "object", isEnum = true, className = className, description = descr }); - - internal static JObject TObject(string className, string description = null, bool is_null = false) => - is_null ? - JObject.FromObject(new { type = "object", className = className, description = description ?? className, subtype = is_null ? "null" : null }) : - JObject.FromObject(new { type = "object", className = className, description = description ?? className }); - - internal static JObject TArray(string className, string description) => JObject.FromObject(new { type = "object", className, description, subtype = "array" }); - - internal static JObject TBool(bool value) => JObject.FromObject(new { type = "boolean", value = @value, description = @value ? "true" : "false" }); - - internal static JObject TSymbol(string value) => JObject.FromObject(new { type = "symbol", value = @value, description = @value }); - - internal static JObject TChar(char value) => JObject.FromObject(new { type = "symbol", value = @value, description = $"{(int)value} '{@value}'" }); - - /* - For target names with generated method names like - `void b__11_0 (Math.GenericStruct)` - - .. pass target "as `target: "void |(Math.GenericStruct)"` - */ - internal static JObject TDelegate(string className, string target) => JObject.FromObject(new - { - __custom_type = "delegate", - className = className, - target = target - }); - - internal static JObject TPointer(string type_name, bool is_null = false) => JObject.FromObject(new { __custom_type = "pointer", type_name = type_name, is_null = is_null, is_void = type_name.StartsWith("void*") }); - - internal static JObject TIgnore() => JObject.FromObject(new { __custom_type = "ignore_me" }); - - internal static JObject TGetter(string type, JObject value = null) => JObject.FromObject(new { __custom_type = "getter", type_name = type, value = value}); - - internal static JObject TDateTime(DateTime dt) => JObject.FromObject(new - { - __custom_type = "datetime", - binary = dt.ToBinary() - }); - - internal async Task LoadAssemblyDynamically(string asm_file, string pdb_file) - { - // Simulate loading an assembly into the framework - byte[] bytes = File.ReadAllBytes(asm_file); - string asm_base64 = Convert.ToBase64String(bytes); - - string pdb_base64 = null; - if (pdb_file != null) - { - bytes = File.ReadAllBytes(pdb_file); - pdb_base64 = Convert.ToBase64String(bytes); - } - - var load_assemblies = JObject.FromObject(new - { - expression = $"{{ let asm_b64 = '{asm_base64}'; let pdb_b64 = '{pdb_base64}'; invoke_static_method('[debugger-test] LoadDebuggerTest:LoadLazyAssembly', asm_b64, pdb_b64); }}" - }); - - Result load_assemblies_res = await cli.SendCommand("Runtime.evaluate", load_assemblies, token); - load_assemblies_res.AssertOk(); - } - - internal async Task LoadAssemblyDynamicallyALCAndRunMethod(string asm_file, string pdb_file, string type_name, string method_name) - { - // Simulate loading an assembly into the framework - byte[] bytes = File.ReadAllBytes(asm_file); - string asm_base64 = Convert.ToBase64String(bytes); - - string pdb_base64 = null; - if (pdb_file != null) - { - bytes = File.ReadAllBytes(pdb_file); - pdb_base64 = Convert.ToBase64String(bytes); - } - - Task bpResolved = WaitForBreakpointResolvedEvent(); - var load_assemblies = JObject.FromObject(new - { - expression = $"{{ let asm_b64 = '{asm_base64}'; let pdb_b64 = '{pdb_base64}'; invoke_static_method('[debugger-test] LoadDebuggerTestALC:LoadLazyAssemblyInALC', asm_b64, pdb_b64); }}" - }); - - Result load_assemblies_res = await cli.SendCommand("Runtime.evaluate", load_assemblies, token); - load_assemblies_res.AssertOk(); - await bpResolved; - - var run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] LoadDebuggerTestALC:RunMethodInALC', '" + type_name + "', '" + method_name + "'); }, 1);" - }); - - await cli.SendCommand("Runtime.evaluate", run_method, token); - return await WaitFor(Inspector.PAUSE); - } - - internal async Task LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges(string asm_file, string pdb_file, string class_name, string method_name, bool expectBpResolvedEvent, params string[] sourcesToWait) - { - byte[] bytes = File.ReadAllBytes(asm_file); - string asm_base64 = Convert.ToBase64String(bytes); - bytes = File.ReadAllBytes(pdb_file); - string pdb_base64 = Convert.ToBase64String(bytes); - - string expression = $"let asm_b64 = '{asm_base64}'; let pdb_b64 = '{pdb_base64}';"; - expression = $"{{ {expression} invoke_static_method('[debugger-test] TestHotReloadUsingSDB:LoadLazyHotReload', asm_b64, pdb_b64); }}"; - var load_assemblies = JObject.FromObject(new - { - expression - }); - - Task eventTask = expectBpResolvedEvent - ? WaitForBreakpointResolvedEvent() - : WaitForScriptParsedEventsAsync(sourcesToWait); - (await cli.SendCommand("Runtime.evaluate", load_assemblies, token)).AssertOk(); - await eventTask; - - var run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] TestHotReloadUsingSDB:RunMethod', '" + class_name + "', '" + method_name + "'); }, 1);" - }); - - (await cli.SendCommand("Runtime.evaluate", run_method, token)).AssertOk(); - return await WaitFor(Inspector.PAUSE); - } - - internal async Task LoadAssemblyAndTestHotReloadUsingSDB(string asm_file_hot_reload, string class_name, string method_name, int id, Func rebindBreakpoint = null, bool rebindBeforeUpdates = false) - { - await cli.SendCommand("Debugger.resume", null, token); - var bytes = File.ReadAllBytes($"{asm_file_hot_reload}.{id}.dmeta"); - string dmeta1 = Convert.ToBase64String(bytes); - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.{id}.dil"); - string dil1 = Convert.ToBase64String(bytes); - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.{id}.dpdb"); - string dpdb1 = Convert.ToBase64String(bytes); - - var run_method = JObject.FromObject(new - { - expression = "invoke_static_method('[debugger-test] TestHotReloadUsingSDB:GetModuleGUID');" - }); - - var moduleGUID_res = await cli.SendCommand("Runtime.evaluate", run_method, token); - - Assert.True(moduleGUID_res.IsOk); - var moduleGUID = moduleGUID_res.Value["result"]["value"]; - - var applyUpdates = JObject.FromObject(new - { - moduleGUID, - dmeta = dmeta1, - dil = dil1, - dpdb = dpdb1 - }); - - if (rebindBreakpoint != null && rebindBeforeUpdates) - await rebindBreakpoint(); - - await cli.SendCommand("DotnetDebugger.applyUpdates", applyUpdates, token); - - if (rebindBreakpoint != null && !rebindBeforeUpdates) - await rebindBreakpoint(); - - run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] TestHotReloadUsingSDB:RunMethod', '" + class_name + "', '" + method_name + "'); }, 1);" - }); - await cli.SendCommand("Runtime.evaluate", run_method, token); - return await WaitFor(Inspector.PAUSE); - } - - internal async Task LoadAssemblyAndTestHotReload(string asm_file, string pdb_file, string asm_file_hot_reload, string class_name, string method_name, bool expectBpResolvedEvent, string[] sourcesToWait, string methodName2 = "", string methodName3 = "") - { - byte[] bytes = File.ReadAllBytes(asm_file); - string asm_base64 = Convert.ToBase64String(bytes); - bytes = File.ReadAllBytes(pdb_file); - string pdb_base64 = Convert.ToBase64String(bytes); - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.1.dmeta"); - string dmeta1 = Convert.ToBase64String(bytes); - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.1.dil"); - string dil1 = Convert.ToBase64String(bytes); - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.1.dpdb"); - string dpdb1 = Convert.ToBase64String(bytes); - - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.2.dmeta"); - string dmeta2 = Convert.ToBase64String(bytes); - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.2.dil"); - string dil2 = Convert.ToBase64String(bytes); - - bytes = File.ReadAllBytes($"{asm_file_hot_reload}.2.dpdb"); - string dpdb2 = Convert.ToBase64String(bytes); - - string expression = $"let asm_b64 = '{asm_base64}'; let pdb_b64 = '{pdb_base64}';"; - expression = $"{expression} let dmeta1 = '{dmeta1}'; let dil1 = '{dil1}'; let dpdb1 = '{dpdb1}';"; - expression = $"{expression} let dmeta2 = '{dmeta2}'; let dil2 = '{dil2}'; let dpdb2 = '{dpdb2}';"; - expression = $"{{ {expression} invoke_static_method('[debugger-test] TestHotReload:LoadLazyHotReload', asm_b64, pdb_b64, dmeta1, dil1, dpdb1, dmeta2, dil2, dpdb2); }}"; - var load_assemblies = JObject.FromObject(new - { - expression - }); - - Task eventTask = expectBpResolvedEvent - ? WaitForBreakpointResolvedEvent() - : WaitForScriptParsedEventsAsync(sourcesToWait); - (await cli.SendCommand("Runtime.evaluate", load_assemblies, token)).AssertOk(); - await eventTask; - - if (methodName2 == "") - methodName2 = method_name; - if (methodName3 == "") - methodName3 = method_name; - - var run_method = JObject.FromObject(new - { - expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] TestHotReload:RunMethod', '" + class_name + "', '" + method_name + "', '" + methodName2 + "', '" + methodName3 + "'); }, 1);" - }); - - await cli.SendCommand("Runtime.evaluate", run_method, token); - return await WaitFor(Inspector.PAUSE); - } - - public Task WaitForBreakpointResolvedEvent() => WaitForEventAsync("Debugger.breakpointResolved"); - - public async Task WaitForEventAsync(string eventName) - { - try - { - return await insp.WaitForEvent(eventName); - } - catch (TaskCanceledException) - { - throw new XunitException($"Timed out waiting for {eventName} event"); - } - } - - internal virtual async Task SetJustMyCode(bool enabled) - { - var req = JObject.FromObject(new { JustMyCodeStepping = enabled }); - var res = await cli.SendCommand("DotnetDebugger.setDebuggerProperty", req, token); - Assert.True(res.IsOk); - Assert.Equal(res.Value["justMyCodeEnabled"], enabled); - } - - internal async Task SetSymbolOptions(JObject param) - { - var res = await cli.SendCommand("DotnetDebugger.setSymbolOptions", param, token); - Assert.True(res.IsOk); - } - - internal async Task CheckEvaluateFail(string id, params (string expression, string message)[] args) - { - foreach (var arg in args) - { - (_, Result _res) = await EvaluateOnCallFrame(id, arg.expression, expect_ok: false).ConfigureAwait(false); - // different response structure for Chrome and Firefox: - string errorMessage = _res.Error["preview"] == null ? _res.Error["result"]?["description"]?.Value() : _res.Error["preview"]?["message"]?.Value(); - AssertEqual(arg.message, errorMessage, $"Expression '{arg.expression}' - wrong error message"); - } - } - } - - class DotnetObjectId - { - public string Scheme { get; } - public string Value { get; } - - JObject value_json; - public JObject ValueAsJson - { - get - { - if (value_json == null) - { - try - { - value_json = JObject.Parse(Value); - } - catch (JsonReaderException) { } - } - - return value_json; - } - } - - public static bool TryParse(JToken jToken, out DotnetObjectId objectId) => TryParse(jToken?.Value(), out objectId); - - public static bool TryParse(string id, out DotnetObjectId objectId) - { - objectId = null; - if (id == null) - { - return false; - } - - if (!id.StartsWith("dotnet:")) - { - return false; - } - - var parts = id.Split(":", 3); - - if (parts.Length < 3) - { - return false; - } - - objectId = new DotnetObjectId(parts[1], parts[2]); - - return true; - } - - public DotnetObjectId(string scheme, string value) - { - Scheme = scheme; - Value = value; - } - - public override string ToString() => $"dotnet:{Scheme}:{Value}"; - } - - enum StepKind - { - Into, - Over, - Out, - Resume - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestFirefox.cs b/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestFirefox.cs deleted file mode 100644 index 672002077f624f..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestFirefox.cs +++ /dev/null @@ -1,492 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests; - -public class DebuggerTestFirefox : DebuggerTestBase -{ - private new TimeSpan TestTimeout => base.TestTimeout * 5; - internal FirefoxInspectorClient _client; - public DebuggerTestFirefox(ITestOutputHelper testOutput, string driver = "debugger-driver.html", string locale = "en-US") - : base(testOutput, driver, locale) - { - if (insp.Client is not FirefoxInspectorClient) - throw new Exception($"Bug: client should be {nameof(FirefoxInspectorClient)} for use with {nameof(DebuggerTestFirefox)}"); - - _client = (FirefoxInspectorClient)insp.Client; - } - - public override async Task InitializeAsync() - { - Func)>> fn = (client, token) => - { - Func)> getInitCmdFn = (cmd, args) => (cmd, client.SendCommand(cmd, args, token)); - var init_cmds = new List<(string, Task)> - { - getInitCmdFn("listTabs", JObject.FromObject(new { type = "listTabs", to = "root"})) - }; - - return init_cmds; - }; - - await Ready(); - await insp.OpenSessionAsync(fn, "", TestTimeout); - } - - internal override Dictionary SubscribeToScripts(Inspector insp) - { - dicScriptsIdToUrl = new Dictionary(); - dicFileToUrl = new Dictionary(); - insp.On("newSource", async (args, c) => - { - var script_id = args?["source"]?["actor"].Value(); - var url = args?["source"]?["sourceMapBaseURL"]?.Value(); - /*_testOutput.WriteLine(script_id); - _testOutput.WriteLine(args);*/ - if (script_id.StartsWith("dotnet://")) - { - var dbgUrl = args?["source"]?["dotNetUrl"]?.Value(); - var arrStr = dbgUrl.Split("/"); - dbgUrl = arrStr[0] + "/" + arrStr[1] + "/" + arrStr[2] + "/" + arrStr[arrStr.Length - 1]; - dicScriptsIdToUrl[script_id] = dbgUrl; - dicFileToUrl[dbgUrl] = args?["source"]?["url"]?.Value(); - } - else if (!String.IsNullOrEmpty(url)) - { - var dbgUrl = args?["source"]?["sourceMapBaseURL"]?.Value(); - var arrStr = dbgUrl.Split("/"); - dicScriptsIdToUrl[script_id] = arrStr[arrStr.Length - 1]; - dicFileToUrl[new Uri(url).AbsolutePath] = url; - } - return await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - }); - insp.On("resource-available-form", async (args, c) => - { - var script_id = args?["resources"]?[0]?["actor"].Value(); - var url = args?["resources"]?[0]?["url"]?.Value(); - if (script_id.StartsWith("dotnet://")) - { - var dbgUrl = args?["resources"]?[0]?["dotNetUrl"]?.Value(); - var arrStr = dbgUrl.Split("/"); - dbgUrl = arrStr[0] + "/" + arrStr[1] + "/" + arrStr[2] + "/" + arrStr[arrStr.Length - 1]; - dicScriptsIdToUrl[script_id] = dbgUrl; - dicFileToUrl[dbgUrl] = args?["resources"]?[0]?["url"]?.Value(); - } - else if (!String.IsNullOrEmpty(url)) - { - var dbgUrl = args?["resources"]?[0]?["url"]?.Value(); - var arrStr = dbgUrl.Split("/"); - dicScriptsIdToUrl[script_id] = arrStr[arrStr.Length - 1]; - dicFileToUrl[new Uri(url).AbsolutePath] = url; - } - return await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - }); - return dicScriptsIdToUrl; - } - - internal override async Task SetBreakpoint(string url_key, int line, int column, bool expect_ok = true, bool use_regex = false, string condition = "") - { - var bp1_req = JObject.FromObject(new { - type = "setBreakpoint", - location = JObject.FromObject(new { - line = line + 1, - column, - sourceUrl = dicFileToUrl[url_key] - }), - to = _client.BreakpointActorId - }); - - var bp1_res = await cli.SendCommand("setBreakpoint", bp1_req, token); - Assert.True(expect_ok == bp1_res.IsOk); - return bp1_res; - } - internal override async Task EvaluateAndCheck( - string expression, string script_loc, int line, int column, string function_name, - Func wait_for_event_fn = null, Func locals_fn = null) - { - return await SendCommandAndCheck( - CreateEvaluateArgs(expression), - "evaluateJSAsync", script_loc, line, column, function_name, - wait_for_event_fn: wait_for_event_fn, - locals_fn: locals_fn); - } - - internal override void CheckLocation(string script_loc, int line, int column, Dictionary scripts, JToken location) - { - if (location == null) //probably trying to check startLocation endLocation or functionLocation which are not available on Firefox - return; - int column_from_stack = -1; - if (column != -1) - column_from_stack = location["columnNumber"].Value(); - - var loc_str = $"{ scripts[location["scriptId"].Value()] }" + - $"#{ location["lineNumber"].Value()}" + - $"#{ column_from_stack }"; - - var expected_loc_str = $"{script_loc}#{line+1}#{column}"; - Assert.Equal(expected_loc_str, loc_str); - } - - internal override void CheckLocationLine(JToken location, int line) - { - if (location == null) //probably trying to check startLocation endLocation or functionLocation which are not available on Firefox - return; - Assert.Equal(location["lineNumber"].Value(), line+1); - } - - private JObject ConvertFirefoxToDefaultFormat(JArray frames, JObject wait_res) - { - var callFrames = new JArray(); - foreach (var frame in frames) - { - var callFrame = JObject.FromObject(new - { - functionName = frame["displayName"].Value(), - callFrameId = frame["actor"].Value(), - //functionLocation = 0, - location = JObject.FromObject(new - { - scriptId = frame["where"]["actor"].Value(), - lineNumber = frame["where"]["line"].Value(), - columnNumber = frame["where"]["column"].Value() - }), - url = scripts[frame["where"]["actor"].Value()], - scopeChain = new JArray(JObject.FromObject(new - { - type = "local", - name = frame["displayName"].Value(), - @object = JObject.FromObject(new - { - type = "object", - className = "Object", - description = "Object", - objectId = frame["actor"].Value() - }) - })) - }); - callFrames.Add(callFrame); - } - return JObject.FromObject(new - { - callFrames, - reason = "other" - }); - } - - internal override Task SetJustMyCode(bool enabled) => Task.CompletedTask; - - internal override async Task SendCommandAndCheck(JObject args, string method, string script_loc, int line, int column, string function_name, - Func wait_for_event_fn = null, Func locals_fn = null, string waitForEvent = Inspector.PAUSE) - { - switch (method) - { - case "Debugger.resume": - return await StepAndCheck(StepKind.Resume, script_loc, line, column, function_name, wait_for_event_fn, locals_fn); - case "Debugger.stepInto": - return await StepAndCheck(StepKind.Into, script_loc, line, column, function_name, wait_for_event_fn, locals_fn); - } - var res = await cli.SendCommand(method, args, token); - if (!res.IsOk) - { - _testOutput.WriteLine($"Failed to run command {method} with args: {args?.ToString()}\nresult: {res.Error.ToString()}"); - Assert.True(false, $"SendCommand for {method} failed with {res.Error.ToString()}"); - } - var wait_res = await WaitFor(waitForEvent); - if (function_name != null) - { - AssertEqual(function_name, wait_res["callFrames"]?[0]?["functionName"]?.Value(), wait_res["callFrames"]?[0]?["functionName"]?.ToString()); - } - - if (script_loc != null && line >= 0) - CheckLocation(script_loc, line, column, scripts, wait_res["callFrames"]?[0]?["location"]); - - if (wait_for_event_fn != null) - { - await wait_for_event_fn(wait_res); - } - - if (locals_fn != null) - { - var locals = await GetProperties(wait_res["callFrames"][0]["callFrameId"].Value()); - try - { - await locals_fn(locals); - } - catch (System.AggregateException ex) - { - throw new AggregateException(ex.Message + " \n" + locals.ToString(), ex); - } - } - - return wait_res; - } - - internal JObject ConvertFromFirefoxToDefaultFormat(KeyValuePair variable) - { - string name = variable.Key; - JToken value = variable.Value; - JObject variableValue = null; - string valueType = "value"; - if (value?["type"] == null || value["type"].Value() == "object" || value["type"].Value() == "string") - { - var actor = value["value"]?["actor"]?.Value(); - string type = value["value"]?["type"]?.Value(); - switch (type) - { - case "null": - variableValue = JObject.FromObject(new - { - type = "object", - subtype = "null", - className = value["value"]["class"].Value(), - description = value["value"]["class"].Value() - }); - if (actor != null && actor.StartsWith("dotnet:pointer:")) - variableValue["type"] = "symbol"; - break; - case "function": - variableValue = JObject.FromObject(new - { - type = type, - objectId = value["value"]["actor"].Value(), - className = "Function", - description = $"get {name} ()" - }); - valueType = "get"; - break; - case "string": - variableValue = JObject.FromObject(new - { - type = type, - objectId = value["value"]["actor"]?.Value(), - value = value["value"]["value"]?.Value(), - description = value["value"]["value"].Value() - }); - break; - default: - variableValue = JObject.FromObject(new - { - type = type, - value = (string)null, - description = value["value"]?["value"]?.Value() == null ? value["value"]["class"].Value() : value["value"]?["value"]?.Value(), - className = value["value"]["class"].Value(), - objectId = actor, - }); - if (actor.StartsWith("dotnet:valuetype:")) - variableValue["isValueType"] = true; - if (actor.StartsWith("dotnet:array:")) - variableValue["subtype"] = "array"; - if (actor.StartsWith("dotnet:pointer:")) - variableValue["type"] = "object"; - if (actor.StartsWith("dotnet:pointer:-1")) - { - variableValue["type"] = "symbol"; - variableValue["value"] = value["value"]?["value"]?.Value(); - } - break; - } - } - else - { - var description = value["value"].ToString(); - if (value["type"].Value() == "boolean") - description = description.ToLower(); - variableValue = JObject.FromObject(new - { - type = value["type"], - value = value["value"], - description - }); - } - var ret = JObject.FromObject(new - { - name, - writable = value["writable"] != null ? value["writable"] : false - }); - ret[valueType] = variableValue; - return ret; - } - - /* @fn_args is for use with `Runtime.callFunctionOn` only */ - internal override async Task GetProperties(string id, JToken fn_args = null, bool? own_properties = null, bool? accessors_only = null, bool expect_ok = true) - { - if (id.StartsWith("dotnet:scope:")) - { - JArray ret = new (); - var o = JObject.FromObject(new - { - to = id, - type = "getEnvironment" - }); - var frame_props = await cli.SendCommand("getEnvironment", o, token); - foreach (var variable in frame_props.Value["result"]["value"]["bindings"]["variables"].Value()) - { - var varToAdd = ConvertFromFirefoxToDefaultFormat(variable); - ret.Add(varToAdd); - } - return ret; - } - if (id.StartsWith("dotnet:evaluationResult:") || id.StartsWith("dotnet:valuetype:") || id.StartsWith("dotnet:object:") || id.StartsWith("dotnet:array:") || id.StartsWith("dotnet:pointer:")) - { - JArray ret = new (); - var o = JObject.FromObject(new - { - to = id, - type = "enumProperties" - }); - var propertyIterator = await cli.SendCommand("enumProperties", o, token); - o = JObject.FromObject(new - { - to = propertyIterator.Value["result"]["value"]?["iterator"]?["actor"].Value().Replace("propertyIterator", ""), - type = "prototypeAndProperties" - }); - var objProps = await cli.SendCommand("prototypeAndProperties", o, token); - foreach (var prop in objProps.Value["result"]["value"]["ownProperties"].Value()) - { - var varToAdd = ConvertFromFirefoxToDefaultFormat(prop); - ret.Add(varToAdd); - } - return ret; - } - return null; - } - - internal override async Task StepAndCheck(StepKind kind, string script_loc, int line, int column, string function_name, - Func wait_for_event_fn = null, Func locals_fn = null, int times = 1) - { - JObject resumeLimit = null; - - if (kind != StepKind.Resume) - { - resumeLimit = JObject.FromObject(new - { - type = kind == StepKind.Over ? "next" : kind == StepKind.Out ? "finish" : "step" - }); - } - var o = JObject.FromObject(new - { - to = _client.ThreadActorId, - type = "resume", - resumeLimit - }); - - for (int i = 0; i < times - 1; i++) - { - await SendCommandAndCheck(o, "resume", null, -1, -1, null); - } - - // Check for method/line etc only at the last step - return await SendCommandAndCheck( - o, "resume", script_loc, line, column, function_name, - wait_for_event_fn: wait_for_event_fn, - locals_fn: locals_fn); - } - - internal override async Task SetBreakpointInMethod(string assembly, string type, string method, int lineOffset = 0, int col = 0, string condition = "") - { - var req = JObject.FromObject(new { assemblyName = assembly, type = "DotnetDebugger.getMethodLocation", typeName = type, methodName = method, lineOffset = lineOffset, to = "internal" }); - - // Protocol extension - var res = await cli.SendCommand("DotnetDebugger.getMethodLocation", req, token); - Assert.True(res.IsOk); - var m_url = res.Value["result"]["value"]["url"].Value(); - var m_line = res.Value["result"]["value"]["line"].Value(); - var m_column = res.Value["result"]["value"]["column"].Value(); - - - var bp1_req = JObject.FromObject(new { - type = "setBreakpoint", - location = JObject.FromObject(new { - line = m_line + lineOffset + 1, - column = col, - sourceUrl = m_url - }), - to = _client.BreakpointActorId - }); - - if (condition != "") - bp1_req["options"] = JObject.FromObject(new { condition }); - - var bp1_res = await cli.SendCommand("setBreakpoint", bp1_req, token); - Assert.True(bp1_res.IsOk); - - var arr = new JArray(JObject.FromObject(new { - lineNumber = m_line + lineOffset, - columnNumber = -1 - })); - - bp1_res.Value["locations"] = arr; - return bp1_res; - } - - internal override async Task<(JToken, Result)> EvaluateOnCallFrame(string id, string expression, bool expect_ok = true) - { - var o = CreateEvaluateArgs(expression); - var res = await cli.SendCommand("evaluateJSAsync", o, token); - if (res.IsOk) - { - if (res.Value["result"]["value"] is JObject) - { - var actor = res.Value["result"]["value"]["actor"].Value(); - var resObj = JObject.FromObject(new - { - type = res.Value["result"]["value"]["type"], - className = res.Value["result"]["value"]["class"], - description = res.Value["result"]["value"]["description"], - objectId = actor - }); - if (actor?.StartsWith("dotnet:valuetype:") == true) - resObj["isValueType"] = true; - return (resObj, res); - } - return (res.Value["result"], res); - } - - return (null, res); - } - - internal override bool SkipProperty(string propertyName) => propertyName == "isEnum"; - - internal override async Task CheckDateTimeGetter(JToken value, DateTime expected, string label = "") => await Task.CompletedTask; - - internal override string EvaluateCommand() => "evaluateJSAsync"; - - internal override JObject CreateEvaluateArgs(string expression) - { - if (string.IsNullOrEmpty(_client.ConsoleActorId)) - throw new Exception($"Cannot create evaluate request because consoleActorId is '{_client.ConsoleActorId}"); - return JObject.FromObject(new - { - to = _client.ConsoleActorId, - type = "evaluateJSAsync", - text = expression, - options = new { eager = true, mapped = new { @await = true } } - }); - } - - internal override async Task WaitFor(string what) - { - var wait_res = await insp.WaitFor(what); - var frames = await cli.SendCommand("frames", JObject.FromObject(new - { - to = wait_res["from"].Value(), - type = "frames", - start = 0, - count = 1000 - }), token); - - if (frames.Value["result"]?["value"]?["frames"] is not JArray frames_arr) - throw new Exception($"Tried to get frames after waiting for '{what}', but got unexpected result: {frames}"); - - return ConvertFirefoxToDefaultFormat(frames_arr, wait_res); - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj b/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj deleted file mode 100644 index 7283603a955e1c..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj +++ /dev/null @@ -1,153 +0,0 @@ - - - $(AspNetCoreAppCurrent) - true - true - false - chrome - $(DefineConstants);RUN_IN_CHROME - $(DefineConstants);RELEASE_RUNTIME - windows - - <_ProvisionBrowser Condition="'$(ContinuousIntegrationBuild)' == 'true' or Exists('/.dockerenv')">true - true - true - - - $(OutputPath).runsettings - $(ArtifactsObjDir)vscode\.runsettings - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_FilesToCopy Include="$(OutputPath)\**\*" TargetPath="DebuggerTestSuite" /> - <_FilesToCopy Include="$(ArtifactsBinDir)debugger-test\Debug\**\*" TargetPath="debugger-test" /> - - - - - - - - - - - - - <_Regex>^ *(DebuggerTests[^\($]+) - - - <_TestLines0 Include="$([System.Text.RegularExpressions.Regex]::Match('%(_ListOfTestsLines.Identity)', '$(_Regex)'))" /> - - - - - - - - - - - - - $(DotNetTool) - $([System.IO.Path]::Combine($(DotNetRoot), $(DotNetTool))) - - <_RunSettingsInputFilePath>$(RepositoryEngineeringDir)testing\.runsettings - $([System.IO.File]::ReadAllText('$(_RunSettingsInputFilePath)')) - $(RunSettingsFileContent.Replace('$$MAXCPUCOUNT$$', '1')) - $(RunSettingsFileContent.Replace('$$MAXCPUCOUNT$$', '0')) - $(RunSettingsFileContent.Replace('$$TARGETPLATFORM$$', '')) - $(RunSettingsFileContent.Replace('$$COVERAGE_INCLUDE$$', '$(CoverageIncludeFilter)') - .Replace('$$COVERAGE_EXCLUDEBYFILE$$', '$(CoverageExcludeByFileFilter)') - .Replace('$$COVERAGE_INCLUDEDIRECTORY$$', '$(CoverageIncludeDirectoryFilter)') - .Replace('$$COVERAGE_ENABLED$$', '$([MSBuild]::ValueOrDefault('$(Coverage)', 'false'))') - .Replace('$$DISABLEPARALLELIZATION$$', '$([MSBuild]::ValueOrDefault('$(TestDisableParallelization)', 'false'))') - .Replace('$$DISABLEAPPDOMAIN$$', '$([MSBuild]::ValueOrDefault('$(TestDisableAppDomain)', 'false'))') - .Replace('$$TESTCASEFILTER$$', '$(_testFilter)') - .Replace('$$DOTNETHOSTPATH$$', '$(DotNetForTests)')) - - - - - - - - - namespace DebuggerTests - { - public class CheckColonInSourceName - { - public static void Evaluate() - { - var a = 123%3B - } - } - } - - - - - - diff --git a/src/mono/browser/debugger/DebuggerTestSuite/DelegateTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/DelegateTests.cs deleted file mode 100644 index a59d7c4a0420b7..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/DelegateTests.cs +++ /dev/null @@ -1,308 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class DelegateTests : DebuggerTests - { - public DelegateTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(0, 53, 8, "Math.DelegatesTest", false)] - [InlineData(0, 53, 8, "Math.DelegatesTest", true)] - [InlineData(2, 99, 8, "Math.InnerMethod2", false)] - [InlineData(2, 99, 8, "Math.InnerMethod2", true)] - public async Task InspectLocalsWithDelegatesAtBreakpointSite(int frame, int line, int col, string method_name, bool use_cfo) => - await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", line, col, method_name, - "window.setTimeout(function() { invoke_delegates_test (); }, 1);", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][frame]["callFrameId"].Value()); - - await CheckProps(locals, new - { - fn_func = TDelegate("System.Func", "bool |(Math)"), - fn_func_null = TObject("System.Func", is_null: true), - fn_func_arr = TArray("System.Func[]", "System.Func[1]"), - fn_del = TDelegate("Math.IsMathNull", "bool IsMathNullDelegateTarget (Math)"), - fn_del_null = TObject("Math.IsMathNull", is_null: true), - fn_del_arr = TArray("Math.IsMathNull[]", "Math.IsMathNull[1]"), - - // Unused locals - fn_func_unused = TDelegate("System.Func", "bool |(Math)"), - fn_func_null_unused = TObject("System.Func", is_null: true), - fn_func_arr_unused = TArray("System.Func[]", "System.Func[1]"), - - fn_del_unused = TDelegate("Math.IsMathNull", "bool IsMathNullDelegateTarget (Math)"), - fn_del_null_unused = TObject("Math.IsMathNull", is_null: true), - fn_del_arr_unused = TArray("Math.IsMathNull[]", "Math.IsMathNull[1]"), - - res = TBool(false), - m_obj = TObject("Math") - }, "locals"); - - await CompareObjectPropertiesFor(locals, "fn_func_arr", new[] - { - TDelegate( - "System.Func", - "bool |(Math)") - }, "locals#fn_func_arr"); - - await CompareObjectPropertiesFor(locals, "fn_del_arr", new[] - { - TDelegate( - "Math.IsMathNull", - "bool IsMathNullDelegateTarget (Math)") - }, "locals#fn_del_arr"); - - await CompareObjectPropertiesFor(locals, "fn_func_arr_unused", new[] - { - TDelegate( - "System.Func", - "bool |(Math)") - }, "locals#fn_func_arr_unused"); - - await CompareObjectPropertiesFor(locals, "fn_del_arr_unused", new[] - { - TDelegate( - "Math.IsMathNull", - "bool IsMathNullDelegateTarget (Math)") - }, "locals#fn_del_arr_unused"); - } - ); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(0, 202, 8, "Math.DelegatesSignatureTest", false)] - [InlineData(0, 202, 8, "Math.DelegatesSignatureTest", true)] - [InlineData(2, 99, 8, "Math.InnerMethod2", false)] - [InlineData(2, 99, 8, "Math.InnerMethod2", true)] - public async Task InspectDelegateSignaturesWithFunc(int frame, int line, int col, string bp_method, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", - line, col, - bp_method, - "window.setTimeout (function () { invoke_static_method ('[debugger-test] Math:DelegatesSignatureTest'); }, 1)", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][frame]["callFrameId"].Value()); - - await CheckProps(locals, new - { - fn_func = TDelegate("System.Func>, Math.GenericStruct>", - "Math.GenericStruct |(Math,Math.GenericStruct>)"), - - fn_func_del = TDelegate("System.Func>, Math.GenericStruct>", - "Math.GenericStruct DelegateTargetForSignatureTest (Math,Math.GenericStruct>)"), - - fn_func_null = TObject("System.Func>, Math.GenericStruct>", is_null: true), - fn_func_only_ret = TDelegate("System.Func", "bool |()"), - fn_func_arr = TArray("System.Func>, Math.GenericStruct>[]", "System.Func>, Math.GenericStruct>[1]"), - - fn_del = TDelegate("Math.DelegateForSignatureTest", - "Math.GenericStruct DelegateTargetForSignatureTest (Math,Math.GenericStruct>)"), - - fn_del_l = TDelegate("Math.DelegateForSignatureTest", - "Math.GenericStruct |(Math,Math.GenericStruct>)"), - - fn_del_null = TObject("Math.DelegateForSignatureTest", is_null: true), - fn_del_arr = TArray("Math.DelegateForSignatureTest[]", "Math.DelegateForSignatureTest[2]"), - m_obj = TObject("Math"), - gs_gs = TValueType("Math.GenericStruct>"), - fn_void_del = TDelegate("Math.DelegateWithVoidReturn", - "void DelegateTargetWithVoidReturn (Math.GenericStruct)"), - - fn_void_del_arr = TArray("Math.DelegateWithVoidReturn[]", "Math.DelegateWithVoidReturn[1]"), - fn_void_del_null = TObject("Math.DelegateWithVoidReturn", is_null: true), - gs = TValueType("Math.GenericStruct"), - rets = TArray("Math.GenericStruct[]", "Math.GenericStruct[6]") - }, "locals"); - - await CompareObjectPropertiesFor(locals, "fn_func_arr", new[] - { - TDelegate( - "System.Func>, Math.GenericStruct>", - "Math.GenericStruct |(Math,Math.GenericStruct>)"), - }, "locals#fn_func_arr"); - - await CompareObjectPropertiesFor(locals, "fn_del_arr", new[] - { - TDelegate( - "Math.DelegateForSignatureTest", - "Math.GenericStruct DelegateTargetForSignatureTest (Math,Math.GenericStruct>)"), - TDelegate( - "Math.DelegateForSignatureTest", - "Math.GenericStruct |(Math,Math.GenericStruct>)") - }, "locals#fn_del_arr"); - - await CompareObjectPropertiesFor(locals, "fn_void_del_arr", new[] - { - TDelegate( - "Math.DelegateWithVoidReturn", - "void DelegateTargetWithVoidReturn (Math.GenericStruct)") - }, "locals#fn_void_del_arr"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(0, 224, 8, "Math.ActionTSignatureTest", false)] - [InlineData(0, 224, 8, "Math.ActionTSignatureTest", true)] - [InlineData(2, 99, 8, "Math.InnerMethod2", false)] - [InlineData(2, 99, 8, "Math.InnerMethod2", true)] - public async Task ActionTSignatureTest(int frame, int line, int col, string bp_method, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", line, col, - bp_method, - "window.setTimeout (function () { invoke_static_method ('[debugger-test] Math:ActionTSignatureTest'); }, 1)", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][frame]["callFrameId"].Value()); - - await CheckProps(locals, new - { - fn_action = TDelegate("System.Action>", - "void |(Math.GenericStruct)"), - fn_action_del = TDelegate("System.Action>", - "void DelegateTargetWithVoidReturn (Math.GenericStruct)"), - fn_action_bare = TDelegate("System.Action", - "void|()"), - - fn_action_null = TObject("System.Action>", is_null: true), - - fn_action_arr = TArray("System.Action>[]", "System.Action>[3]"), - - gs = TValueType("Math.GenericStruct"), - }, "locals"); - - await CompareObjectPropertiesFor(locals, "fn_action_arr", new[] - { - TDelegate( - "System.Action>", - "void |(Math.GenericStruct)"), - TDelegate( - "System.Action>", - "void DelegateTargetWithVoidReturn (Math.GenericStruct)"), - TObject("System.Action>", is_null : true) - }, "locals#fn_action_arr"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(0, 242, 8, "Math.NestedDelegatesTest", false)] - [InlineData(0, 242, 8, "Math.NestedDelegatesTest", true)] - [InlineData(2, 99, 8, "Math.InnerMethod2", false)] - [InlineData(2, 99, 8, "Math.InnerMethod2", true)] - public async Task NestedDelegatesTest(int frame, int line, int col, string bp_method, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", line, col, - bp_method, - "window.setTimeout (function () { invoke_static_method ('[debugger-test] Math:NestedDelegatesTest'); }, 1)", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][frame]["callFrameId"].Value()); - - await CheckProps(locals, new - { - fn_func = TDelegate("System.Func, bool>", - "bool |(Func)"), - fn_func_null = TObject("System.Func, bool>", is_null: true), - fn_func_arr = TArray("System.Func, bool>[]", "System.Func, bool>[1]"), - fn_del_arr = TArray("System.Func, bool>[]", "System.Func, bool>[1]"), - - m_obj = TObject("Math"), - fn_del_null = TObject("System.Func, bool>", is_null: true), - fs = TDelegate("System.Func", - "bool |(int)") - }, "locals"); - - await CompareObjectPropertiesFor(locals, "fn_func_arr", new[] - { - TDelegate( - "System.Func, bool>", - "bool |(System.Func)") - }, "locals#fn_func_arr"); - - await CompareObjectPropertiesFor(locals, "fn_del_arr", new[] - { - TDelegate( - "System.Func, bool>", - "bool DelegateTargetForNestedFunc (Func)") - }, "locals#fn_del_arr"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(0, 262, 8, "Math.MethodWithDelegateArgs", false)] - [InlineData(0, 262, 8, "Math.MethodWithDelegateArgs", true)] - [InlineData(2, 99, 8, "Math.InnerMethod2", false)] - [InlineData(2, 99, 8, "Math.InnerMethod2", true)] - public async Task DelegatesAsMethodArgsTest(int frame, int line, int col, string bp_method, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", line, col, - bp_method, - "window.setTimeout (function () { invoke_static_method ('[debugger-test] Math:DelegatesAsMethodArgsTest'); }, 1)", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][frame]["callFrameId"].Value()); - - await CheckProps(locals, new - { - @this = TObject("Math"), - dst_arr = TArray("Math.DelegateForSignatureTest[]", "Math.DelegateForSignatureTest[2]"), - fn_func = TDelegate("System.Func", - "bool |(char[])"), - fn_action = TDelegate("System.Action[]>", - "void |(Math.GenericStruct[])") - }, "locals"); - - await CompareObjectPropertiesFor(locals, "dst_arr", new[] - { - TDelegate("Math.DelegateForSignatureTest", - "Math.GenericStruct DelegateTargetForSignatureTest (Math,Math.GenericStruct>)"), - TDelegate("Math.DelegateForSignatureTest", - "Math.GenericStruct |(Math,Math.GenericStruct>)"), - }, "locals#dst_arr"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task MethodWithDelegatesAsyncTest(bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", 281, 8, - "Math.MethodWithDelegatesAsync", - "window.setTimeout (function () { invoke_static_method_async ('[debugger-test] Math:MethodWithDelegatesAsyncTest'); }, 1)", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - await CheckProps(locals, new - { - @this = TObject("Math"), - _dst_arr = TArray("Math.DelegateForSignatureTest[]", "Math.DelegateForSignatureTest[2]"), - _fn_func = TDelegate("System.Func", - "bool |(char[])"), - _fn_action = TDelegate("System.Action[]>", - "void |(Math.GenericStruct[])") - }, "locals"); - - await CompareObjectPropertiesFor(locals, "_dst_arr", new[] - { - TDelegate( - "Math.DelegateForSignatureTest", - "Math.GenericStruct DelegateTargetForSignatureTest (Math,Math.GenericStruct>)"), - TDelegate( - "Math.DelegateForSignatureTest", - "Math.GenericStruct |(Math,Math.GenericStruct>)"), - }, "locals#dst_arr"); - }); - } - -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs b/src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs deleted file mode 100644 index 27633d74c49897..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/DevToolsClient.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Microsoft.WebAssembly.Diagnostics; - -namespace DebuggerTests -{ - internal class DevToolsClient : IDisposable - { - protected readonly ILogger logger; - protected RunLoop _runLoop; - - public event EventHandler RunLoopStopped; - - public DevToolsClient(ILogger logger) - { - this.logger = logger; - } - - ~DevToolsClient() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - } - - protected virtual void Dispose(bool disposing) - { - _runLoop?.Dispose(); - _runLoop = null; - } - - public Task ShutdownAsync(CancellationToken cancellationToken) - => _runLoop is null - ? Task.CompletedTask - : _runLoop.ShutdownAsync(cancellationToken); - - public void Fail(Exception exception) => _runLoop?.Fail(exception); - protected void Send(byte[] bytes, CancellationToken token) => _runLoop?.Send(bytes, token); - - protected async Task ConnectToWebServer(Uri uri, CancellationToken token) - { - // connects to the webserver to start the proxy - ClientWebSocket clientSocket = new(); - clientSocket.Options.KeepAliveInterval = Timeout.InfiniteTimeSpan; - logger.LogDebug("Client connecting to {0}", uri); - await clientSocket.ConnectAsync(uri, token); - return clientSocket; - } - - protected virtual Task SetupConnection(Uri webserverUri, CancellationToken token) - => throw new NotImplementedException(); - - protected async Task ConnectAndStartRunLoopAsync( - Uri uri, - Func receive, - CancellationTokenSource cts) - { - WasmDebuggerConnection conn = await SetupConnection(uri, cts.Token); - conn.OnReadAsync = receive; - _runLoop = new(new[] { new DevToolsQueue(conn) }, logger); - _runLoop.RunLoopStopped += (sender, args) => RunLoopStopped?.Invoke(sender, args); - _ = _runLoop.RunAsync(cts); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/Directory.Build.props b/src/mono/browser/debugger/DebuggerTestSuite/Directory.Build.props deleted file mode 100644 index 5524a1e06d7d0f..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/Directory.Build.props +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/mono/browser/debugger/DebuggerTestSuite/EnvironmentVariables.cs b/src/mono/browser/debugger/DebuggerTestSuite/EnvironmentVariables.cs deleted file mode 100644 index 05171f96cb4d59..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/EnvironmentVariables.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -#nullable enable - -namespace DebuggerTests; - -internal static class EnvironmentVariables -{ - public static readonly string? DebuggerTestPath = Environment.GetEnvironmentVariable("DEBUGGER_TEST_PATH"); - public static readonly string? TestLogPath = Environment.GetEnvironmentVariable("TEST_LOG_PATH"); - public static readonly bool SkipCleanup = GetEnvironmentVariableValue("SKIP_CLEANUP"); - public static readonly bool WasmEnableThreads = GetEnvironmentVariableValue("WasmEnableThreads"); - - private static bool GetEnvironmentVariableValue(string envVariable) - { - string? str = Environment.GetEnvironmentVariable(envVariable); - if (str is null) - return false; - - if (str == "1" || str.ToLower() == "true") - return true; - - return false; - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrame2Tests.cs b/src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrame2Tests.cs deleted file mode 100644 index 44e9f90d95380e..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrame2Tests.cs +++ /dev/null @@ -1,856 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - // TODO: static async, static method args - public class EvaluateOnCallFrame2Tests : DebuggerTests - { - public EvaluateOnCallFrame2Tests(ITestOutputHelper testOutput) : base(testOutput) - {} - - public static IEnumerable InstanceMethodsTestData(string type_name) - { - yield return new object[] { type_name, "InstanceMethod", $"{type_name}.InstanceMethod", false }; - yield return new object[] { type_name, "GenericInstanceMethod", $"{type_name}.GenericInstanceMethod", false }; - yield return new object[] { type_name, "InstanceMethodAsync", $"{type_name}.InstanceMethodAsync", true }; - yield return new object[] { type_name, "GenericInstanceMethodAsync", $"{type_name}.GenericInstanceMethodAsync", true }; - - // TODO: { "DebuggerTests.EvaluateTestsGeneric`1", "Instance", 9, "EvaluateTestsGenericStructInstanceMethod", prefix } - } - - public static IEnumerable InstanceMethodForTypeMembersTestData(string type_name) - { - foreach (var data in InstanceMethodsTestData(type_name)) - { - yield return new object[] { "", 0 }.Concat(data).ToArray(); - yield return new object[] { "this.", 0 }.Concat(data).ToArray(); - yield return new object[] { "NewInstance.", 3 }.Concat(data).ToArray(); - yield return new object[] { "this.NewInstance.", 3 }.Concat(data).ToArray(); - } - } - - [Theory] - [InlineData("DebuggerTestsV2.EvaluateStaticFieldsInStaticClass", "Run", "DebuggerTestsV2", "EvaluateStaticFieldsInStaticClass", "EvaluateMethods", 1, 2)] - [InlineData("DebuggerTests.EvaluateStaticFieldsInStaticClass", "Run", "DebuggerTests", "EvaluateStaticFieldsInStaticClass", "EvaluateMethods", 1, 1)] - [InlineData("DebuggerTests.EvaluateStaticFieldsInStaticClass", "RunAsync", "DebuggerTests", "EvaluateStaticFieldsInStaticClass", "EvaluateMethodsAsync", 1, 1)] - [InlineData("DebuggerTests.EvaluateStaticFieldsInInstanceClass", "RunStatic", "DebuggerTests", "EvaluateStaticFieldsInInstanceClass", "EvaluateMethods", 1, 7)] - [InlineData("DebuggerTests.EvaluateStaticFieldsInInstanceClass", "RunStaticAsync", "DebuggerTests", "EvaluateStaticFieldsInInstanceClass", "EvaluateMethodsAsync", 1, 7)] - [InlineData("DebuggerTests.EvaluateStaticFieldsInInstanceClass", "Run", "DebuggerTests", "EvaluateStaticFieldsInInstanceClass", "EvaluateMethods", 1, 7)] - [InlineData("DebuggerTests.EvaluateStaticFieldsInInstanceClass", "RunAsync", "DebuggerTests", "EvaluateStaticFieldsInInstanceClass", "EvaluateMethodsAsync", 1, 7)] - public async Task EvaluateStaticFields( - string bpLocation, string bpMethod, string namespaceName, string className, string triggeringMethod, int bpLine, int expectedInt) => - await CheckInspectLocalsAtBreakpointSite( - bpLocation, bpMethod, bpLine, $"{bpLocation}.{bpMethod}", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:{triggeringMethod}'); }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - foreach (var pad in new[] { String.Empty, " " }) - { - await EvaluateOnCallFrameAndCheck(id, - ($"{pad}{namespaceName}.{className}.StaticField", TNumber(expectedInt * 10)), - ($"{pad}{namespaceName}{pad}.{className}.{pad}StaticProperty", TString($"StaticProperty{expectedInt}")), - ($"{namespaceName}.{pad}{className}.StaticPropertyWithError", TString($"System.Exception: not implemented {expectedInt}")), - ($"{pad}{className}.{pad}StaticField", TNumber(expectedInt * 10)), - ($"{pad}{pad}{className}.StaticProperty", TString($"StaticProperty{expectedInt}")), - ($"{pad}{className}.StaticPropertyWithError", TString($"System.Exception: not implemented {expectedInt}")), - ($"{pad}StaticField{pad}", TNumber(expectedInt * 10)), - ($"{pad}StaticProperty", TString($"StaticProperty{expectedInt}")), - ($"{pad}StaticPropertyWithError", TString($"System.Exception: not implemented {expectedInt}")) - ); - } - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateStaticClassesNested() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateMethodTestsClass", "EvaluateMethods", 3, "DebuggerTests.EvaluateMethodTestsClass.EvaluateMethods", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - foreach (var pad in new[] { String.Empty, " " }) - { - await EvaluateOnCallFrameAndCheck(id, - ($"{pad}DebuggerTests{pad}.EvaluateStaticFieldsInStaticClass.NestedClass1.{pad}NestedClass2.NestedClass3.{pad}StaticField", TNumber(3)), - ($"{pad}DebuggerTests.EvaluateStaticFieldsInStaticClass.NestedClass1.NestedClass2.NestedClass3.StaticProperty", TString("StaticProperty3")), - ($"{pad}{pad}DebuggerTests.{pad}EvaluateStaticFieldsInStaticClass.NestedClass1.NestedClass2.NestedClass3.{pad}StaticPropertyWithError", TString("System.Exception: not implemented 3")), - ($"EvaluateStaticFieldsInStaticClass.{pad}NestedClass1.{pad}NestedClass2.NestedClass3.StaticField", TNumber(3)), - ($"EvaluateStaticFieldsInStaticClass.NestedClass1.{pad}{pad}NestedClass2.NestedClass3.{pad}StaticProperty", TString("StaticProperty3")), - ($"{pad}EvaluateStaticFieldsInStaticClass.NestedClass1.{pad}NestedClass2.{pad}NestedClass3.StaticPropertyWithError", TString("System.Exception: not implemented 3"))); - } - }); - - [Fact] - public async Task EvaluateStaticClassesNestedWithNoNamespace() => await CheckInspectLocalsAtBreakpointSite( - "NoNamespaceClass", "EvaluateMethods", 1, "NoNamespaceClass.EvaluateMethods", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] NoNamespaceClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - foreach (var pad in new[] { String.Empty, " " }) - { - await EvaluateOnCallFrameAndCheck(id, - ($"{pad}NoNamespaceClass.NestedClass1.NestedClass2.{pad}NestedClass3.StaticField", TNumber(30)), - ($"NoNamespaceClass.NestedClass1.{pad}NestedClass2.NestedClass3.StaticProperty", TString("StaticProperty30")), - ($"NoNamespaceClass.{pad}NestedClass1.NestedClass2.NestedClass3.{pad}StaticPropertyWithError", TString("System.Exception: not implemented 30"))); - } - }); - - [Fact] - public async Task EvaluateStaticClassesNestedWithSameNames() => await CheckInspectLocalsAtBreakpointSite( - "NestedWithSameNames.B.NestedWithSameNames.B", "Run", 1, "NestedWithSameNames.B.NestedWithSameNames.B.Run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] NestedWithSameNames:Evaluate'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - foreach (var pad in new[] { String.Empty, " " }) - { - await EvaluateOnCallFrameAndCheck(id, - ($"{pad}NestedWithSameNames", TNumber(90)), - ($"B.{pad}NestedWithSameNames", TNumber(90)), - ($"{pad}B.{pad}StaticField", TNumber(40)), - ($"{pad}{pad}B.StaticProperty", TString("StaticProperty4")), - ($"B.{pad}StaticPropertyWithError{pad}", TString("System.Exception: not implemented V4")) - ); - await CheckEvaluateFail(id, - ($"{pad}NestedWithSameNames.B.{pad}StaticField", GetPrimitiveHasNoMembersMessage("B")), - ($"NestedWithSameNames.{pad}B.StaticProperty", GetPrimitiveHasNoMembersMessage("B")), - ($"{pad}NestedWithSameNames{pad}.{pad}B.StaticPropertyWithError", GetPrimitiveHasNoMembersMessage("B")), - ($"{pad}NestedWithSameNames.B.{pad}NestedWithSameNames", GetPrimitiveHasNoMembersMessage("B")), - ($"B.NestedWithSameNames.{pad}B{pad}.StaticField", GetPrimitiveHasNoMembersMessage("B")), - ($"{pad}B.NestedWithSameNames.{pad}B.StaticProperty", GetPrimitiveHasNoMembersMessage("B")), - ($"B.NestedWithSameNames{pad}.B.{pad}StaticPropertyWithError", GetPrimitiveHasNoMembersMessage("B")), - ($"{pad}NestedWithSameNames.B{pad}.NestedWithSameNames.B{pad}.NestedWithSameNames{pad}", GetPrimitiveHasNoMembersMessage("B")), - ($"NestedWithSameNames.B{pad}.{pad}{pad}NestedWithDifferentName.B.{pad}StaticField", GetPrimitiveHasNoMembersMessage("B")), - ($"{pad}NestedWithSameNames.B.NestedWithDifferentName.B.StaticProperty", GetPrimitiveHasNoMembersMessage("B")), - ($"NestedWithSameNames.{pad}B.{pad}NestedWithDifferentName.B.{pad}StaticPropertyWithError", GetPrimitiveHasNoMembersMessage("B")) - ); - } - string GetPrimitiveHasNoMembersMessage(string name) => $"Cannot find member '{name}' on a primitive type"; - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("DebuggerTests", "EvaluateStaticFieldsInInstanceClass", 7, true)] - [InlineData("DebuggerTestsV2", "EvaluateStaticFieldsInStaticClass", 2, false)] - public async Task EvaluateStaticFieldsFromDifferentNamespaceInDifferentFrames( - string namespaceName, string className, int expectedInt, bool isFromDifferentNamespace) => - await CheckInspectLocalsAtBreakpointSite( - "DebuggerTestsV2.EvaluateStaticFieldsInStaticClass", "Run", 1, "DebuggerTestsV2.EvaluateStaticFieldsInStaticClass.Run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id_top = pause_location["callFrames"][0]["callFrameId"].Value(); - var id_second = pause_location["callFrames"][1]["callFrameId"].Value(); - int expectedIntInPrevFrame = isFromDifferentNamespace ? 7 : 1; - - foreach (var pad in new[] { String.Empty, " " }) - { - await EvaluateOnCallFrameAndCheck(id_top, - ($"{pad}StaticField", TNumber(20)), - ($"{pad}{namespaceName}.{pad}{className}.StaticField{pad}", TNumber(expectedInt * 10)), - ($"{pad}StaticProperty", TString($"StaticProperty2")), - ($"{pad}{namespaceName}.{pad}{className}.StaticProperty", TString($"StaticProperty{expectedInt}")), - ($"{pad}StaticPropertyWithError", TString($"System.Exception: not implemented 2")), - ($"{pad}{namespaceName}{pad}.{pad}{className}.StaticPropertyWithError", TString($"System.Exception: not implemented {expectedInt}")) - ); - - if (!isFromDifferentNamespace) - { - await EvaluateOnCallFrameAndCheck(id_top, - ($"{pad}{className}.StaticField", TNumber(expectedInt * 10)), - ($"{className}{pad}.StaticProperty{pad}", TString($"StaticProperty{expectedInt}")), - ($"{className}{pad}.{pad}StaticPropertyWithError", TString($"System.Exception: not implemented {expectedInt}")) - ); - } - - await EvaluateOnCallFrameAndCheck(id_second, - ($"{pad}{namespaceName}.{pad}{className}.{pad}StaticField", TNumber(expectedInt * 10)), - ($"{pad}{className}.StaticField", TNumber(expectedIntInPrevFrame * 10)), - ($"{namespaceName}{pad}.{pad}{className}.StaticProperty", TString($"StaticProperty{expectedInt}")), - ($"{pad}{className}.StaticProperty", TString($"StaticProperty{expectedIntInPrevFrame}")), - ($"{pad}{namespaceName}.{className}.StaticPropertyWithError", TString($"System.Exception: not implemented {expectedInt}")), - ($"{className}{pad}.StaticPropertyWithError{pad}", TString($"System.Exception: not implemented {expectedIntInPrevFrame}")) - ); - - await CheckEvaluateFail(id_second, - ($"{pad}StaticField", GetNonExistingVarMessage("StaticField")), - ($"{pad}{pad}StaticProperty", GetNonExistingVarMessage("StaticProperty")), - ($"{pad}StaticPropertyWithError{pad}", GetNonExistingVarMessage("StaticPropertyWithError")) - ); - } - string GetNonExistingVarMessage(string name) => $"The name {name} does not exist in the current context"; - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateStaticClassInvalidField() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var id_prev = pause_location["callFrames"][1]["callFrameId"].Value(); - - var (_, res) = await EvaluateOnCallFrame(id, "DebuggerTests.EvaluateStaticFieldsInStaticClass.StaticProperty2", expect_ok: false); - AssertEqual("Failed to resolve member access for DebuggerTests.EvaluateStaticFieldsInStaticClass.StaticProperty2", res.Error["result"]?["description"]?.Value(), "wrong error message"); - var exceptionDetailsStack = res.Error["exceptionDetails"]?["stackTrace"]?["callFrames"]?[0]; - Assert.Equal("DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", exceptionDetailsStack?["functionName"]?.Value()); - Assert.Equal(358, exceptionDetailsStack?["lineNumber"]?.Value()); - Assert.Equal(16, exceptionDetailsStack?["columnNumber"]?.Value()); - (_, res) = await EvaluateOnCallFrame(id_prev, "DebuggerTests.EvaluateStaticFieldsInStaticClass.StaticProperty2", expect_ok: false); - exceptionDetailsStack = res.Error["exceptionDetails"]?["stackTrace"]?["callFrames"]?[0]; - AssertEqual("Failed to resolve member access for DebuggerTests.EvaluateStaticFieldsInStaticClass.StaticProperty2", res.Error["result"]?["description"]?.Value(), "wrong error message"); - Assert.Equal("DebuggerTests.EvaluateMethodTestsClass.EvaluateMethods", exceptionDetailsStack?["functionName"]?.Value()); - Assert.Equal(422, exceptionDetailsStack?["lineNumber"]?.Value()); - Assert.Equal(12, exceptionDetailsStack?["columnNumber"]?.Value()); - (_, res) = await EvaluateOnCallFrame(id, "DebuggerTests.InvalidEvaluateStaticClass.StaticProperty2", expect_ok: false); - AssertEqual("Failed to resolve member access for DebuggerTests.InvalidEvaluateStaticClass.StaticProperty2", res.Error["result"]?["description"]?.Value(), "wrong error message"); - }); - - [ConditionalFact(nameof(WasmSingleThreaded), nameof(RunningOnChrome))] - public async Task AsyncLocalsInContinueWithBlock() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.AsyncTests.ContinueWithTests", "ContinueWithStaticAsync", 4, "DebuggerTests.AsyncTests.ContinueWithTests.ContinueWithStaticAsync.AnonymousMethod__3_0", - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ($"t.Status", TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion")), - ($" t.Status", TEnum("System.Threading.Tasks.TaskStatus", "RanToCompletion")) - ); - - await EvaluateOnCallFrameFail(id, - ("str", "ReferenceError"), - (" str", "ReferenceError") - ); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateConstantValueUsingRuntimeEvaluate() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClass", "EvaluateLocals", 9, "DebuggerTests.EvaluateTestsClass.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var dt = new DateTime(2020, 1, 2, 3, 4, 5); - await RuntimeEvaluateAndCheck( - ("15\n//comment as vs does\n", TNumber(15)), - ("15", TNumber(15)), - ("\"15\"\n//comment as vs does\n", TString("15")), - ("\"15\"", TString("15"))); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("EvaluateBrowsableClass", "TestEvaluateFieldsNone", "testFieldsNone", 10)] - [InlineData("EvaluateBrowsableClass", "TestEvaluatePropertiesNone", "testPropertiesNone", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluateFieldsNone", "testFieldsNone", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluatePropertiesNone", "testPropertiesNone", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluateFieldsNone", "testFieldsNone", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluatePropertiesNone", "testPropertiesNone", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluateFieldsNone", "testFieldsNone", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluatePropertiesNone", "testPropertiesNone", 10)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClass", "TestEvaluatePropertiesNone", "testPropertiesNone", 5, true)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStruct", "TestEvaluatePropertiesNone", "testPropertiesNone", 5, true)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClassStatic", "TestEvaluatePropertiesNone", "testPropertiesNone", 5, true)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStructStatic", "TestEvaluatePropertiesNone", "testPropertiesNone", 5, true)] - public async Task EvaluateBrowsableNone( - string outerClassName, string className, string localVarName, int breakLine, bool allMembersAreProperties = false) => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.{outerClassName}", "Evaluate", breakLine, $"DebuggerTests.{outerClassName}.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.{outerClassName}:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var (testNone, _) = await EvaluateOnCallFrame(id, localVarName); - await CheckValue(testNone, TObject($"DebuggerTests.{outerClassName}.{className}"), nameof(testNone)); - var testNoneProps = await GetProperties(testNone["objectId"]?.Value()); - - if (allMembersAreProperties) - await CheckProps(testNoneProps, new - { - list = TGetter("list", TObject("System.Collections.Generic.List", description: "Count = 2")), - array = TGetter("array", TObject("int[]", description: "int[2]")), - text = TGetter("text", TString("text")), - nullNone = TGetter("nullNone", TObject("bool[]", is_null: true)), - valueTypeEnum = TGetter("valueTypeEnum", TEnum("DebuggerTests.SampleEnum", "yes")), - sampleStruct = TGetter("sampleStruct", TObject("DebuggerTests.SampleStructure", description: "DebuggerTests.SampleStructure")), - sampleClass = TGetter("sampleClass", TObject("DebuggerTests.SampleClass", description: "DebuggerTests.SampleClass")) - }, "testNoneProps#1"); - else - await CheckProps(testNoneProps, new - { - list = TObject("System.Collections.Generic.List", description: "Count = 2"), - array = TObject("int[]", description: "int[2]"), - text = TString("text"), - nullNone = TObject("bool[]", is_null: true), - valueTypeEnum = TEnum("DebuggerTests.SampleEnum", "yes"), - sampleStruct = TObject("DebuggerTests.SampleStructure", description: "DebuggerTests.SampleStructure"), - sampleClass = TObject("DebuggerTests.SampleClass", description: "DebuggerTests.SampleClass") - }, "testNoneProps#1"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("EvaluateBrowsableClass", "TestEvaluateFieldsNever", "testFieldsNever", 10)] - [InlineData("EvaluateBrowsableClass", "TestEvaluatePropertiesNever", "testPropertiesNever", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluateFieldsNever", "testFieldsNever", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluatePropertiesNever", "testPropertiesNever", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluateFieldsNever", "testFieldsNever", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluatePropertiesNever", "testPropertiesNever", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluateFieldsNever", "testFieldsNever", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluatePropertiesNever", "testPropertiesNever", 10)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClass", "TestEvaluatePropertiesNever", "testPropertiesNever", 5)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStruct", "TestEvaluatePropertiesNever", "testPropertiesNever", 5)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClassStatic", "TestEvaluatePropertiesNever", "testPropertiesNever", 5)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStructStatic", "TestEvaluatePropertiesNever", "testPropertiesNever", 5)] - public async Task EvaluateBrowsableNever(string outerClassName, string className, string localVarName, int breakLine) => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.{outerClassName}", "Evaluate", breakLine, $"DebuggerTests.{outerClassName}.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.{outerClassName}:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var (testNever, _) = await EvaluateOnCallFrame(id, localVarName); - await CheckValue(testNever, TObject($"DebuggerTests.{outerClassName}.{className}"), nameof(testNever)); - var testNeverProps = await GetProperties(testNever["objectId"]?.Value()); - await CheckProps(testNeverProps, new - { - }, "testNeverProps#1"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("EvaluateBrowsableClass", "TestEvaluateFieldsCollapsed", "testFieldsCollapsed", 10)] - [InlineData("EvaluateBrowsableClass", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluateFieldsCollapsed", "testFieldsCollapsed", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluateFieldsCollapsed", "testFieldsCollapsed", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluateFieldsCollapsed", "testFieldsCollapsed", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 10)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClass", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 5, true)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStruct", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 5, true)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClassStatic", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 5, true)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStructStatic", "TestEvaluatePropertiesCollapsed", "testPropertiesCollapsed", 5, true)] - public async Task EvaluateBrowsableCollapsed( - string outerClassName, string className, string localVarName, int breakLine, bool allMembersAreProperties = false) => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.{outerClassName}", "Evaluate", breakLine, $"DebuggerTests.{outerClassName}.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.{outerClassName}:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var (testCollapsed, _) = await EvaluateOnCallFrame(id, localVarName); - await CheckValue(testCollapsed, TObject($"DebuggerTests.{outerClassName}.{className}"), nameof(testCollapsed)); - var testCollapsedProps = await GetProperties(testCollapsed["objectId"]?.Value()); - if (allMembersAreProperties) - await CheckProps(testCollapsedProps, new - { - listCollapsed = TGetter("listCollapsed", TObject("System.Collections.Generic.List", description: "Count = 2")), - arrayCollapsed = TGetter("arrayCollapsed", TObject("int[]", description: "int[2]")), - textCollapsed = TGetter("textCollapsed", TString("textCollapsed")), - nullCollapsed = TGetter("nullCollapsed", TObject("bool[]", is_null: true)), - valueTypeEnumCollapsed = TGetter("valueTypeEnumCollapsed", TEnum("DebuggerTests.SampleEnum", "yes")), - sampleStructCollapsed = TGetter("sampleStructCollapsed", TObject("DebuggerTests.SampleStructure", description: "DebuggerTests.SampleStructure")), - sampleClassCollapsed = TGetter("sampleClassCollapsed", TObject("DebuggerTests.SampleClass", description: "DebuggerTests.SampleClass")) - }, "testCollapsedProps#1"); - else - await CheckProps(testCollapsedProps, new - { - listCollapsed = TObject("System.Collections.Generic.List", description: "Count = 2"), - arrayCollapsed = TObject("int[]", description: "int[2]"), - textCollapsed = TString("textCollapsed"), - nullCollapsed = TObject("bool[]", is_null: true), - valueTypeEnumCollapsed = TEnum("DebuggerTests.SampleEnum", "yes"), - sampleStructCollapsed = TObject("DebuggerTests.SampleStructure", description: "DebuggerTests.SampleStructure"), - sampleClassCollapsed = TObject("DebuggerTests.SampleClass", description: "DebuggerTests.SampleClass") - }, "testCollapsedProps#1"); - }); - - // [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("EvaluateBrowsableClass", "TestEvaluateFieldsRootHidden", "testFieldsRootHidden", 10)] - [InlineData("EvaluateBrowsableClass", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluateFieldsRootHidden", "testFieldsRootHidden", 10)] - [InlineData("EvaluateBrowsableStruct", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluateFieldsRootHidden", "testFieldsRootHidden", 10)] - [InlineData("EvaluateBrowsableClassStatic", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluateFieldsRootHidden", "testFieldsRootHidden", 10)] - [InlineData("EvaluateBrowsableStructStatic", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 10)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClass", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 5)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStruct", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 5)] - [InlineData("EvaluateBrowsableNonAutoPropertiesClassStatic", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 5)] - [InlineData("EvaluateBrowsableNonAutoPropertiesStructStatic", "TestEvaluatePropertiesRootHidden", "testPropertiesRootHidden", 5)] - public async Task EvaluateBrowsableRootHidden( - string outerClassName, string className, string localVarName, int breakLine) => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.{outerClassName}", "Evaluate", breakLine, $"DebuggerTests.{outerClassName}.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.{outerClassName}:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var (testRootHidden, _) = await EvaluateOnCallFrame(id, localVarName); - await CheckValue(testRootHidden, TObject($"DebuggerTests.{outerClassName}.{className}"), nameof(testRootHidden)); - var testRootHiddenProps = await GetProperties(testRootHidden["objectId"]?.Value()); - - JObject[] expectedTestRootHiddenProps = new[] - { - JObject.FromObject(new { value = TNumber(1), name = "listRootHidden[0]"}), - JObject.FromObject(new { value = TNumber(2), name = "listRootHidden[1]"}), - JObject.FromObject(new { value = TNumber(11), name = "arrayRootHidden[0]"}), - JObject.FromObject(new { value = TNumber(22), name = "arrayRootHidden[1]"}), - JObject.FromObject(new { value = TNumber(100), name = "sampleStructRootHidden.Id"}), - JObject.FromObject(new { value = TBool(true), name = "sampleStructRootHidden.IsStruct"}), - JObject.FromObject(new { value = TNumber(200), name = "sampleClassRootHidden.ClassId"}), - JObject.FromObject(new { value = TObject("System.Collections.Generic.List", description: "Count = 1"), name = "sampleClassRootHidden.Items"}) - }; - await CheckProps(testRootHiddenProps, expectedTestRootHiddenProps, "listRootHidden"); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateStaticAttributeInAssemblyNotRelatedButLoaded() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClass", "EvaluateLocals", 9, "DebuggerTests.EvaluateTestsClass.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - await RuntimeEvaluateAndCheck( - ("ClassToBreak.valueToCheck", TNumber(10))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateLocalObjectFromAssemblyNotRelatedButLoaded() - => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClass", "EvaluateLocalsFromAnotherAssembly", 5, "DebuggerTests.EvaluateTestsClass.EvaluateLocalsFromAnotherAssembly", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocalsFromAnotherAssembly'); })", - wait_for_event_fn: async (pause_location) => - { - await RuntimeEvaluateAndCheck( - ("a.valueToCheck", TNumber(20))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task StructureGetters() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.StructureGetters", "Evaluate", 2, $"DebuggerTests.StructureGetters.Evaluate", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.StructureGetters:Evaluate'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var (obj, _) = await EvaluateOnCallFrame(id, "s"); - var props = await GetProperties(obj["objectId"]?.Value()); - await CheckProps(props, new - { - Id = TGetter("Id", TNumber(123)) - }, "s#1"); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateMethodWithDefaultParam() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.DefaultParamMethods", "Evaluate", 2, "DebuggerTests.DefaultParamMethods.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.DefaultParamMethods:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("test.GetByte()", TNumber(1)), - ("test.GetSByte()", TNumber(1)), - ("test.GetByteNullable()", TNumber(1)), - ("test.GetSByteNullable()", TNumber(1)), - - ("test.GetInt16()", TNumber(1)), - ("test.GetUInt16()", TNumber(1)), - ("test.GetInt16Nullable()", TNumber(1)), - ("test.GetUInt16Nullable()", TNumber(1)), - - ("test.GetInt32()", TNumber(1)), - ("test.GetUInt32()", TNumber(1)), - ("test.GetInt32Nullable()", TNumber(1)), - ("test.GetUInt32Nullable()", TNumber(1)), - - ("test.GetInt64()", TNumber(1)), - ("test.GetUInt64()", TNumber(1)), - ("test.GetInt64Nullable()", TNumber(1)), - ("test.GetUInt64Nullable()", TNumber(1)), - - ("test.GetChar()", TChar('T')), - ("test.GetCharNullable()", TChar('T')), - ("test.GetUnicodeChar()", TChar('\u0105')), - - ("test.GetString()", TString("1.23")), - ("test.GetUnicodeString()", TString("\u017C\u00F3\u0142\u0107")), - ("test.GetString(null)", TString(null)), - ("test.GetStringNullable()", TString("1.23")), - - ("test.GetSingle()", TNumber("1.23", isDecimal: true)), - ("test.GetDouble()", TNumber("1.23", isDecimal: true)), - ("test.GetSingleNullable()", TNumber("1.23", isDecimal: true)), - ("test.GetDoubleNullable()", TNumber("1.23", isDecimal: true)), - - ("test.GetBool()", TBool(true)), - ("test.GetBoolNullable()", TBool(true)), - ("test.GetNull()", TBool(true)), - - ("test.SumDefaultAndRequiredParam(2)", TNumber(5)), - ("test.SumDefaultAndRequiredParam(3, 2)", TNumber(5)), - ("test.SumDefaultNegativeAndRequiredParamInts(3, +2)", TNumber(5)), - ("test.SumDefaultNegativeAndRequiredParamInts(-3, -2)", TNumber(-5)), - ("test.SumDefaultNegativeAndRequiredParamInts(-3)", TNumber(-6)), // default: -3 - ("test.SumDefaultNegativeAndRequiredParamLongInts(-1l, -2l)", TNumber(-3)), - ("test.SumDefaultNegativeAndRequiredParamLongInts(-1l)", TNumber(-124)), // default: -123l - ("test.SumDefaultNegativeAndRequiredParamFloats(-1.1f, -1.1f)", TNumber("-2.2", isDecimal: true)), - ("test.SumDefaultNegativeAndRequiredParamFloats(-1.1f)", TNumber("-4.4", isDecimal: true)), // default: -3.3f - ("test.SumDefaultNegativeAndRequiredParamDoubles(-0.1, -0.2)", TNumber("-0.30000000000000004", isDecimal: true)), // expected result for doubles copied from coreclr response - ("test.SumDefaultNegativeAndRequiredParamDoubles(-0.1)", TNumber("-3.3000000000000003", isDecimal: true)), // default: -3.2 - // https://github.com/dotnet/runtime/issues/93057 - // ("test.SumDefaultNegativeAndRequiredParamShortInts(-1, -120)", TNumber(-121)), // we have no way of testing it, debugger recognizes passed literals as integers and does not find the correct overload. We would need to cast to short and we don't support passing parameters with a cast. - // ("test.SumDefaultNegativeAndRequiredParamShortInts(-1)", TNumber(-124)), // default: -123 - // ("test.GetDefaultNegativeShortInt(-123)", TNumber(-123)), - ("test.GetDefaultNegativeShortInt()", TNumber(-123)), // default: -123 - ("test.GetDefaultAndRequiredParamMixedTypes(\"a\")", TString("a; -1; False")), - ("test.GetDefaultAndRequiredParamMixedTypes(\"a\", 23)", TString("a; 23; False")), - ("test.GetDefaultAndRequiredParamMixedTypes(\"a\", 23, true)", TString("a; 23; True")) - ); - - var (_, res) = await EvaluateOnCallFrame(id, "test.GetDefaultAndRequiredParamMixedTypes(\"a\", 23, true, 1.23f)", expect_ok: false); - AssertEqual("Unable to evaluate method 'GetDefaultAndRequiredParamMixedTypes'. Too many arguments passed.", - res.Error["result"]["description"]?.Value(), "wrong error message"); - }); - - [Fact] - public async Task EvaluateMethodWithLinq() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.DefaultParamMethods", "Evaluate", 2, "DebuggerTests.DefaultParamMethods.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.DefaultParamMethods:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("test.listToLinq.ToList()", TObject("System.Collections.Generic.List", description: "Count = 11")) - ); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateNullObjectPropertiesPositive() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.EvaluateNullableProperties", "Evaluate", 11, "DebuggerTests.EvaluateNullableProperties.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.EvaluateNullableProperties:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - // we have no way of returning int? for null values, - // so we return the last non-null class name - await EvaluateOnCallFrameAndCheck(id, - ("list.Count", TNumber(1)), - ("list!.Count", TNumber(1)), - ("list?.Count", TNumber(1)), - ("listNull", TObject("System.Collections.Generic.List", is_null: true)), - ("listNull?.Count", TObject("System.Collections.Generic.List", is_null: true)), - ("tc?.MemberList?.Count", TNumber(2)), - ("tc!.MemberList?.Count", TNumber(2)), - ("tc!.MemberList!.Count", TNumber(2)), - ("tc?.MemberListNull?.Count", TObject("System.Collections.Generic.List", is_null: true)), - ("tc.MemberListNull?.Count", TObject("System.Collections.Generic.List", is_null: true)), - ("tcNull?.MemberListNull?.Count", TObject("DebuggerTests.EvaluateNullableProperties.TestClass", is_null: true)), - ("str!.Length", TNumber(9)), - ("str?.Length", TNumber(9)), - ("str_null?.Length", TObject("string", is_null: true)) - ); - }); - - [Fact] - public async Task EvaluateNullObjectPropertiesNegative() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.EvaluateNullableProperties", "Evaluate", 6, "DebuggerTests.EvaluateNullableProperties.Evaluate", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.EvaluateNullableProperties:Evaluate'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await CheckEvaluateFail(id, - ("list.Count.x", "Cannot find member 'x' on a primitive type"), - ("listNull.Count", GetNullReferenceErrorOn("\"Count\"")), - ("listNull!.Count", GetNullReferenceErrorOn("\"Count\"")), - ("tcNull.MemberListNull.Count", GetNullReferenceErrorOn("\"MemberListNull\"")), - ("tc.MemberListNull.Count", GetNullReferenceErrorOn("\"Count\"")), - ("tcNull?.MemberListNull.Count", GetNullReferenceErrorOn("\"Count\"")), - ("listNull?.Count.NonExistingProperty", GetNullReferenceErrorOn("\"NonExistingProperty\"")), - ("tc?.MemberListNull! .Count", GetNullReferenceErrorOn("\"Count\"")), - ("tc?. MemberListNull!.Count", GetNullReferenceErrorOn("\"Count\"")), - ("tc?.MemberListNull.Count", GetNullReferenceErrorOn("\"Count\"")), - ("tc! .MemberListNull!.Count", GetNullReferenceErrorOn("\"Count\"")), - ("tc!.MemberListNull. Count", GetNullReferenceErrorOn("\"Count\"")), - ("tcNull?.Sibling.MemberListNull?.Count", GetNullReferenceErrorOn("\"MemberListNull?\"")), - ("listNull?", "Expected expression."), - ("listNull!.Count", GetNullReferenceErrorOn("\"Count\"")), - ("x?.p", "Operation '?' not allowed on primitive type - 'x?'"), - ("str_null.Length", GetNullReferenceErrorOn("\"Length\"")), - ("str_null!.Length", GetNullReferenceErrorOn("\"Length\"")) - ); - - string GetNullReferenceErrorOn(string name) => $"Expression threw NullReferenceException trying to access {name} on a null-valued object."; - }); - - [Fact] - public async Task EvaluateMethodsOnPrimitiveTypesReturningPrimitives() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.PrimitiveTypeMethods", "Evaluate", 11, "DebuggerTests.PrimitiveTypeMethods.Evaluate", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.PrimitiveTypeMethods:Evaluate'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("test.propInt.ToString()", TString("12")), - ("test.propUint.ToString()", TString("12")), - ("test.propLong.ToString()", TString("12")), - ("test.propUlong.ToString()", TString("12")), - ("test.propBool.ToString()", TString("True")), - ("test.propChar.ToString()", TString("X")), - ("test.propString.ToString()", TString("s_t_r")), - ("test.propString.EndsWith('r')", TBool(true)), - ("test.propString.StartsWith('S')", TBool(false)), - ("localInt.ToString()", TString("2")), - ("localUint.ToString()", TString("2")), - ("localLong.ToString()", TString("2")), - ("localUlong.ToString()", TString("2")), - ("localBool.ToString()", TString("False")), - ("localBool.GetHashCode()", TNumber(0)), - ("localBool.GetTypeCode()", TObject("System.TypeCode", "Boolean")), - ("localChar.ToString()", TString("Y")), - ("localString.ToString()", TString("S*T*R")), - ("localString.EndsWith('r')", TBool(false)), - ("localString.StartsWith('S')", TBool(true)) - ); - }); - - [Fact] - public async Task EvaluateMethodsOnPrimitiveTypesReturningPrimitivesCultureDependant() => - await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.PrimitiveTypeMethods", "Evaluate", 11, "DebuggerTests.PrimitiveTypeMethods.Evaluate", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.PrimitiveTypeMethods:Evaluate'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var (floatMemberVal, _) = await EvaluateOnCallFrame(id, "test.propFloat"); - var (doubleMemberVal, _) = await EvaluateOnCallFrame(id, "test.propDouble"); - var (floatLocalVal, _) = await EvaluateOnCallFrame(id, "localFloat"); - var (doubleLocalVal, _) = await EvaluateOnCallFrame(id, "localDouble"); - - // expected value depends on the debugger's user culture and is equal to - // description of the number that also respects user's culture settings - await EvaluateOnCallFrameAndCheck(id, - ("test.propFloat.ToString()", TString(floatMemberVal["description"]?.Value())), - ("test.propDouble.ToString()", TString(doubleMemberVal["description"]?.Value())), - - ("localFloat.ToString()", TString(floatLocalVal["description"]?.Value())), - ("localDouble.ToString()", TString(doubleLocalVal["description"]?.Value()))); - }); - - [Fact] - public async Task EvaluateMethodsOnPrimitiveTypesReturningObjects() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.PrimitiveTypeMethods", "Evaluate", 11, "DebuggerTests.PrimitiveTypeMethods.Evaluate", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.PrimitiveTypeMethods:Evaluate'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var (res, _) = await EvaluateOnCallFrame(id, "test.propString.Split('_', 3, System.StringSplitOptions.TrimEntries)"); - var props = await GetProperties(res["objectId"]?.Value()); - var expected_props = new[] { TString("s"), TString("t"), TString("r") }; - await CheckProps(props, expected_props, "props#1"); - - (res, _) = await EvaluateOnCallFrame(id, "localString.Split('*', 3, System.StringSplitOptions.RemoveEmptyEntries)"); - props = await GetProperties(res["objectId"]?.Value()); - expected_props = new[] { TString("S"), TString("T"), TString("R") }; - await CheckProps(props, expected_props, "props#2"); - }); - - [Theory] - [InlineData("DefaultMethod", "IDefaultInterface", "Evaluate")] - [InlineData("DefaultMethod2", "IExtendIDefaultInterface", "Evaluate")] - [InlineData("DefaultMethodAsync", "IDefaultInterface", "EvaluateAsync", true)] - public async Task EvaluateLocalsInDefaultInterfaceMethod(string pauseMethod, string methodInterface, string entryMethod, bool isAsync = false) => - await CheckInspectLocalsAtBreakpointSite( - methodInterface, pauseMethod, 2, methodInterface + "." + pauseMethod, - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DefaultInterfaceMethod:{entryMethod}'); }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("localString", TString($"{pauseMethod}()")), - ("this", TObject("DIMClass")), - ("this.dimClassMember", TNumber(123))); - }); - - [Theory] - [InlineData("DefaultMethodStatic", "IDefaultInterface", "EvaluateStatic")] - [InlineData("DefaultMethodAsyncStatic", "IDefaultInterface", "EvaluateAsyncStatic", true)] - public async Task EvaluateLocalsInDefaultInterfaceMethodStatic(string pauseMethod, string methodInterface, string entryMethod, bool isAsync = false) => - await CheckInspectLocalsAtBreakpointSite( - methodInterface, pauseMethod, 2, methodInterface + "." + pauseMethod, - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DefaultInterfaceMethod:{entryMethod}'); }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("localString", TString($"{pauseMethod}()")), - ("IDefaultInterface.defaultInterfaceMember", TString("defaultInterfaceMember")), - ("defaultInterfaceMember", TString("defaultInterfaceMember")) - ); - }); - - [Fact] - public async Task EvaluateStringProperties() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.TypeProperties", "Run", 3, "DebuggerTests.TypeProperties.Run", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.TypeProperties:Run'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("localString.Length", TNumber(5)), - ("localString[1]", TChar('B')), - ("instance.str.Length", TNumber(5)), - ("instance.str[3]", TChar('c')) - ); - }); - - [Fact] - public async Task EvaluateStaticGetterInValueType() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.TypeProperties", "Run", 3, "DebuggerTests.TypeProperties.Run", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.TypeProperties:Run'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("EvaluateStaticGetterInValueType.A", TNumber(5)) - ); - }); - - [Fact] - public async Task EvaluateSumBetweenObjectAndString() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.SumObjectAndString", "run", 7, "DebuggerTests.SumObjectAndString.run", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.SumObjectAndString:run'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("myList+\"asd\"", TString("System.Collections.Generic.List`1[System.Int32]asd")), - ("dt+\"asd\"", TString("1/1/0001 12:00:00 AMasd")), - ("myClass+\"asd\"", TString("OverriddenToStringasd")), - ("listNull+\"asd\"", TString("asd")) - ); - await CheckEvaluateFail(id, - ("myClass+dt", "Cannot evaluate '(myClass+dt\n)': (3,9): error CS0019: Operator '+' cannot be applied to operands of type 'object' and 'object'"), - ("myClass+1", "Cannot evaluate '(myClass+1\n)': (2,9): error CS0019: Operator '+' cannot be applied to operands of type 'object' and 'int'"), - ("dt+1", "Cannot evaluate '(dt+1\n)': (2,9): error CS0019: Operator '+' cannot be applied to operands of type 'object' and 'int'") - ); - }); - - [Fact] - public async Task EvaluateMethodsOnEnum() => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.EvaluateMethodsOnEnum", "run", 2, "DebuggerTests.EvaluateMethodsOnEnum.run", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodsOnEnum:run'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("s_valueTypeEnum.ToString()", TString("no")), - ("mc.valueTypeEnum.ToString()", TString("yes")) - // ("mc.valueTypeEnum.HasFlag(SampleEnum.no)", TBool(true)) // ToDo: https://github.com/dotnet/runtime/issues/92262 - ); - }); - - [Fact] - public async Task EvaluateObjectIndexingMultidimensional() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 12, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("c[j, aDouble]", TNumber("3.34")), //only IdentifierNameSyntaxes - ("c[1, aDouble]", TNumber("3.34")), //IdentifierNameSyntax with LiteralExpressionSyntax - ("c[aChar, \"&\", longString]", TString("9-&-longString")), - ("c[cc.numArray[j], aDouble]", TNumber("4.34")), //ElementAccessExpressionSyntax - ("c[cc.numArray[j], cc.numArray[0]]", TNumber("3")), //multiple ElementAccessExpressionSyntaxes - ("c[cc.numArray[cc.numList[0]], cc.numArray[i]]", TNumber("3")), - ("c[cc.numArray[cc.numList[0]], cc.numArray[cc.numArray[i]]]", TNumber("4")) - ); - }); - - [Fact] - public async Task EvaluateValueTypeIndexingMultidimensional() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 12, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("s[j, aDouble]", TNumber("3.34")), //only IdentifierNameSyntaxes - ("s[1, aDouble]", TNumber("3.34")), //IdentifierNameSyntax with LiteralExpressionSyntax - ("s[aChar, \"&\", longString]", TString("9-&-longString")), - ("s[cc.numArray[j], aDouble]", TNumber("4.34")), //ElementAccessExpressionSyntax - ("s[cc.numArray[j], cc.numArray[0]]", TNumber("3")), //multiple ElementAccessExpressionSyntaxes - ("s[cc.numArray[cc.numList[0]], cc.numArray[i]]", TNumber("3")), - ("s[cc.numArray[cc.numList[0]], cc.numArray[cc.numArray[i]]]", TNumber("4")) - ); - }); - - - [Fact] - public async Task EvaluateMethodsWithObjectParams() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.FastCheck", "run", 6, "DebuggerTests.FastCheck.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.FastCheck:run'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("mc.Method(number)", TNumber(-123)), - ("mc.Method(ic)", TNumber(123)), - ("mc.Method(ic.number)", TNumber(123)), - ("mc.Method(DebuggerTestsV2.EvaluateStaticFieldsInStaticClass.StaticField)", TNumber(20)), - ("mc.Method(EvaluateStaticFieldsInInstanceClass.StaticField)", TNumber(70)), - ("mc.Method(instance.StaticField)", TNumber(70)), - ("mc.Method(instance2.propInt)", TNumber(12)) - ); - }); - - // https://github.com/dotnet/runtime/issues/98086 - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateValueTypeWithFixedArrayAndMoreFields() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateValueTypeWithFixedArray", "run", 3, "DebuggerTests.EvaluateValueTypeWithFixedArray.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateValueTypeWithFixedArray:run'); })", - wait_for_event_fn: async (pause_location) => - { - await RuntimeEvaluateAndCheck( - ("myVar.MyMethod()", TNumber(13)), - ("myVar.myIntArray[0]", TNumber(1)), - ("myVar.myIntArray[1]", TNumber(2)), - ("myVar.myCharArray[2]", TChar('a'))); - }); - - // https://github.com/dotnet/runtime/issues/98086 - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateValueTypeWithObjectValueType() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateValueTypeWithObjectValueType", "run", 3, "DebuggerTests.EvaluateValueTypeWithObjectValueType.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateValueTypeWithObjectValueType:run'); })", - wait_for_event_fn: async (pause_location) => - { - await RuntimeEvaluateAndCheck( - ("myVar.MyMethod()", TNumber(10))); - }); - - // https://github.com/dotnet/runtime/issues/106311 - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateOnValueTypeWithoutExtraSpace() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateOnValueTypeWithoutExtraSpace", "run", 3, "DebuggerTests.EvaluateOnValueTypeWithoutExtraSpace.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateOnValueTypeWithoutExtraSpace:run'); })", - wait_for_event_fn: async (pause_location) => - { - await RuntimeEvaluateAndCheck( - ("f1.DistSquaredXY(f2)", TNumber(2))); - }); - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrameTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrameTests.cs deleted file mode 100644 index 5e099a787bc466..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/EvaluateOnCallFrameTests.cs +++ /dev/null @@ -1,937 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - // TODO: static async, static method args - public class EvaluateOnCallFrameTests : DebuggerTests - { - public EvaluateOnCallFrameTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - public static IEnumerable InstanceMethodsTestData(string type_name) - { - yield return new object[] { type_name, "InstanceMethod", $"{type_name}.InstanceMethod", false }; - yield return new object[] { type_name, "GenericInstanceMethod", $"{type_name}.GenericInstanceMethod", false }; - yield return new object[] { type_name, "InstanceMethodAsync", $"{type_name}.InstanceMethodAsync", true }; - yield return new object[] { type_name, "GenericInstanceMethodAsync", $"{type_name}.GenericInstanceMethodAsync", true }; - - // TODO: { "DebuggerTests.EvaluateTestsGeneric`1", "Instance", 9, "EvaluateTestsGenericStructInstanceMethod", prefix } - } - - public static IEnumerable InstanceMethodForTypeMembersTestData(string type_name) - { - foreach (var data in InstanceMethodsTestData(type_name)) - { - yield return new object[] { "", 0 }.Concat(data).ToArray(); - yield return new object[] { "this.", 0 }.Concat(data).ToArray(); - yield return new object[] { "NewInstance.", 3 }.Concat(data).ToArray(); - yield return new object[] { "this.NewInstance.", 3 }.Concat(data).ToArray(); - } - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(InstanceMethodForTypeMembersTestData), parameters: "DebuggerTests.EvaluateTestsStructWithProperties")] - [MemberData(nameof(InstanceMethodForTypeMembersTestData), parameters: "DebuggerTests.EvaluateTestsClassWithProperties")] - public async Task EvaluateTypeInstanceMembers(string prefix, int bias, string type, string method, string bp_function_name, bool is_async) - => await CheckInspectLocalsAtBreakpointSite( - type, method, /*line_offset*/1, bp_function_name, - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] {type}:run');}}, 1);", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var dateTime = new DateTime(2010, 9, 8, 7, 6, 5 + bias); - var DTProp = dateTime.AddMinutes(10); - - foreach (var pad in new[] { String.Empty, " " }) - { - var padded_prefix = pad + prefix; - await EvaluateOnCallFrameAndCheck(id, - ($"{padded_prefix}a", TNumber(4)), - - // fields - ($"{padded_prefix}dateTime.TimeOfDay", TValueType("System.TimeSpan", dateTime.TimeOfDay.ToString())), - ($"{padded_prefix}dateTime", TDateTime(dateTime)), - ($"{padded_prefix}dateTime.TimeOfDay.Minutes", TNumber(dateTime.TimeOfDay.Minutes)), - - // properties - ($"{padded_prefix}DTProp.TimeOfDay.Minutes", TNumber(DTProp.TimeOfDay.Minutes)), - ($"{padded_prefix}DTProp", TDateTime(DTProp)), - ($"{padded_prefix}DTProp.TimeOfDay", TValueType("System.TimeSpan", DTProp.TimeOfDay.ToString())), - - ($"{padded_prefix}IntProp", TNumber(9)), - ($"{padded_prefix}NullIfAIsNotZero", TObject("DebuggerTests.EvaluateTestsClassWithProperties", is_null: true)) - ); - } - }); - - [Theory] - [MemberData(nameof(InstanceMethodsTestData), parameters: "DebuggerTests.EvaluateTestsStructWithProperties")] - [MemberData(nameof(InstanceMethodsTestData), parameters: "DebuggerTests.EvaluateTestsClassWithProperties")] - public async Task EvaluateInstanceMethodArguments(string type, string method, string bp_function_name, bool is_async) - => await CheckInspectLocalsAtBreakpointSite( - type, method, /*line_offset*/1, bp_function_name, - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] {type}:run');}}, 1);", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var DTProp = new DateTime(2010, 9, 8, 7, 6, 5).AddMinutes(10); - _testOutput.WriteLine ($"------- test running the bits.."); - await EvaluateOnCallFrameAndCheck(id, - ("g", TNumber(400)), - ("h", TNumber(123)), - ("valString", TString("just a test")), - ("me", TObject(type)), - - // property on method arg - ("me.DTProp", TDateTime(DTProp)), - ("me.DTProp.TimeOfDay.Minutes", TNumber(DTProp.TimeOfDay.Minutes)), - ("me.DTProp.Second + (me.IntProp - 5)", TNumber(DTProp.Second + 4))) - .ConfigureAwait(false); - - _testOutput.WriteLine ($"------- test done!"); - }); - - [Theory] - [MemberData(nameof(InstanceMethodsTestData), parameters: "DebuggerTests.EvaluateTestsStructWithProperties")] - [MemberData(nameof(InstanceMethodsTestData), parameters: "DebuggerTests.EvaluateTestsClassWithProperties")] - public async Task EvaluateMethodLocals(string type, string method, string bp_function_name, bool is_async) - => await CheckInspectLocalsAtBreakpointSite( - type, method, /*line_offset*/5, bp_function_name, - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] {type}:run');}}, 1);", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var dt = new DateTime(2025, 3, 5, 7, 9, 11); - await EvaluateOnCallFrameAndCheck(id, - (" d ", TNumber(401)), - ("d", TNumber(401)), - (" d", TNumber(401)), - ("e", TNumber(402)), - ("f", TNumber(403)), - - // property on a local - ("local_dt", TDateTime(dt)), - (" local_dt", TDateTime(dt)), - ("local_dt.Date", TDateTime(dt.Date)), - (" local_dt.Date", TDateTime(dt.Date))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateStaticLocalsWithDeepMemberAccess() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClass", "EvaluateLocals", 9, "DebuggerTests.EvaluateTestsClass.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var dt = new DateTime(2020, 1, 2, 3, 4, 5); - await EvaluateOnCallFrameAndCheck(id, - ("f_s.c", TNumber(4)), - ("f_s", TValueType("DebuggerTests.EvaluateTestsStructWithProperties")), - - ("f_s.dateTime", TDateTime(dt)), - ("f_s.dateTime.Date", TDateTime(dt.Date))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateLocalsAsync() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.Point", "AsyncInstanceMethod", 1, "DebuggerTests.Point.AsyncInstanceMethod", - "window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.ArrayTestsClass:EntryPointForStructMethod', true); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - // sc_arg - { - var (sc_arg, _) = await EvaluateOnCallFrame(id, "sc_arg"); - await CheckValue(sc_arg, TObject("DebuggerTests.SimpleClass"), nameof(sc_arg)); - - // Check that we did get the correct object - var sc_arg_props = await GetProperties(sc_arg["objectId"]?.Value()); - await CheckProps(sc_arg_props, new - { - X = TNumber(10), - Y = TNumber(45), - Id = TString("sc#Id"), - Color = TEnum("DebuggerTests.RGB", "Blue"), - PointWithCustomGetter = TGetter("PointWithCustomGetter") - }, "sc_arg_props#1"); - - await EvaluateOnCallFrameAndCheck(id, - ("(sc_arg.PointWithCustomGetter.X)", TNumber(100)), - ("sc_arg.Id + \"_foo\"", TString($"sc#Id_foo")), - ("sc_arg.Id + (sc_arg.X==10 ? \"_is_ten\" : \"_not_ten\")", TString($"sc#Id_is_ten"))); - } - - // local_gs - { - var (local_gs, _) = await EvaluateOnCallFrame(id, "local_gs"); - await CheckValue(local_gs, TValueType("DebuggerTests.SimpleGenericStruct"), nameof(local_gs)); - - (local_gs, _) = await EvaluateOnCallFrame(id, " local_gs"); - await CheckValue(local_gs, TValueType("DebuggerTests.SimpleGenericStruct"), nameof(local_gs)); - - var local_gs_props = await GetProperties(local_gs["objectId"]?.Value()); - await CheckProps(local_gs_props, new - { - Id = TObject("string", is_null: true), - Color = TEnum("DebuggerTests.RGB", "Red"), - Value = TNumber(0) - }, "local_gs_props#1"); - await EvaluateOnCallFrameAndCheck(id, ("(local_gs.Id)", TString(null))); - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(InstanceMethodForTypeMembersTestData), parameters: "DebuggerTests.EvaluateTestsStructWithProperties")] - [MemberData(nameof(InstanceMethodForTypeMembersTestData), parameters: "DebuggerTests.EvaluateTestsClassWithProperties")] - public async Task EvaluateExpressionsWithDeepMemberAccesses(string prefix, int bias, string type, string method, string bp_function_name, bool _) - => await CheckInspectLocalsAtBreakpointSite( - type, method, /*line_offset*/4, bp_function_name, - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] {type}:run');}}, 1);", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var dateTime = new DateTime(2010, 9, 8, 7, 6, 5 + bias); - var DTProp = dateTime.AddMinutes(10); - - await EvaluateOnCallFrameAndCheck(id, - ($"{prefix}a + 5", TNumber(9)), - ($"10 + {prefix}IntProp", TNumber(19)), - ($" {prefix}IntProp + {prefix}DTProp.Second", TNumber(9 + DTProp.Second)), - ($" {prefix}IntProp + ({prefix}DTProp.Second+{prefix}dateTime.Year)", TNumber(9 + DTProp.Second + dateTime.Year)), - ($" {prefix}DTProp.Second > 0 ? \"_foo_\": \"_zero_\"", TString("_foo_")), - - // local_dt is not live yet - ($"local_dt.Date.Year * 10", TNumber(10))); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("")] - [InlineData("this.")] - public async Task InheritedAndPrivateMembersInAClass(string prefix) - => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.GetPropertiesTests.DerivedClass", "InstanceMethod", 1, "DebuggerTests.GetPropertiesTests.DerivedClass.InstanceMethod", - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTests.GetPropertiesTests.DerivedClass:run');}}, 1);", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - foreach (var pad in new[] { String.Empty, " " }) - { - var padded_prefix = pad + prefix; - await EvaluateOnCallFrameAndCheck(id, - // overridden - ($"{padded_prefix}FirstName + \"_foo\"", TString("DerivedClass#FirstName_foo")), - ($"{padded_prefix}DateTimeForOverride.Date.Year", TNumber(2190)), - ($"{padded_prefix}DateTimeForOverride.Date.Year - 10", TNumber(2180)), - ($"\"foo_\" + {padded_prefix}StringPropertyForOverrideWithAutoProperty", TString("foo_DerivedClass#StringPropertyForOverrideWithAutoProperty")), - - // private - ($"{padded_prefix}_stringField + \"_foo\"", TString("DerivedClass#_stringField_foo")), - ($"{padded_prefix}_stringField", TString("DerivedClass#_stringField")), - ($"{padded_prefix}_dateTime.Second + 4", TNumber(7)), - ($"{padded_prefix}_DTProp.Second + 4", TNumber(13)), - - // inherited public - ($"\"foo_\" + {padded_prefix}Base_AutoStringProperty", TString("foo_base#Base_AutoStringProperty")), - // inherited private - ($"{padded_prefix}_base_dateTime.Date.Year - 10", TNumber(2124)) - ); - } - }); - - [Fact] - public async Task EvaluateSimpleExpressions() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - // "((this))", TObject("foo")); //FIXME: - // "((dt))", TObject("foo")); //FIXME: - - ("this", TObject("DebuggerTests.EvaluateTestsClass.TestEvaluate")), - (" this", TObject("DebuggerTests.EvaluateTestsClass.TestEvaluate")), - - ("5", TNumber(5)), - (" 5", TNumber(5)), - ("d + e", TNumber(203)), - ("e + 10", TNumber(112)), - - // repeated expressions - ("this.a + this.a", TNumber(2)), - ("a + \"_\" + a", TString("9000_9000")), - ("a+(a )", TString("90009000")), - - // possible duplicate arg name - ("this.a + this_a", TNumber(46)), - - ("this.a + this.b", TNumber(3)), - ("\"test\" + \"test\"", TString("testtest")), - ("5 + 5", TNumber(10))); - }); - - public static TheoryData ShadowMethodArgsTestData => new TheoryData - { - { "DebuggerTests.EvaluateTestsClassWithProperties", "EvaluateShadow", "DebuggerTests.EvaluateTestsClassWithProperties.EvaluateShadow" }, - { "DebuggerTests.EvaluateTestsClassWithProperties", "EvaluateShadowAsync", "DebuggerTests.EvaluateTestsClassWithProperties.EvaluateShadowAsync" }, - { "DebuggerTests.EvaluateTestsStructWithProperties", "EvaluateShadow", "DebuggerTests.EvaluateTestsStructWithProperties.EvaluateShadow" }, - { "DebuggerTests.EvaluateTestsStructWithProperties", "EvaluateShadowAsync", "DebuggerTests.EvaluateTestsStructWithProperties.EvaluateShadowAsync" }, - }; - - [Theory] - [MemberData(nameof(ShadowMethodArgsTestData))] - public async Task LocalsAndArgsShadowingThisMembers(string type_name, string method, string bp_function_name) => await CheckInspectLocalsAtBreakpointSite( - type_name, method, 2, bp_function_name, - "window.setTimeout(function() { invoke_static_method ('[debugger-test] " + type_name + ":run'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("a", TString("hello")), - ("this.a", TNumber(4))); - - await CheckExpressions("this.", new DateTime(2010, 9, 8, 7, 6, 5 + 0)); - await CheckExpressions(String.Empty, new DateTime(2020, 3, 4, 5, 6, 7)); - - async Task CheckExpressions(string prefix, DateTime dateTime) - { - await EvaluateOnCallFrameAndCheck(id, - (prefix + "dateTime", TDateTime(dateTime)), - (prefix + "dateTime.TimeOfDay.Minutes", TNumber(dateTime.TimeOfDay.Minutes)), - (prefix + "dateTime.TimeOfDay", TValueType("System.TimeSpan", dateTime.TimeOfDay.ToString()))); - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("DebuggerTests.EvaluateTestsStructWithProperties", true)] - [InlineData("DebuggerTests.EvaluateTestsClassWithProperties", false)] - public async Task EvaluateOnPreviousFrames(string type_name, bool is_valuetype) => await CheckInspectLocalsAtBreakpointSite( - type_name, "EvaluateShadow", 1, $"{type_name}.EvaluateShadow", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] {type_name}:run'); }})", - wait_for_event_fn: async (pause_location) => - { - var dt_local = new DateTime(2020, 3, 4, 5, 6, 7); - var dt_this = new DateTime(2010, 9, 8, 7, 6, 5); - - // At EvaluateShadow - { - var id0 = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id0, - ("dateTime", TDateTime(dt_local)), - ("this.dateTime", TDateTime(dt_this)) - ); - - await EvaluateOnCallFrameFail(id0, ("obj.IntProp", "ReferenceError")); - } - - { - var id1 = pause_location["callFrames"][1]["callFrameId"].Value(); - await EvaluateOnCallFrameFail(id1, - ("dateTime", "ReferenceError"), - ("this.dateTime", "ReferenceError")); - - // obj available only on the -1 frame - await EvaluateOnCallFrameAndCheck(id1, ("obj.IntProp", TNumber(7))); - } - - await SetBreakpointInMethod("debugger-test.dll", type_name, "SomeMethod", 1); - pause_location = await SendCommandAndCheck(null, "Debugger.resume", null, 0, 0, $"{type_name}.SomeMethod"); - - // At SomeMethod - - // TODO: change types also.. so, that `this` is different! - - // Check frame0 - { - var id0 = pause_location["callFrames"][0]["callFrameId"].Value(); - - // 'me' and 'dateTime' are reversed in this method - await EvaluateOnCallFrameAndCheck(id0, - ("dateTime", is_valuetype ? TValueType(type_name) : TObject(type_name)), - ("this.dateTime", TDateTime(dt_this)), - ("me", TDateTime(dt_local)), - - // local variable shadows field, but isn't "live" yet - ("DTProp", TString(null)), - - // access field via `this.` - ("this.DTProp", TDateTime(dt_this.AddMinutes(10)))); - - await EvaluateOnCallFrameFail(id0, ("obj", "ReferenceError")); - } - - // check frame1 - { - var id1 = pause_location["callFrames"][1]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id1, - // 'me' and 'dateTime' are reversed in this method - ("dateTime", TDateTime(dt_local)), - ("this.dateTime", TDateTime(dt_this)), - ("me", is_valuetype ? TValueType(type_name) : TObject(type_name)), - - // not shadowed here - ("DTProp", TDateTime(dt_this.AddMinutes(10))), - - // access field via `this.` - ("this.DTProp", TDateTime(dt_this.AddMinutes(10)))); - - await EvaluateOnCallFrameFail(id1, ("obj", "ReferenceError")); - } - - // check frame2 - { - var id2 = pause_location["callFrames"][2]["callFrameId"].Value(); - - // Only obj should be available - await EvaluateOnCallFrameFail(id2, - ("dateTime", "ReferenceError"), - ("this.dateTime", "ReferenceError"), - ("me", "ReferenceError")); - - await EvaluateOnCallFrameAndCheck(id2, ("obj", is_valuetype ? TValueType(type_name) : TObject(type_name))); - } - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task JSEvaluate() - { - var bp_loc = "/other.js"; - var line = 78; - var col = 1; - - await SetBreakpoint(bp_loc, line, col); - - var eval_expr = "window.setTimeout(function() { eval_call_on_frame_test (); }, 1)"; - var result = await cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), token); - var pause_location = await insp.WaitFor(Inspector.PAUSE); - - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameFail(id, - ("me.foo", null), - ("obj.foo.bar", null)); - - await EvaluateOnCallFrame(id, "obj.foo", expect_ok: true); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task NegativeTestsInInstanceMethod() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - // Use '.' on a primitive member - await EvaluateOnCallFrameFail(id, - //BUG: TODO: - //("a)", "CompilationError"), - - ("this.a.", "ReferenceError"), - ("a.", "ReferenceError"), - - ("this..a", "CompilationError"), - (".a.", "ReferenceError"), - - ("me.foo", "ReferenceError"), - - ("this.a + non_existent", "ReferenceError"), - - ("this.NullIfAIsNotZero.foo", "ReferenceError"), - ("NullIfAIsNotZero.foo", "ReferenceError")); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task NegativeTestsInStaticMethod() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClass", "EvaluateLocals", 9, "DebuggerTests.EvaluateTestsClass.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateTestsClass:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameFail(id, - ("me.foo", "ReferenceError"), - ("this", "CompilationError"), - ("this.NullIfAIsNotZero.foo", "ReferenceError")); - }); - - [Fact] - public async Task EvaluatePropertyThatThrows() - => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateTestsClassWithProperties", "InstanceMethod", /*line_offset*/1, "DebuggerTests.EvaluateTestsClassWithProperties.InstanceMethod", - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTests.EvaluateTestsClassWithProperties:run');}}, 1);", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, ("this.PropertyThrowException", TString("System.Exception: error"))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateSimpleMethodCallsError() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var (_, res) = await EvaluateOnCallFrame(id, "this.objToTest.MyMethodWrong()", expect_ok: false ); - Assert.Equal( - $"Method 'MyMethodWrong' not found in type 'DebuggerTests.EvaluateMethodTestsClass.ParmToTest'", - res.Error["result"]?["description"]?.Value()); - - (_, res) = await EvaluateOnCallFrame(id, "this.objToTest.MyMethod(1)", expect_ok: false); - Assert.Equal( - "Unable to evaluate method 'MyMethod'. Too many arguments passed.", - res.Error["result"]?["description"]?.Value()); - - (_, res) = await EvaluateOnCallFrame(id, "this.CallMethodWithParm(\"1\")", expect_ok: false ); - Assert.Contains("No implementation of method 'CallMethodWithParm' matching 'this.CallMethodWithParm(\"1\")' found in type DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.", res.Error["result"]?["description"]?.Value()); - - (_, res) = await EvaluateOnCallFrame(id, "this.ParmToTestObjNull.MyMethod()", expect_ok: false ); - Assert.Equal("Expression 'this.ParmToTestObjNull.MyMethod' evaluated to null", res.Error["result"]?["description"]?.Value()); - var exceptionDetailsStack = res.Error["exceptionDetails"]?["stackTrace"]?["callFrames"]?[0]; - Assert.Equal("DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", exceptionDetailsStack?["functionName"]?.Value()); - Assert.Equal(358, exceptionDetailsStack?["lineNumber"]?.Value()); - Assert.Equal(16, exceptionDetailsStack?["columnNumber"]?.Value());; - - (_, res) = await EvaluateOnCallFrame(id, "this.ParmToTestObjException.MyMethod()", expect_ok: false ); - Assert.Equal("Method 'MyMethod' not found in type 'string'", res.Error["result"]?["description"]?.Value()); - }); - - [Fact] - public async Task EvaluateSimpleMethodCallsWithoutParms() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("this.CallMethod()", TNumber(1)), - ("this.CallMethod()", TNumber(1)), - ("this.CallMethodReturningChar()", TChar('A')), - ("this.ParmToTestObj.MyMethod()", TString("methodOK")), - ("this.ParmToTestObj.ToString()", TString("DebuggerTests.EvaluateMethodTestsClass+ParmToTest")), - ("this.objToTest.MyMethod()", TString("methodOK"))); - }); - - - [Fact] - public async Task EvaluateSimpleMethodCallsWithConstParms() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("this.CallMethodWithParm(10)", TNumber(11)), - ("this.CallMethodWithMultipleParms(10, 10)", TNumber(21)), - ("this.CallMethodWithParmBool(true)", TString("TRUE")), - ("this.CallMethodWithParmBool(false)", TString("FALSE")), - ("this.CallMethodWithParmString(\"concat\")", TString("str_const_concat")), - ("this.CallMethodWithParmString(\"\\\"\\\"\")", TString("str_const_\"\"")), - ("this.CallMethodWithParmString(\"\uD83D\uDEF6\")", TString("str_const_\uD83D\uDEF6")), - ("this.CallMethodWithParmString(\"\\uD83D\\uDEF6\")", TString("str_const_\uD83D\uDEF6")), - ("this.CallMethodWithParmString(\"\uD83D\uDE80\")", TString("str_const_\uD83D\uDE80")), - ("this.CallMethodWithParmString_\u03BB(\"\uD83D\uDE80\")", TString("\u03BB_\uD83D\uDE80")), - ("this.CallMethodWithParm(10) + this.a", TNumber(12)), - ("this.CallMethodWithObj(null)", TNumber(-1)), - ("this.CallMethodWithChar('a')", TString("str_const_a"))); - }); - - [Fact] - public async Task EvaluateSimpleMethodCallsWithVariableParms() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("this.CallMethodWithParm(this.a)", TNumber(2)), - ("this.CallMethodWithMultipleParms(this.a, 10)", TNumber(12)), - ("this.CallMethodWithParmString(this.str)", TString("str_const_str_const_")), - ("this.CallMethodWithParmBool(this.t)", TString("TRUE")), - ("this.CallMethodWithParmBool(this.f)", TString("FALSE")), - ("this.CallMethodWithParm(this.a) + this.a", TNumber(3)), - ("this.CallMethodWithObj(this.objToTest)", TNumber(10))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateIndexingNegative() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var (_, res) = await EvaluateOnCallFrame(id, "cc.idx0[2]", expect_ok: false ); - Assert.Equal("Unable to evaluate element access 'cc.idx0[2]': Cannot apply indexing with [] to a primitive object of type 'number'", res.Error["result"]?["description"]?.Value()); - var exceptionDetailsStack = res.Error["exceptionDetails"]?["stackTrace"]?["callFrames"]?[0]; - Assert.Equal("DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", exceptionDetailsStack?["functionName"]?.Value()); - Assert.Equal(576, exceptionDetailsStack?["lineNumber"]?.Value()); - Assert.Equal(12, exceptionDetailsStack?["columnNumber"]?.Value()); - (_, res) = await EvaluateOnCallFrame(id, "c[1]", expect_ok: false ); - Assert.Equal( "Unable to evaluate element access 'c[1]': Cannot apply indexing with [] to an object of type 'DebuggerTests.EvaluateLocalsWithIndexingTests.ClassWithIndexers'", res.Error["result"]?["description"]?.Value()); - }); - - [Fact] - public async Task EvaluateIndexingsByConstant() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("cc.numList[0]", TNumber(1)), - ("cc.textList[1]", TString("2")), - ("cc.numArray[1]", TNumber(2)), - ("cc.textArray[0]", TString("1"))); - }); - - [Fact] - public async Task EvaluateIndexingByLocalVariable() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("cc.numList[i]", TNumber(1)), - ("cc.textList[j]", TString("2")), - ("cc.numArray[j]", TNumber(2)), - ("cc.textArray[i]", TString("1"))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateObjectIndexingByNonIntConst() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("c[\"longstring\"]", TBool(true)), // class - ("c[\"-\"]", TBool(false)), - ("c[\'-\']", TString("res_-")), - ("c[true]", TString("True")), - ("c[1.23]", TNumber(1)), - ("s[\"longstring\"]", TBool(true)), // struct - ("s[\"-\"]", TBool(false)), - ("s[\'-\']", TString("res_-")), - ("s[true]", TString("True")), - ("s[1.23]", TNumber(1)), - ("cc.indexedByStr[\"1\"]", TBool(true)), - ("cc.indexedByStr[\"111\"]", TBool(false)), - ("cc.indexedByStr[\"true\"]", TBool(true)), - ("cc.indexedByChar[\'i\']", TString("I")), - ("cc.indexedByChar[\'5\']", TString("5")), - ("cc.indexedByBool[true]", TString("TRUE")), - ("cc.indexedByBool[false]", TString("FALSE")) - ); - var (_, res) = await EvaluateOnCallFrame(id,"cc.indexedByStr[\"invalid\"]", expect_ok: false); - Assert.True(res.Error["result"]?["description"]?.Value().StartsWith("Cannot evaluate '(cc.indexedByStr[\"invalid\"]", StringComparison.Ordinal)); - (_, res) = await EvaluateOnCallFrame(id,"cc.indexedByStr[null]", expect_ok: false); - Assert.True(res.Error["result"]?["description"]?.Value().StartsWith("Cannot evaluate '(cc.indexedByStr[null]", StringComparison.Ordinal)); - }); - - [Fact] - public async Task EvaluateObjectByNonIntLocals() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 15, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("c[longString]", TBool(true)), - ("c[aBool]", TString("True")), - ("c[aChar]", TString("res_9")), - ("c[shortString]", TBool(false)), - ("c[aFloat]", TNumber(1)), - ("c[aDouble]", TNumber(2)), - ("c[aDecimal]", TNumber(3)), - ("c[arr]", TChar('t')), - ("c[objIdx]", TNumber(123)), - ("s[longString]", TBool(true)), - ("s[aBool]", TString("True")), - ("s[aChar]", TString("res_9")), - ("s[shortString]", TBool(false)), - ("s[aFloat]", TNumber(1)), - ("s[aDouble]", TNumber(2)), - ("s[aDecimal]", TNumber(3)), - ("s[arr]", TChar('t')), - ("s[objIdx]", TNumber(123)) - ); - }); - - [Fact] - public async Task EvaluateNestedObjectIndexingByNonIntLocals() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 12, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("c[cc.textArray[0]]", TBool(false)), // c["1"] - ("c[cc.textArray[j]]", TBool(false)), // c["2"] - ("s[cc.textArray[0]]", TBool(false)), // s["1"] - ("s[cc.textArray[j]]", TBool(false)) // s["2"] - ); - }); - - // ToDo: https://github.com/dotnet/runtime/issues/76015 - [Fact] - public async Task EvaluateIndexingByExpression() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("cc.numList[i + 1]", TNumber(2)), - ("cc.textList[(2 * j) - 1]", TString("2")), - ("cc.textList[j - 1]", TString("1")), - ("cc.numArray[cc.numList[j - 1]]", TNumber(2)) - ); - }); - - [Fact] - public async Task EvaluateIndexingByExpressionMultidimensional() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests", "EvaluateLocals", 5, "DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("f.numArray2D[0, j - 1]", TNumber(1)), // 0, 0 - ("f.numArray2D[f.idx1, i + j]", TNumber(4)), // 1, 1 - ("f.numArray2D[(f.idx1 - j) * 5, i + j]", TNumber(2)), // 0, 1 - ("f.numArray2D[i + j, f.idx1 - 1]", TNumber(3)) // 1, 0 - ); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateIndexingByExpressionNegative() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - // indexing with expression of a wrong type - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var (_, res) = await EvaluateOnCallFrame(id, "cc.numList[\"a\" + 1]", expect_ok: false ); - Assert.Equal("Unable to evaluate element access 'cc.numList[\"a\" + 1]': Cannot index with an object of type 'string'", res.Error["result"]?["description"]?.Value()); - var exceptionDetailsStack = res.Error["exceptionDetails"]?["stackTrace"]?["callFrames"]?[0]; - Assert.Equal("DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", exceptionDetailsStack?["functionName"]?.Value()); - Assert.Equal(576, exceptionDetailsStack?["lineNumber"]?.Value()); - Assert.Equal(12, exceptionDetailsStack?["columnNumber"]?.Value()); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateIndexingByExpressionContainingUnknownIdentifier() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); 1 }})", - wait_for_event_fn: async (pause_location) => - { - // indexing with expression of a wrong type - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var (_, res) = await EvaluateOnCallFrame(id, "cc.numList[\"a\" + x]", expect_ok: false); - Assert.Equal("The name x does not exist in the current context", res.Error["result"]?["description"]?.Value()); - }); - - [Fact] - public async Task EvaluateIndexingByMemberVariables() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("cc.idx0", TNumber(0)), - ("cc.idx1", TNumber(1)), - ("cc.numList[cc.idx0]", TNumber(1)), - ("cc.textList[cc.idx1]", TString("2")), - ("cc.numArray[cc.idx1]", TNumber(2)), - ("cc.textArray[cc.idx0]", TString("1"))); - }); - - [Fact] - public async Task EvaluateIndexingNested() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("cc.idx0", TNumber(0)), - ("cc.numList[cc.numList[cc.idx0]]", TNumber(2)), - ("cc.textList[cc.numList[cc.idx0]]", TString("2")), - ("cc.numArray[cc.numArray[cc.idx0]]", TNumber(2)), - ("cc.textArray[cc.numArray[cc.idx0]]", TString("2"))); - - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateIndexingMultidimensional() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests", "EvaluateLocals", 5, "DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithMultidimensionalIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("j", TNumber(1)), - ("f.idx1", TNumber(1)), - ("f.numArray2D[0, 0]", TNumber(1)), - ("f.numArray2D[0, 1]", TNumber(2)), - ("f.numArray2D[1, 0]", TNumber(3)), - ("f.numArray2D[1 ,1]", TNumber(4)), - ("f.numArray3D[0, 0, 0]", TNumber(1)), - ("f.numArray3D[0 ,0 ,1]", TNumber(2)), - ("f.numArray3D[0 ,0, 2]", TNumber(3)), - ("f.numArray3D[1, 1, 0]", TNumber(10)), - ("f.numArray3D[1, 1, 1]", TNumber(11)), - ("f.numArray3D[1 , 1, 2]", TNumber(12)), - ("f.numArray2D[0,0]", TNumber(1)), - ("f.numArray2D[0,1]", TNumber(2)), - ("f.numArray2D[1,0]", TNumber(3)), - ("f.numArray2D[1,1]", TNumber(4)), - ("f.numArray3D[0,0,0]", TNumber(1)), - ("f.numArray3D[0,0,1]", TNumber(2)), - ("f.numArray3D[0,0,2]", TNumber(3)), - ("f.numArray3D[1,1,0]", TNumber(10)), - ("f.numArray3D[1,1,1]", TNumber(11)), - ("f.numArray3D[1,1,2]", TNumber(12)), - ("f.textArray2D[0,0]", TString("one")), - ("f.textArray2D[0,1]", TString("two")), - ("f.textArray2D[1,0]", TString("three")), - ("f.textArray2D[1,1]", TString("four")), - ("f.numArray2D[i,i]", TNumber(1)), - ("f.numArray2D[i,j]", TNumber(2)), - ("f.numArray2D[j,i]", TNumber(3)), - ("f.numArray2D[j,j]", TNumber(4)), - ("f.numArray3D[i,i,i]", TNumber(1)), - ("f.numArray3D[i,i,j]", TNumber(2)), - ("f.numArray3D[i,i,2]", TNumber(3)), - ("f.numArray3D[j,j,i]", TNumber(10)), - ("f.numArray3D[j,j,1]", TNumber(11)), - ("f.numArray3D[j,j,2]", TNumber(12)), - ("f.textArray2D[i,i]", TString("one")), - ("f.textArray2D[i,j]", TString("two")), - ("f.textArray2D[j,i]", TString("three")), - ("f.textArray2D[j,j]", TString("four")), - ("f.numArray2D[f.idx0,f.idx0]", TNumber(1)), - ("f.numArray2D[f.idx0,f.idx1]", TNumber(2)), - ("f.numArray2D[f.idx1,f.idx0]", TNumber(3)), - ("f.numArray2D[f.idx1,f.idx1]", TNumber(4)), - ("f.numArray3D[f.idx0,f.idx0,f.idx0]", TNumber(1)), - ("f.numArray3D[f.idx0,f.idx0,f.idx1]", TNumber(2)), - ("f.numArray3D[f.idx0,f.idx0,2]", TNumber(3)), - ("f.numArray3D[f.idx1,f.idx1,f.idx0]", TNumber(10)), - ("f.numArray3D[f.idx1,f.idx1,f.idx1]", TNumber(11)), - ("f.numArray3D[f.idx1,f.idx1,2]", TNumber(12)), - ("f.textArray2D[f.idx0,f.idx0]", TString("one")), - ("f.textArray2D[f.idx0,f.idx1]", TString("two")), - ("f.textArray2D[f.idx1,f.idx0]", TString("three")), - ("f.textArray2D[f.idx1,f.idx1]", TString("four"))); - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateIndexingJagged() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateLocalsWithIndexingTests", "EvaluateLocals", 6, "DebuggerTests.EvaluateLocalsWithIndexingTests.EvaluateLocals", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateLocalsWithIndexingTests:EvaluateLocals'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - await EvaluateOnCallFrameAndCheck(id, - ("j", TNumber(1)), - ("cc.idx1", TNumber(1)), - ("cc.numArrayOfArrays[1][1]", TNumber(2)), - ("cc.numArrayOfArrays[j][j]", TNumber(2)), - ("cc.numArrayOfArrays[cc.idx1][cc.idx1]", TNumber(2)), - ("cc.numListOfLists[1][1]", TNumber(2)), - ("cc.numListOfLists[j][j]", TNumber(2)), - ("cc.numListOfLists[cc.idx1][cc.idx1]", TNumber(2)), - ("cc.textArrayOfArrays[1][1]", TString("2")), - ("cc.textArrayOfArrays[j][j]", TString("2")), - ("cc.textArrayOfArrays[cc.idx1][cc.idx1]", TString("2")), - ("cc.textListOfLists[1][1]", TString("2")), - ("cc.textListOfLists[j][j]", TString("2")), - ("cc.textListOfLists[cc.idx1][cc.idx1]", TString("2")), - ("cc.numArrayOfArrays[cc.numArray[cc.numList[1]]][cc.numList[0]]", TNumber(2)) - ); - - }); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task EvaluateSimpleMethodCallsCheckChangedValue() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate", "run", 9, "DebuggerTests.EvaluateMethodTestsClass.TestEvaluate.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.EvaluateMethodTestsClass:EvaluateMethods'); })", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - - var frame = pause_location["callFrames"][0]; - var props = await GetObjectOnFrame(frame, "this"); - CheckNumber(props, "a", 1); - - await EvaluateOnCallFrameAndCheck(id, - ("this.CallMethodChangeValue()", TObject("object", is_null : true))); - - frame = pause_location["callFrames"][0]; - props = await GetObjectOnFrame(frame, "this"); - CheckNumber(props, "a", 11); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(true)] - [InlineData(false)] - public async Task EvaluateMethodWithBPWhilePausedInADifferentMethodAndNotHit(bool setBreakpointBeforePause) - { - await cli.SendCommand("DotnetDebugger.setEvaluationOptions", JObject.FromObject(new { options = new { noFuncEval = false } }), token); - var waitForScript = WaitForConsoleMessage("console.warning: MONO_WASM: Adding an id (0) that already exists in commands_received"); - if (setBreakpointBeforePause) - await SetBreakpointInMethod("debugger-test.dll", "TestEvaluateDontPauseOnBreakpoint", "MyMethod2", 1); - await CheckInspectLocalsAtBreakpointSite( - "TestEvaluateDontPauseOnBreakpoint", "run", 3, "TestEvaluateDontPauseOnBreakpoint.run", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] TestEvaluateDontPauseOnBreakpoint:run'); })", - wait_for_event_fn: async (pause_location) => - { - if (!setBreakpointBeforePause) - await SetBreakpointInMethod("debugger-test.dll", "TestEvaluateDontPauseOnBreakpoint", "MyMethod2", 1); - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("myVar.MyMethod2()", TString("Object 11")), - ("myVar.MyMethod3()", TString("Object 11")), - ("myVar.MyCount", TString("Object 11")), - ("myVar.MyMethod()", TString("Object 10")), - ("myVar", TObject("TestEvaluateDontPauseOnBreakpoint", description: "Object 11"))); - var props = await GetObjectOnFrame(pause_location["callFrames"][0], "myVar"); - await CheckString(props, "MyCount", "Object 11"); - }); - await SendCommandAndCheck(null, "Debugger.resume", null, 0, 0, "TestEvaluateDontPauseOnBreakpoint.MyMethod2"); - await SendCommandAndCheck(null, "Debugger.resume", null, 0, 0, "TestEvaluateDontPauseOnBreakpoint.MyMethod"); - Assert.False(waitForScript.IsCompleted); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs deleted file mode 100644 index f20d7d08349ea1..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/ExceptionTests.cs +++ /dev/null @@ -1,375 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using System.Threading; -using Xunit; -using Xunit.Sdk; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - - public class ExceptionTests : DebuggerTests - { - public ExceptionTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task ExceptionTestAll() - { - string entry_method_name = "[debugger-test] DebuggerTests.ExceptionTestsClass:TestExceptions"; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-exception-test.cs"; - - await SetPauseOnException("all"); - - var eval_expr = "window.setTimeout(function() { invoke_static_method_native (" + - $"'{entry_method_name}'" + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, null, 0, 0, null); - //stop in the managed caught exception - pause_location = await WaitForManagedException(pause_location); - - AssertEqual("DebuggerTests.ExceptionTestsClass.TestCaughtException.run", pause_location["callFrames"]?[0]?["functionName"]?.Value(), "pause0"); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "DebuggerTests.CustomException", - uncaught = false - }), "exception0.data"); - - var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - await CheckString(exception_members, "message", "not implemented caught"); - - pause_location = await WaitForManagedException(null); - AssertEqual("DebuggerTests.ExceptionTestsClass.TestUncaughtException.run", pause_location["callFrames"]?[0]?["functionName"]?.Value(), "pause1"); - - //stop in the uncaught exception - CheckLocation(debugger_test_loc, 28, 16, scripts, pause_location["callFrames"][0]["location"]); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "DebuggerTests.CustomException", - uncaught = true - }), "exception1.data"); - - exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - await CheckString(exception_members, "message", "not implemented uncaught"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task JSExceptionTestAll() - { - await SetPauseOnException("all"); - - var eval_expr = "window.setTimeout(function () { exceptions_test (); }, 1)"; - var pause_location = await EvaluateAndCheck(eval_expr, null, 0, 0, null); - pause_location = await WaitForJSException(pause_location, "exception_caught_test"); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "TypeError", - uncaught = false - }), "exception0.data"); - - var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - await CheckString(exception_members, "message", "exception caught"); - - pause_location = await SendCommandAndCheck(null, "Debugger.resume", null, 0, 0, null); - pause_location = await WaitForJSException(pause_location, "exception_uncaught_test"); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "RangeError", - uncaught = true - }), "exception1.data"); - - exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - await CheckString(exception_members, "message", "exception uncaught"); - - async Task WaitForJSException(JObject pause_location, string exp_fn_name) - { - while (true) - { - if (pause_location != null) - { - AssertEqual("exception", pause_location["reason"]?.Value(), $"Expected to only pause because of an exception. {pause_location}"); - - string actual_fn_name = pause_location["callFrames"]?[0]?["functionName"]?.Value(); - - // return if we hit a managed exception, or an uncaught one - if (pause_location["data"]?["objectId"]?.Value()?.StartsWith("dotnet:object:", StringComparison.Ordinal) == true) - { - _testOutput.WriteLine($"Hit an unexpected managed exception, with function name: {actual_fn_name}. {pause_location}"); - throw new XunitException($"Hit an unexpected managed exception, with function name: {actual_fn_name}"); - } - - if (pause_location["data"]?["uncaught"]?.Value() == true) - break; - - if (actual_fn_name == exp_fn_name) - break; - } - - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null); - } - - return pause_location; - } - } - - // FIXME? BUG? We seem to get the stack trace for Runtime.exceptionThrown at `call_method`, - // but JS shows the original error type, and original trace - [ConditionalFact(nameof(RunningOnChrome))] - public async Task ExceptionTestNone() - { - //Collect events - string entry_method_name = "[debugger-test] DebuggerTests.ExceptionTestsClass:TestExceptions"; - await SetPauseOnException("none"); - - var eval_expr = "window.setTimeout(function() { invoke_static_method (" + - $"'{entry_method_name}'" + - "); }, 1);"; - - try - { - await EvaluateAndCheck(eval_expr, null, 0, 0, "", null, null); - } - catch (ArgumentException ae) - { - var eo = JObject.Parse(ae.Message); - - // AssertEqual (line, eo ["exceptionDetails"]?["lineNumber"]?.Value (), "lineNumber"); - AssertEqual("Uncaught", eo["exceptionDetails"]?["text"]?.Value(), "text"); - - await CheckValue(eo["exceptionDetails"]?["exception"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "ManagedError" // BUG?: "DebuggerTests.CustomException" - }), "exception"); - - return; - } - - Assert.True(false, "Expected to get an ArgumentException from the uncaught user exception"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task JSExceptionTestNone() - { - await SetPauseOnException("none"); - - var eval_expr = "window.setTimeout(function () { exceptions_test (); }, 1)"; - - int line = 46; - try - { - await EvaluateAndCheck(eval_expr, null, 0, 0, "", null, null); - } - catch (ArgumentException ae) - { - _testOutput.WriteLine($"{ae}"); - var eo = JObject.Parse(ae.Message); - - AssertEqual(line, eo["exceptionDetails"]?["lineNumber"]?.Value(), "lineNumber"); - AssertEqual("Uncaught", eo["exceptionDetails"]?["text"]?.Value(), "text"); - - await CheckValue(eo["exceptionDetails"]?["exception"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "RangeError" - }), "exception"); - - return; - } - - Assert.True(false, "Expected to get an ArgumentException from the uncaught user exception"); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("function () { exceptions_test (); }", null, 0, 0, "exception_uncaught_test", "RangeError", "exception uncaught")] - [InlineData("function () { invoke_static_method_native ('[debugger-test] DebuggerTests.ExceptionTestsClass:TestExceptions'); }", - "dotnet://debugger-test.dll/debugger-exception-test.cs", 28, 16, "DebuggerTests.ExceptionTestsClass.TestUncaughtException.run", - "DebuggerTests.CustomException", "not implemented uncaught")] - public async Task ExceptionTestUncaught(string eval_fn, string loc, int line, int col, string fn_name, - string exception_type, string exception_message) - { - await SetPauseOnException("uncaught"); - - var eval_expr = $"window.setTimeout({eval_fn}, 1);"; - var pause_location = await EvaluateAndCheck(eval_expr, loc, line, col, fn_name); - - Assert.Equal("exception", pause_location["reason"]); - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = exception_type, - uncaught = true - }), "exception.data"); - - var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - await CheckString(exception_members, "message", exception_message); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task ExceptionTestUncaughtWithReload() - { - string entry_method_name = "[debugger-test] DebuggerTests.ExceptionTestsClass:TestExceptions"; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-exception-test.cs"; - - await SetPauseOnException("uncaught"); - - await SendCommand("Page.enable", null); - await SendCommand("Page.reload", JObject.FromObject(new - { - ignoreCache = true - })); - await insp.WaitFor(Inspector.APP_READY); - - var eval_expr = "window.setTimeout(function() { invoke_static_method_native (" + - $"'{entry_method_name}'" + - "); }, 1);"; - - var pause_location = await EvaluateAndCheck(eval_expr, null, 0, 0, null); - //stop in the managed caught exception - pause_location = await WaitForManagedException(pause_location); - - AssertEqual("DebuggerTests.ExceptionTestsClass.TestUncaughtException.run", pause_location["callFrames"]?[0]?["functionName"]?.Value(), "pause1"); - - //stop in the uncaught exception - CheckLocation(debugger_test_loc, 28, 16, scripts, pause_location["callFrames"][0]["location"]); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "DebuggerTests.CustomException", - uncaught = true - }), "exception1.data"); - - var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - await CheckString(exception_members, "message", "not implemented uncaught"); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("[debugger-test] DebuggerTests.ExceptionTestsClassDefault:TestExceptions", "System.Exception", 76, "DebuggerTests.ExceptionTestsClassDefault")] - [InlineData("[debugger-test] DebuggerTests.ExceptionTestsClass:TestExceptions", "DebuggerTests.CustomException", 28, "DebuggerTests.ExceptionTestsClass")] - public async Task ExceptionTestAllWithReload(string entry_method_name, string class_name, int line_number, string class_name_pause) - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-exception-test.cs"; - - await SetPauseOnException("all"); - - await SendCommand("Page.enable", null); - var pause_location = await SendCommandAndCheck(JObject.FromObject(new - { - ignoreCache = true - }), "Page.reload", null, 0, 0, null); - - // Hit resume to skip - int count = 0; - var taskWait = insp.WaitFor(Inspector.APP_READY); - while (true) - { - await cli.SendCommand("Debugger.resume", null, token); - count++; - - try - { - await insp.WaitFor(Inspector.PAUSE) - .WaitAsync(TimeSpan.FromSeconds(10)); - } - catch (TimeoutException) - { - // timed out waiting for a PAUSE - insp.ClearWaiterFor(Inspector.PAUSE); - break; - } - } - await taskWait; - _testOutput.WriteLine ($"* Resumed {count} times"); - - var eval_expr = "window.setTimeout(function() { invoke_static_method_native (" + - $"'{entry_method_name}'" + - "); }, 1);"; - - pause_location = await EvaluateAndCheck(eval_expr, null, 0, 0, null); - //stop in the managed caught exception - pause_location = await WaitForManagedException(pause_location); - - AssertEqual($"{class_name_pause}.TestCaughtException.run", pause_location["callFrames"]?[0]?["functionName"]?.Value(), "pause0"); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = class_name, - uncaught = false, - description = "not implemented caught" - }), "exception0.data"); - - var exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - var ptd = JObject.FromObject(new { value = new { objectId = pause_location["data"]["objectId"]?.Value() } }); - var res = await InvokeGetter(ptd, "Message"); - await CheckValue(res.Value["result"], JObject.FromObject(new { type = "string", value = $"not implemented caught" }), "exception0.message"); - - - pause_location = await WaitForManagedException(null); - AssertEqual($"{class_name_pause}.TestUncaughtException.run", pause_location["callFrames"]?[0]?["functionName"]?.Value(), "pause1"); - - //stop in the uncaught exception - CheckLocation(debugger_test_loc, line_number, 16, scripts, pause_location["callFrames"][0]["location"]); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = class_name, - uncaught = true, - description = "not implemented uncaught" - }), "exception1.data"); - - exception_members = await GetProperties(pause_location["data"]["objectId"]?.Value()); - ptd = JObject.FromObject(new { value = new { objectId = pause_location["data"]["objectId"]?.Value() } }); - res = await InvokeGetter(ptd, "Message"); - await CheckValue(res.Value["result"], JObject.FromObject(new { type = "string", value = $"not implemented uncaught" }), "exception1.message"); - } - - - async Task WaitForManagedException(JObject pause_location) - { - while (true) - { - if (pause_location != null) - { - AssertEqual("exception", pause_location["reason"]?.Value(), $"Expected to only pause because of an exception. {pause_location}"); - - // return in case of a managed exception, and ignore JS ones - if (pause_location["data"]?["objectId"]?.Value()?.StartsWith("dotnet:object:", StringComparison.Ordinal) == true || - pause_location["data"]?["uncaught"]?.Value() == true) - { - break; - } - } - - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null); - } - - return pause_location; - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/FirefoxInspectorClient.cs b/src/mono/browser/debugger/DebuggerTestSuite/FirefoxInspectorClient.cs deleted file mode 100644 index 4cb831d6e3878e..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/FirefoxInspectorClient.cs +++ /dev/null @@ -1,270 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; -using Microsoft.WebAssembly.Diagnostics; -using System; -using System.Net.WebSockets; -using System.Net.Sockets; -using System.Net; - -#nullable enable - -namespace DebuggerTests; - -class FirefoxInspectorClient : InspectorClient -{ - internal string? BreakpointActorId {get; set;} - internal string? ConsoleActorId {get; set;} - internal string? ThreadActorId {get; set;} - private ClientWebSocket? _clientSocket; - - public FirefoxInspectorClient(ILogger logger) : base(logger) - { - } - - protected override async Task SetupConnection(Uri webserverUri, CancellationToken token) - { - _clientSocket = await ConnectToWebServer(webserverUri, token); - - ArraySegment buff = new(new byte[10]); - _ = _clientSocket.ReceiveAsync(buff, token) - .ContinueWith(async t => - { - if (token.IsCancellationRequested) - return; - - logger.LogTrace($"** client socket closed, so stopping the client loop too"); - // Webserver connection is closed - // So, stop the loop here too - // _clientInitiatedClose.TrySetResult(); - await ShutdownAsync(token); - }, TaskContinuationOptions.NotOnRanToCompletion | TaskContinuationOptions.RunContinuationsAsynchronously) - .ConfigureAwait(false); - - RunLoopStopped += (_, _) => - { - logger.LogDebug($"RunLoop stopped, closing the websocket, state: {_clientSocket.State}"); - if (_clientSocket.State == WebSocketState.Open) - { - _clientSocket.Abort(); - } - }; - - IPEndPoint endpoint = new (IPAddress.Parse("127.0.0.1"), DebuggerTestBase.FirefoxProxyPort); - try - { - TcpClient tcpClient = new(); - - logger.LogDebug($"Connecting to the proxy at tcp://{endpoint} .."); - await tcpClient.ConnectAsync(endpoint, token); - logger.LogDebug($".. connected to the proxy!"); - return new FirefoxDebuggerConnection(tcpClient, "client", logger); - } - catch (SocketException se) - { - throw new Exception($"Failed to connect to the proxy at {endpoint}", se); - } - } - public async Task ProcessTabInfo(Result command, CancellationToken token) - { - var resultTabs = command.Value?["result"]?["value"]?["tabs"]; - if (resultTabs == null || - resultTabs.Value()?.Count == 0 || - resultTabs[0]?["url"]?.Value()?.StartsWith("about:") == true) - return false; - var toCmd = resultTabs[0]?["actor"]?.Value(); - var res = await SendCommand("getWatcher", JObject.FromObject(new { type = "getWatcher", isServerTargetSwitchingEnabled = true, to = toCmd}), token); - var watcherId = res.Value?["result"]?["value"]?["actor"]?.Value(); - res = await SendCommand("watchResources", JObject.FromObject(new { type = "watchResources", resourceTypes = new JArray("console-message"), to = watcherId}), token); - res = await SendCommand("watchTargets", JObject.FromObject(new { type = "watchTargets", targetType = "frame", to = watcherId}), token); - UpdateTarget(res.Value?["result"]?["value"]?["target"] as JObject); - if (ThreadActorId == null) - return false; - res = await SendCommand("attach", JObject.FromObject(new - { - type = "attach", - options = JObject.FromObject(new - { - pauseOnExceptions = false, - ignoreCaughtExceptions = true, - shouldShowOverlay = true, - shouldIncludeSavedFrames = true, - shouldIncludeAsyncLiveFrames = false, - skipBreakpoints = false, - logEventBreakpoints = false, - observeAsmJS = true, - breakpoints = new JArray(), - eventBreakpoints = new JArray() - }), - to = ThreadActorId - }), token); - res = await SendCommand("getBreakpointListActor", JObject.FromObject(new { type = "getBreakpointListActor", to = watcherId}), token); - BreakpointActorId = res.Value?["result"]?["value"]?["breakpointList"]?["actor"]?.Value(); - return true; - } - - public override async Task ProcessCommand(Result command, CancellationToken token) - { - if (await ProcessTabInfo(command, token)) - return; - do - { - command = await SendCommand("listTabs", JObject.FromObject(new { type = "listTabs", to = "root"}), token); - } while (!await ProcessTabInfo(command, token)); - } - - protected override Task? HandleMessage(string msg, CancellationToken token) - { - var res = JObject.Parse(msg); - if (res["type"]?.Value() == "newSource") - { - var method = res["type"]?.Value(); - return onEvent("", method, res, token); - } - - if (res["type"]?.Value() == "target-available-form" && res["target"] is JObject target) - { - UpdateTarget(target); - return Task.CompletedTask; - } - if (res["applicationType"] != null) - return null; - if (res["resultID"] != null) - { - if (res["type"]?.Value() == "evaluationResult") - { - if (res["from"]?.Value() is not string from_str) - return null; - - var messageId = new FirefoxMessageId("", 0, from_str); - if (pending_cmds.TryRemove(messageId, out var item)) - item.SetResult(Result.FromJsonFirefox(res)); - else - logger.LogDebug($"HandleMessage: Could not find any pending cmd for {messageId}. msg: {msg}"); - } - return null; - } - if (res["from"] is not null) - { - if (res["from"]?.Value() is not string from_str) - return null; - - var messageId = new FirefoxMessageId("", 0, from_str); - if (pending_cmds.TryRemove(messageId, out var item)) - { - item.SetResult(Result.FromJsonFirefox(res)); - return null; - } - } - if (res["type"] != null) - { - var method = res["type"]?.Value(); - switch (method) - { - case "paused": - { - method = "Debugger.paused"; - break; - } - case "resource-available-form": - { - if (res["resources"]?[0]?["resourceType"]?.Value() == "console-message" /*&& res["resources"][0]["arguments"] != null*/) - { - method = "Runtime.consoleAPICalled"; - var args = new JArray(); - // FIXME: unnecessary alloc - foreach (JToken? argument in res["resources"]?[0]?["message"]?["arguments"]?.Value() ?? new JArray()) - { - if (argument is null) - continue; - - string? strValue = null; - if (argument is JObject argObj && argObj["type"]?.Value() == "longString" && argObj["initial"] is JToken argInitialToken) - { - /* - "arguments" : [ - "mono_wasm_debug_event_raised:aef14bca-5519-4dfe-b35a-f867abc123ae", - { - "actor" : "server1.conn0.windowGlobal10737418242/longstractor35", - "initial" : "{\"eventName .... ", - "length" : 7737462, - "type" : "longString" - }, - "{}" - ] - */ - strValue = argInitialToken.Value(); - } - else if (argument.Type is JTokenType.String) - { - strValue = argument.Value(); - } - - // fallback - strValue ??= argument.ToString(); - args.Add(JObject.FromObject(new { value = strValue })); - } - res = JObject.FromObject(new - { - type = res["resources"]?[0]?["message"]?["level"]?.Value(), - args - }); - } - break; - } - } - return onEvent("", method, res, token); - } - return null; - } - - public override Task SendCommand(SessionId sessionId, string method, JObject? args, CancellationToken token) - { - if (args == null) - args = new JObject(); - var tcs = new TaskCompletionSource(); - MessageId msgId; - if (args["to"]?.Value() is not string to_str) - throw new Exception($"No 'to' field found in '{args}'"); - - msgId = new FirefoxMessageId("", 0, to_str); - pending_cmds.AddOrUpdate(msgId, tcs, (key, oldValue) => tcs); - logger.LogTrace($"SendCommand: to: {args}"); - - var msg = args.ToString(Formatting.None); - var bytes = Encoding.UTF8.GetBytes(msg); - Send(bytes, token); - - return tcs.Task; - } - - private void UpdateTarget(JObject? target) - { - if (target?["threadActor"]?.Value() is string threadActorId) - { - ThreadActorId = threadActorId; - logger.LogTrace($"Updated threadActorId to {threadActorId}"); - } - if (target?["consoleActor"]?.Value() is string consoleActorId) - { - ConsoleActorId = consoleActorId; - logger.LogTrace($"Updated consoleActorId to {consoleActorId}"); - } - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing && _clientSocket?.State == WebSocketState.Open) - { - _clientSocket?.Abort(); - _clientSocket?.Dispose(); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/FirefoxProvider.cs b/src/mono/browser/debugger/DebuggerTestSuite/FirefoxProvider.cs deleted file mode 100644 index e854b63b0ef74c..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/FirefoxProvider.cs +++ /dev/null @@ -1,150 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Net.WebSockets; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.WebAssembly.Diagnostics; -using Wasm.Tests.Internal; - -#nullable enable - -namespace DebuggerTests; - -internal class FirefoxProvider : WasmHostProvider -{ - private WebSocket? _ideWebSocket; - private FirefoxDebuggerProxy? _firefoxDebuggerProxy; - private static readonly Lazy s_browserPath = new(() => - { - string artifactsBinDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(ChromeProvider).Assembly.Location)!, "..", "..", "..")); - return BrowserLocator.FindFirefox(artifactsBinDir, "FIREFOX_PATH_FOR_TESTS"); - }); - - public FirefoxProvider(string id, ILogger logger) : base(id, logger) - { - } - - public async Task StartBrowserAndProxyAsync(HttpContext context, - string targetUrl, - int remoteDebuggingPort, - int proxyPort, - string messagePrefix, - ILoggerFactory loggerFactory, - CancellationTokenSource cts, - int browserReadyTimeoutMs = 20000, - string locale = "en-US") - { - if (_isDisposed) - throw new ObjectDisposedException(nameof(FirefoxProvider)); - - try - { - string args = $"-profile {GetProfilePath(Id)} -headless -new-instance -private -start-debugger-server {remoteDebuggingPort} -UILocale {locale}"; - ProcessStartInfo? psi = GetProcessStartInfo(s_browserPath.Value, args, targetUrl); - string? line = await LaunchHostAsync( - psi, - context, - str => - { - if (str?.Contains("Started devtools server on ") == true) - return $"http://localhost:{remoteDebuggingPort}"; - - return null; - }, - messagePrefix, - browserReadyTimeoutMs, - cts.Token).ConfigureAwait(false); - - if (_process is null || line is null) - throw new Exception($"Failed to launch firefox"); - } - catch (Exception ex) - { - TestHarnessProxy.RegisterProxyExitState(Id, new(RunLoopStopReason.Exception, ex)); - throw; - } - - /* - * Firefox uses a plain tcp connection, so we use that for communicating - * with the browser. But the tests connect to the webserver via a websocket, - * so we *accept* that here to complete the connection. - * - * Normally, when the tests are closing down, they close that webserver - * connection, and the proxy would shutdown too. But in this case, we need - * to explicitly trigger the proxy/browser shutdown when the websocket - * is closed. - */ - _ideWebSocket = await context.WebSockets.AcceptWebSocketAsync(); - - ArraySegment buff = new(new byte[10]); - _ = _ideWebSocket.ReceiveAsync(buff, cts.Token) - .ContinueWith(t => - { - // client has closed the webserver connection, Or - // it has been cancelled. - // so, we should kill the proxy, and firefox - Dispose(); - }, TaskContinuationOptions.NotOnRanToCompletion | TaskContinuationOptions.RunContinuationsAsynchronously) - .ConfigureAwait(false); - - _firefoxDebuggerProxy = new FirefoxDebuggerProxy(); - TestHarnessProxy.RegisterNewProxy(Id, _firefoxDebuggerProxy); - await _firefoxDebuggerProxy - .RunForTests(remoteDebuggingPort, proxyPort, Id, loggerFactory, _logger, cts) - .ConfigureAwait(false); - } - - public override void Dispose() - { - if (_isDisposed || _isDisposing) - return; - - _isDisposing = true; - if (_process?.HasExited == true) - _firefoxDebuggerProxy?.Fail(new Exception($"Firefox unexpectedly exited with code {_process.ExitCode}")); - else - _firefoxDebuggerProxy?.Shutdown(); - - base.Dispose(); - - _logger.LogDebug($"[test_id: {Id}] {nameof(FirefoxProvider)} Dispose"); - - if (_ideWebSocket is not null) - { - _ideWebSocket.Abort(); - _ideWebSocket.Dispose(); - _ideWebSocket = null; - } - - _logger.LogDebug($"[test_id: {Id}] {nameof(FirefoxProvider)} Dispose done"); - _isDisposed = true; - _isDisposing = false; - } - - private static string GetProfilePath(string Id) - { - string prefs = """ - user_pref("devtools.chrome.enabled", true); - user_pref("devtools.debugger.remote-enabled", true); - user_pref("devtools.debugger.prompt-connection", false); - user_pref("devtools.console.stdout.content", true); - user_pref("browser.dom.window.dump.enabled", true); - """; - - string profilePath = Path.GetFullPath(Path.Combine(DebuggerTestBase.DebuggerTestAppPath, $"test-profile-{Id}")); - if (Directory.Exists(profilePath)) - Directory.Delete(profilePath, recursive: true); - - Directory.CreateDirectory(profilePath); - File.WriteAllText(Path.Combine(profilePath, "prefs.js"), prefs); - - return profilePath; - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/GetPropertiesTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/GetPropertiesTests.cs deleted file mode 100644 index 1e87f9e60cc0bf..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/GetPropertiesTests.cs +++ /dev/null @@ -1,665 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Sdk; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class GetPropertiesTests : DebuggerTests - { - public enum AutoEvaluate - { - On, - Off, - Unset, - } - - public GetPropertiesTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - public static TheoryData, bool> ClassGetPropertiesTestData(bool is_async) - { - // FIXME: invoking getter on the hidden(base) properties - is that supported?? - var data = new TheoryData, bool>(); - - var type_name = "DerivedClass2"; - var all_props = new Dictionary() - { - // ------------------instance members-------------------------- - // own: - // public: - {"BaseBase_PropertyForHidingWithField", (TNumber(210), true)}, - {"Base_PropertyForOverridingWithProperty", (TGetter("Base_PropertyForOverridingWithProperty", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3))), true)}, - {"BaseBase_PropertyForVHO", (TGetter("BaseBase_PropertyForVHO", TString("Derived#BaseBase_PropertyForVHO")), true)}, - {"BaseBase_PropertyForVOH", (TGetter("BaseBase_PropertyForVOH", TString("Derived#BaseBase_PropertyForVOH")), true)}, - // {"BaseBase_PropertyForVOO", (TGetter("BaseBase_PropertyForVOO", TString("Derived#BaseBase_PropertyForVOO")), true)}, //FixMe: Issue #69788 - {"BaseBase_AutoPropertyForVHO", (TString("Derived#BaseBase_AutoPropertyForVHO"), true)}, - {"BaseBase_AutoPropertyForVOH", (TString("Derived#BaseBase_AutoPropertyForVOH"), true)}, - // {"BaseBase_AutoPropertyForVOO", (TGetter("BaseBase_AutoPropertyForVOO", TString("Derived#BaseBase_AutoPropertyForVOO")), true)}, //FixMe: Issue #69788 - - // protected / internal: - {"BaseBase_AutoPropertyForHidingWithProperty", (TGetter("BaseBase_AutoPropertyForHidingWithProperty", TString("Derived#BaseBase_AutoPropertyForHidingWithProperty")), true)}, - {"Base_PropertyForOverridingWithAutoProperty", (TDateTime(new DateTime(2022, 7, 6, 5, 4, 3)), true)}, - {"Base_AutoPropertyForOverridingWithAutoProperty", (TDateTime(new DateTime(2023, 7, 6, 5, 4, 3)), true)}, - {"Base_AutoPropertyForOverridingWithProperty", (TGetter("Base_AutoPropertyForOverridingWithProperty", TDateTime(new DateTime(2021, 7, 6, 5, 4, 3))), true)}, - - // private: - {"BaseBase_FieldForHidingWithAutoProperty", (TString("Derived#BaseBase_FieldForHidingWithAutoProperty"), true)}, - - // inherited from Base: - // public: - {"BaseBase_AutoPropertyForHidingWithField", (TNumber(115), false)}, - {"BaseBase_PropertyForHidingWithProperty", (TGetter("BaseBase_PropertyForHidingWithProperty", TString("Base#BaseBase_PropertyForHidingWithProperty")), false)}, - {"BaseBase_FieldForHidingWithAutoProperty (BaseClass2)", (TString("Base#BaseBase_FieldForHidingWithAutoProperty"), false)}, - {"Base_VirtualPropertyNotOverriddenOrHidden", (TGetter("Base_VirtualPropertyNotOverriddenOrHidden", TDateTime(new DateTime(2124, 5, 7, 1, 9, 2))), false)}, - {"FirstName", (TGetter("FirstName", TString("BaseClass#FirstName")), false)}, - {"LastName", (TGetter("LastName", TString("BaseClass#LastName")), false)}, - {"BaseBase_PropertyForVOH (BaseClass2)", (TGetter("BaseBase_PropertyForVOH (BaseClass2)", TString("Base#BaseBase_PropertyForVOH")), false)}, - {"BaseBase_AutoPropertyForVOH (BaseClass2)", (TString("Base#BaseBase_AutoPropertyForVOH"), false)}, - - // protected / internal: - {"BaseBase_PropertyForHidingWithField (BaseClass2)", (TNumber(110), false)}, - {"BaseBase_FieldForHidingWithProperty", (TGetter("BaseBase_FieldForHidingWithProperty", TString("Base#BaseBase_FieldForHidingWithProperty")), false)}, - {"BaseBase_AutoPropertyForHidingWithAutoProperty", (TString("Base#BaseBase_AutoPropertyForHidingWithAutoProperty"), false)}, - - // private: - {"BaseBase_FieldForHidingWithField", (TNumber(105), false)}, - {"BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", (TGetter("BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TString("Base#BaseBase_AutoPropertyForHidingWithProperty")), false)}, - {"BaseBase_PropertyForHidingWithAutoProperty", (TString("Base#BaseBase_PropertyForHidingWithAutoProperty"), false)}, - - // inherited from BaseBase: - // public: - {"BaseBase_FieldForHidingWithField (BaseBaseClass2)", (TNumber(5), false)}, - {"BaseBase_PropertyForHidingWithField (BaseBaseClass2)", (TGetter("BaseBase_PropertyForHidingWithField (BaseBaseClass2)", TNumber(10)), false)}, - {"BaseBase_AutoPropertyForHidingWithField (BaseBaseClass2)", (TNumber(15), false)}, - {"BaseBase_FieldForHidingWithProperty (BaseBaseClass2)", (TString("BaseBase#BaseBase_FieldForHidingWithProperty"), false)}, - {"BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", (TGetter("BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithProperty")), false)}, - {"BaseBase_AutoPropertyForHidingWithProperty (BaseBaseClass2)", (TString("BaseBase#BaseBase_AutoPropertyForHidingWithProperty"), false)}, - {"BaseBase_FieldForHidingWithAutoProperty (BaseBaseClass2)", (TString("BaseBase#BaseBase_FieldForHidingWithAutoProperty"), false)}, - {"BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", (TGetter("BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithAutoProperty")), false)}, - {"BaseBase_AutoPropertyForHidingWithAutoProperty (BaseBaseClass2)", (TString("BaseBase#BaseBase_AutoPropertyForHidingWithAutoProperty"), false)}, - {"BaseBase_PropertyForVHO (BaseBaseClass2)", (TGetter("BaseBase_PropertyForVHO (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForVHO")), false)}, - {"BaseBase_AutoPropertyForVHO (BaseBaseClass2)", (TString("BaseBase#BaseBase_AutoPropertyForVHO"), false)}, - - // ------------------static members-------------------------- - // own: - // public: - {"S_BaseBase_PropertyForHidingWithField", (TNumber(210), true)}, - - // protected / internal: - {"S_BaseBase_AutoPropertyForHidingWithProperty", (TGetter("S_BaseBase_AutoPropertyForHidingWithProperty", TString("Derived#BaseBase_AutoPropertyForHidingWithProperty")), true)}, - - // private: - {"S_BaseBase_FieldForHidingWithAutoProperty", (TString(null), true)}, - - // inherited from Base: - // public: - {"S_BaseBase_AutoPropertyForHidingWithField", (TNumber(115), false)}, - {"S_BaseBase_PropertyForHidingWithProperty", (TGetter("S_BaseBase_PropertyForHidingWithProperty", TString("Base#BaseBase_PropertyForHidingWithProperty")), false)}, - {"S_BaseBase_FieldForHidingWithAutoProperty (BaseClass2)", (TString(null), false)}, - - // protected / internal: - {"S_BaseBase_PropertyForHidingWithField (BaseClass2)", (TNumber(110), false)}, - {"S_BaseBase_FieldForHidingWithProperty", (TGetter("S_BaseBase_FieldForHidingWithProperty", TString("Base#BaseBase_FieldForHidingWithProperty")), false)}, - {"S_BaseBase_AutoPropertyForHidingWithAutoProperty", (TString(null), false)}, - - // private: - {"S_BaseBase_FieldForHidingWithField", (TNumber(105), false)}, - {"S_BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", (TGetter("S_BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TString("Base#BaseBase_AutoPropertyForHidingWithProperty")), false)}, - {"S_BaseBase_PropertyForHidingWithAutoProperty", (TString(null), false)}, - - // inherited from BaseBase: - // public: - {"S_BaseBase_FieldForHidingWithField (BaseBaseClass2)", (TNumber(5), false)}, - {"S_BaseBase_PropertyForHidingWithField (BaseBaseClass2)", (TGetter("S_BaseBase_PropertyForHidingWithField (BaseBaseClass2)", TNumber(10)), false)}, - {"S_BaseBase_AutoPropertyForHidingWithField (BaseBaseClass2)", (TNumber(0), false)}, - {"S_BaseBase_FieldForHidingWithProperty (BaseBaseClass2)", (TString("BaseBase#BaseBase_FieldForHidingWithProperty"), false)}, - {"S_BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", (TGetter("S_BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithProperty")), false)}, - {"S_BaseBase_AutoPropertyForHidingWithProperty (BaseBaseClass2)", (TString(null), false)}, - {"S_BaseBase_FieldForHidingWithAutoProperty (BaseBaseClass2)", (TString("BaseBase#BaseBase_FieldForHidingWithAutoProperty"), false)}, - {"S_BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", (TGetter("S_BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithAutoProperty")), false)}, - {"S_BaseBase_AutoPropertyForHidingWithAutoProperty (BaseBaseClass2)", (TString(null), false)}, - }; - - // default, all properties - // n, n - data.Add(type_name, null, null, all_props.Keys.ToArray(), all_props, is_async); - // f, f - data.Add(type_name, false, false, all_props.Keys.ToArray(), all_props, is_async); - // f, n - data.Add(type_name, false, null, all_props.Keys.ToArray(), all_props, is_async); - // n, f - data.Add(type_name, null, false, all_props.Keys.ToArray(), all_props, is_async); - - // all own - // t, f - // t, n - foreach (bool? accessors in new bool?[] { false, null }) - { - // Breaking from JS behavior, we return *all* members irrespective of `ownMembers` - data.Add(type_name, true, accessors, all_props.Keys.ToArray(), all_props, is_async); - } - - var all_accessors = new[] - { - "Base_PropertyForOverridingWithProperty", - "BaseBase_AutoPropertyForHidingWithProperty", - "Base_AutoPropertyForOverridingWithProperty", - "BaseBase_PropertyForVHO", - "BaseBase_PropertyForVOH", - // "BaseBase_PropertyForVOO", // FixMe: Issue #69788 - "S_BaseBase_AutoPropertyForHidingWithProperty", - - "BaseBase_PropertyForHidingWithProperty", - "FirstName", - "LastName", - "BaseBase_FieldForHidingWithProperty", - "BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", - "BaseBase_PropertyForVOH (BaseClass2)", - "S_BaseBase_PropertyForHidingWithProperty", - "S_BaseBase_FieldForHidingWithProperty", - "S_BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", - - "BaseBase_PropertyForHidingWithField (BaseBaseClass2)", - "BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", - "BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", - "Base_VirtualPropertyNotOverriddenOrHidden", - "BaseBase_PropertyForVHO (BaseBaseClass2)", - "S_BaseBase_PropertyForHidingWithField (BaseBaseClass2)", - "S_BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", - "S_BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)" - }; - - var only_own_accessors = new[] - { - "Base_PropertyForOverridingWithProperty", - "BaseBase_AutoPropertyForHidingWithProperty", - "Base_AutoPropertyForOverridingWithProperty", - "BaseBase_PropertyForVHO", - "BaseBase_PropertyForVOH", - // "BaseBase_PropertyForVOO", // FixMe: Issue #69788 - "S_BaseBase_AutoPropertyForHidingWithProperty", - }; - - // all own, only accessors - // t, t - - // Breaking from JS behavior, we return *all* members irrespective of `ownMembers` - // data.Add(type_name, true, true, only_own_accessors, all_props, is_async); - data.Add(type_name, true, true, all_accessors, all_props, is_async); - - // all accessors - // f, t - // n, t - foreach (bool? own in new bool?[] { false, null }) - { - data.Add(type_name, own, true, all_accessors, all_props, is_async); - } - - return data; - } - - public static TheoryData, bool> StructGetPropertiesTestData(bool is_async) - { - var data = new TheoryData, bool>(); - - var type_name = "CloneableStruct"; - var all_props = new Dictionary() - { - {"_stringField", (TString("CloneableStruct#_stringField"), true)}, - {"_dateTime", (TDateTime(new DateTime(2020, 7, 6, 5, 4, 3 + 3)), true)}, - {"_DTProp", (TGetter("_DTProp"), true)}, - - // own public - {"a", (TNumber(4), true)}, - {"DateTime", (TGetter("DateTime"), true)}, - {"AutoStringProperty", (TString("CloneableStruct#AutoStringProperty"), true)}, - {"FirstName", (TGetter("FirstName"), true)}, - {"LastName", (TGetter("LastName"), true)}, - - // protected - {"b", (TBool(true), true)}, - - // indexers don't show up in getprops - // {"Item", (TSymbol("int { get; }"), true)} - }; - - // default, all properties - data.Add(type_name, null, null, all_props.Keys.ToArray(), all_props, is_async); - data.Add(type_name, false, false, all_props.Keys.ToArray(), all_props, is_async); - - // all own - data.Add(type_name, true, false, all_props.Keys.ToArray(), all_props, is_async); - - var all_accessor_names = new[] - { - "_DTProp", - "DateTime", - "FirstName", - "LastName" - }; - - // all own, only accessors - data.Add(type_name, true, true, all_accessor_names, all_props, is_async); - // all accessors - data.Add(type_name, false, true, all_accessor_names, all_props, is_async); - - return data; - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(ClassGetPropertiesTestData), parameters: true)] - [MemberData(nameof(ClassGetPropertiesTestData), parameters: false)] - [MemberData(nameof(StructGetPropertiesTestData), parameters: true)] - [MemberData(nameof(StructGetPropertiesTestData), parameters: false)] - public async Task InspectTypeInheritedMembers(string type_name, bool? own_properties, bool? accessors_only, string[] expected_names, Dictionary all_props, bool is_async) => - await InspectTypeInheritedMembersInternal(type_name, own_properties, accessors_only, expected_names, all_props, is_async, AutoEvaluate.Unset); - - public static IEnumerable MembersForLocalNestedStructData(bool is_async) - => StructGetPropertiesTestData(false).Select(datum => datum[1..]); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(MembersForLocalNestedStructData), parameters: false)] - [MemberData(nameof(MembersForLocalNestedStructData), parameters: true)] - public async Task MembersForLocalNestedStruct(bool? own_properties, bool? accessors_only, string[] expected_names, Dictionary all_props, bool is_async) => await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.GetPropertiesTests.NestedStruct", - is_async ? $"TestNestedStructStaticAsync" : "TestNestedStructStatic", - 2, - "DebuggerTests.GetPropertiesTests.NestedStruct." + (is_async ? "TestNestedStructStaticAsync" : $"TestNestedStructStatic"), - $"window.setTimeout(function() {{ invoke_static_method_async ('[debugger-test] DebuggerTests.GetPropertiesTests.NestedStruct:run'); }})", - wait_for_event_fn: async (pause_location) => - { - var ns_props = await GetObjectOnFrame(pause_location["callFrames"][0], "ns"); - - var cs_obj = GetAndAssertObjectWithName(ns_props, "cloneableStruct"); - var cs_props = await GetProperties(cs_obj["value"]?["objectId"]?.Value(), own_properties: own_properties, accessors_only: accessors_only); - - await CheckExpectedProperties(expected_names, name => GetAndAssertObjectWithName(cs_props, name), all_props); - AssertHasOnlyExpectedProperties(expected_names, cs_props.Values()); - - // indexer properties shouldn't show up here - var item = cs_props.FirstOrDefault(jt => jt["name"]?.Value() == "Item"); - Assert.Null(item); - }); - - public static TheoryData JSGetPropertiesTestData(bool test_js) => new TheoryData - { - // default, no args set - { - test_js, - null, null, new[] - { - "owner_name", - "owner_last_name", - "kind", - "make", - "available" - } - }, - - // all props - { - test_js, - false, false, new[] - { - "owner_name", - "owner_last_name", - "kind", - "make", - "available" - } - }, - - // all own - { - test_js, - true, false, new[] - { - "owner_name", - "owner_last_name" - } - }, - - // all own accessors - { - test_js, - true, true, new[] - { - "owner_last_name" - } - }, - - // all accessors - { - test_js, - false, true, new[] - { - "available", - "owner_last_name" - } - } - }; - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(JSGetPropertiesTestData), parameters: true)] - // Note: Disabled because we don't match JS's behavior here! - // We return inherited members too for `ownProperties:true` - // [MemberData(nameof(JSGetPropertiesTestData), parameters: false)] - public async Task GetPropertiesTestJSAndManaged(bool test_js, bool? own_properties, bool? accessors_only, string[] expected_names) - { - string eval_expr; - if (test_js) - { - await SetBreakpoint("/other.js", 95, 1); - eval_expr = "window.setTimeout(function() { get_properties_test (); }, 1)"; - } - else - { - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.GetPropertiesTests.DerivedClassForJSTest", "run", 2); - eval_expr = "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.GetPropertiesTests.DerivedClassForJSTest:run'); }, 1)"; - } - - var result = await cli.SendCommand("Runtime.evaluate", JObject.FromObject(new { expression = eval_expr }), token); - var pause_location = await insp.WaitFor(Inspector.PAUSE); - - var id = pause_location["callFrames"][0]["scopeChain"][0]["object"]["objectId"].Value(); - - var frame_locals = await GetProperties(id); - var obj = GetAndAssertObjectWithName(frame_locals, "obj"); - var obj_props = await GetProperties(obj["value"]?["objectId"]?.Value(), - own_properties: own_properties, accessors_only: accessors_only); - - IEnumerable filtered_props; - if (test_js) - { - filtered_props = obj_props.Children().Where(jt => jt["enumerable"]?.Value() == true); - } - else - { - // we don't set `enumerable` right now - filtered_props = obj_props.Children().Where(jt => true); - } - - var expected_props = new Dictionary() - { - // own - {"owner_name", (TString("foo"), true)}, - {"owner_last_name", (TGetter("owner_last_name"), true)}, - - // inherited - {"kind", (TString("car"), false)}, - {"make", (TString("mini"), false)}, - {"available", (TGetter("available"), false)}, - }; - - await CheckExpectedProperties( - expected_names, - name => filtered_props.Where(jt => jt["name"]?.Value() == name).SingleOrDefault(), - expected_props); - - //AssertEqual(expected_names.Length, filtered_props.Count(), $"expected number of properties"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - 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", 128, 8, - "TestChild.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", TNumber(20)), - GetI = TGetter("GetI", TNumber(50)), - GetK = TGetter("GetK", TNumber(30)), - GetD = TGetter("GetD", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3))) - }, "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, bool autoEvaluate = false) - { - foreach (var exp_name in expected_names) - { - if (!all_props.TryGetValue(exp_name, out var expected)) - { - Assert.True(false, $"Test Bug: Could not find property named {exp_name}"); - } - var (exp_prop, is_own) = expected; - var actual_prop = get_actual_prop(exp_name); - - AssertEqual(is_own, actual_prop["isOwn"]?.Value() == true, $"{exp_name}#isOwn"); - - if (exp_prop["__custom_type"]?.Value() == "getter") - { - // HACK! CheckValue normally expects to get a value:{} - // from `{name: "..", value: {}, ..} - // but for getters we actually have: `{name: "..", get: {..} }` - // and no `value` - if (!autoEvaluate) - await CheckValue(actual_prop, exp_prop, exp_name); - else - { - if (exp_prop["value"].Type != JTokenType.Null) - await CheckValue(actual_prop["value"], exp_prop["value"], exp_name); - } - } - else - { - await CheckValue(actual_prop["value"], exp_prop, exp_name); - } - } - } - - private void AssertHasOnlyExpectedProperties(string[] expected_names, IEnumerable actual) - { - bool fail = false; - var exp = new HashSet(expected_names); - - foreach (var obj in actual) - { - if (!exp.Contains(obj["name"]?.Value())) - { - _testOutput.WriteLine($"Unexpected: {obj}"); - fail = true; - } - } - - var act = new HashSet(actual.Select(a => a["name"].Value())); - foreach (var obj in expected_names.Where(ename => !act.Contains(ename))) - { - _testOutput.WriteLine($"Missing: {obj}"); - fail = true; - } - - if (fail) - throw new XunitException($"missing or unexpected members found"); - } - - public static TheoryData, Dictionary, string> GetDataForProtectionLevels() - { - var data = new TheoryData, Dictionary, string>(); - - var public_props = new Dictionary() - { - // --------- public ------------: - // own: - {"BaseBase_PropertyForHidingWithField", TNumber(210)}, - {"Base_PropertyForOverridingWithProperty", TGetter("Base_PropertyForOverridingWithProperty", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3)))}, - {"BaseBase_PropertyForVHO", TGetter("BaseBase_PropertyForVHO", TString("Derived#BaseBase_PropertyForVHO"))}, - {"BaseBase_PropertyForVOH", TGetter("BaseBase_PropertyForVOH", TString("Derived#BaseBase_PropertyForVOH"))}, - // {"BaseBase_PropertyForVOO", TGetter("BaseBase_PropertyForVOO", TString("Derived#BaseBase_PropertyForVOO"))}, //FixMe: Issue #69788 - {"BaseBase_AutoPropertyForVHO", TString("Derived#BaseBase_AutoPropertyForVHO")}, - {"BaseBase_AutoPropertyForVOH", TString("Derived#BaseBase_AutoPropertyForVOH")}, - // {"BaseBase_AutoPropertyForVOO", TString("Derived#BaseBase_AutoPropertyForVOO")}, //FixMe: Issue #69788 - {"S_BaseBase_PropertyForHidingWithField", TNumber(210)}, - - // inherited from Base: - {"BaseBase_AutoPropertyForHidingWithField", TNumber(115)}, - {"BaseBase_PropertyForHidingWithProperty", TGetter("BaseBase_PropertyForHidingWithProperty", TString("Base#BaseBase_PropertyForHidingWithProperty"))}, - {"BaseBase_FieldForHidingWithAutoProperty (BaseClass2)", TString("Base#BaseBase_FieldForHidingWithAutoProperty")}, - {"FirstName", TGetter("FirstName", TString("BaseClass#FirstName"))}, - {"LastName", TGetter("LastName", TString("BaseClass#LastName"))}, - {"Base_VirtualPropertyNotOverriddenOrHidden", TGetter("Base_VirtualPropertyNotOverriddenOrHidden", TDateTime(new DateTime(2124, 5, 7, 1, 9, 2)))}, - {"BaseBase_PropertyForVOH (BaseClass2)", TGetter("BaseBase_PropertyForVOH (BaseClass2)", TString("Base#BaseBase_PropertyForVOH"))}, - {"BaseBase_AutoPropertyForVOH (BaseClass2)", TString("Base#BaseBase_AutoPropertyForVOH")}, - {"S_BaseBase_AutoPropertyForHidingWithField", TNumber(115)}, - {"S_BaseBase_PropertyForHidingWithProperty", TGetter("S_BaseBase_PropertyForHidingWithProperty", TString("Base#BaseBase_PropertyForHidingWithProperty"))}, - {"S_BaseBase_FieldForHidingWithAutoProperty (BaseClass2)", TString(null)}, - - // inherited from BaseBase: - {"BaseBase_FieldForHidingWithField (BaseBaseClass2)", TNumber(5)}, - {"BaseBase_PropertyForHidingWithField (BaseBaseClass2)", TGetter("BaseBase_PropertyForHidingWithField (BaseBaseClass2)", TNumber(10))}, - {"BaseBase_AutoPropertyForHidingWithField (BaseBaseClass2)", TNumber(15)}, - {"BaseBase_FieldForHidingWithProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_FieldForHidingWithProperty")}, - {"BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", TGetter("BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithProperty"))}, - {"BaseBase_AutoPropertyForHidingWithProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_AutoPropertyForHidingWithProperty")}, - {"BaseBase_FieldForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_FieldForHidingWithAutoProperty")}, - {"BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", TGetter("BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithAutoProperty"))}, - {"BaseBase_AutoPropertyForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_AutoPropertyForHidingWithAutoProperty")}, - {"BaseBase_PropertyForVHO (BaseBaseClass2)", TGetter("BaseBase_PropertyForVHO (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForVHO"))}, - {"BaseBase_AutoPropertyForVHO (BaseBaseClass2)", TString("BaseBase#BaseBase_AutoPropertyForVHO")}, - {"S_BaseBase_FieldForHidingWithField (BaseBaseClass2)", TNumber(5)}, - {"S_BaseBase_PropertyForHidingWithField (BaseBaseClass2)", TGetter("S_BaseBase_PropertyForHidingWithField (BaseBaseClass2)", TNumber(10))}, - {"S_BaseBase_AutoPropertyForHidingWithField (BaseBaseClass2)", TNumber(0)}, - {"S_BaseBase_FieldForHidingWithProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_FieldForHidingWithProperty")}, - {"S_BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", TGetter("S_BaseBase_PropertyForHidingWithProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithProperty"))}, - {"S_BaseBase_AutoPropertyForHidingWithProperty (BaseBaseClass2)", TString(null)}, - {"S_BaseBase_FieldForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_FieldForHidingWithAutoProperty")}, - {"S_BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", TGetter("S_BaseBase_PropertyForHidingWithAutoProperty (BaseBaseClass2)", TString("BaseBase#BaseBase_PropertyForHidingWithAutoProperty"))}, - {"S_BaseBase_AutoPropertyForHidingWithAutoProperty (BaseBaseClass2)",TString(null)}, - - // ---- internal / protected ----: - // own: - {"BaseBase_AutoPropertyForHidingWithProperty", TGetter("BaseBase_AutoPropertyForHidingWithProperty", TString("Derived#BaseBase_AutoPropertyForHidingWithProperty"))}, - {"Base_PropertyForOverridingWithAutoProperty", TDateTime(new DateTime(2022, 7, 6, 5, 4, 3))}, - {"Base_AutoPropertyForOverridingWithAutoProperty", TDateTime(new DateTime(2023, 7, 6, 5, 4, 3))}, - {"Base_AutoPropertyForOverridingWithProperty", TGetter("Base_AutoPropertyForOverridingWithProperty", TDateTime(new DateTime(2021, 7, 6, 5, 4, 3)))}, - {"S_BaseBase_AutoPropertyForHidingWithProperty", TGetter("S_BaseBase_AutoPropertyForHidingWithProperty", TString("Derived#BaseBase_AutoPropertyForHidingWithProperty"))}, - // inherited from Base: - {"BaseBase_PropertyForHidingWithField (BaseClass2)", TNumber(110)}, - {"BaseBase_FieldForHidingWithProperty", TGetter("BaseBase_FieldForHidingWithProperty", TString("Base#BaseBase_FieldForHidingWithProperty"))}, - {"BaseBase_AutoPropertyForHidingWithAutoProperty", TString("Base#BaseBase_AutoPropertyForHidingWithAutoProperty")}, - {"S_BaseBase_PropertyForHidingWithField (BaseClass2)", TNumber(110)}, - {"S_BaseBase_FieldForHidingWithProperty", TGetter("S_BaseBase_FieldForHidingWithProperty", TString("Base#BaseBase_FieldForHidingWithProperty"))}, - {"S_BaseBase_AutoPropertyForHidingWithAutoProperty", TString(null)}, - }; - - var private_props = new Dictionary(){ - // own - {"BaseBase_FieldForHidingWithAutoProperty", TString("Derived#BaseBase_FieldForHidingWithAutoProperty")}, - {"S_BaseBase_FieldForHidingWithAutoProperty", TString(null)}, - // from Base: - {"BaseBase_FieldForHidingWithField", TNumber(105)}, - {"BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TGetter("BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TString("Base#BaseBase_AutoPropertyForHidingWithProperty"))}, - {"BaseBase_PropertyForHidingWithAutoProperty", TString("Base#BaseBase_PropertyForHidingWithAutoProperty")}, - {"S_BaseBase_FieldForHidingWithField", TNumber(105)}, - {"S_BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)",TGetter("S_BaseBase_AutoPropertyForHidingWithProperty (BaseClass2)", TString("Base#BaseBase_AutoPropertyForHidingWithProperty"))}, - {"S_BaseBase_PropertyForHidingWithAutoProperty", TString(null)}, - }; - data.Add(public_props, private_props, "DerivedClass2"); - - // structure CloneableStruct: - public_props = new Dictionary() - { - // own - // public - {"a", TNumber(4)}, - {"DateTime", TGetter("DateTime")}, - {"AutoStringProperty", TString("CloneableStruct#AutoStringProperty")}, - {"FirstName", TGetter("FirstName")}, - {"LastName", TGetter("LastName")}, - - // internal - {"b", TBool(true)} - }; - private_props = new Dictionary() - { - {"_stringField", TString("CloneableStruct#_stringField")}, - {"_dateTime", TDateTime(new DateTime(2020, 7, 6, 5, 4, 3 + 3))}, - {"_DTProp", TGetter("_DTProp")} - }; - data.Add(public_props, private_props, "CloneableStruct"); - return data; - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(GetDataForProtectionLevels))] - public async Task PropertiesSortedByProtectionLevel( - Dictionary expectedPublicInternalAndProtected, Dictionary expectedPriv, string entryMethod) => - await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.GetPropertiesTests.{entryMethod}", "InstanceMethod", 1, $"DebuggerTests.GetPropertiesTests.{entryMethod}.InstanceMethod", - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test] DebuggerTests.GetPropertiesTests.{entryMethod}:run'); }})", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - var (obj, _) = await EvaluateOnCallFrame(id, "this"); - var (pubInternalAndProtected, priv) = await GetPropertiesSortedByProtectionLevels(obj["objectId"]?.Value()); - - AssertHasOnlyExpectedProperties(expectedPublicInternalAndProtected.Keys.ToArray(), pubInternalAndProtected.Values()); - AssertHasOnlyExpectedProperties(expectedPriv.Keys.ToArray(), priv.Values()); - - await CheckProps(pubInternalAndProtected, expectedPublicInternalAndProtected, "result"); - await CheckProps(priv, expectedPriv, "private"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(ClassGetPropertiesTestData), parameters: true)] - [MemberData(nameof(ClassGetPropertiesTestData), parameters: false)] - [MemberData(nameof(StructGetPropertiesTestData), parameters: true)] - [MemberData(nameof(StructGetPropertiesTestData), parameters: false)] - public async Task InspectTypeInheritedMembersAutoEvaluateOn(string type_name, bool? own_properties, bool? accessors_only, string[] expected_names, Dictionary all_props, bool is_async) => - await InspectTypeInheritedMembersInternal(type_name, own_properties, accessors_only, expected_names, all_props, is_async, AutoEvaluate.On); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberData(nameof(ClassGetPropertiesTestData), parameters: true)] - [MemberData(nameof(ClassGetPropertiesTestData), parameters: false)] - [MemberData(nameof(StructGetPropertiesTestData), parameters: true)] - [MemberData(nameof(StructGetPropertiesTestData), parameters: false)] - public async Task InspectTypeInheritedMembersAutoEvaluateOff(string type_name, bool? own_properties, bool? accessors_only, string[] expected_names, Dictionary all_props, bool is_async) => - await InspectTypeInheritedMembersInternal(type_name, own_properties, accessors_only, expected_names, all_props, is_async, AutoEvaluate.Off); - - public async Task InspectTypeInheritedMembersInternal(string type_name, bool? own_properties, bool? accessors_only, string[] expected_names, Dictionary all_props, bool is_async, AutoEvaluate auto_evaluate_status) - { - if (auto_evaluate_status == AutoEvaluate.On) - await cli.SendCommand("DotnetDebugger.setEvaluationOptions", JObject.FromObject(new { options = new { noFuncEval = false } }), token); - else if (auto_evaluate_status == AutoEvaluate.Off) - await cli.SendCommand("DotnetDebugger.setEvaluationOptions", JObject.FromObject(new { options = new { noFuncEval = true } }), token); - await CheckInspectLocalsAtBreakpointSite( - $"DebuggerTests.GetPropertiesTests.{type_name}", - $"InstanceMethod{(is_async ? "Async" : "")}", 1, $"DebuggerTests.GetPropertiesTests.{type_name}." + (is_async ? "InstanceMethodAsync" : "InstanceMethod"), - $"window.setTimeout(function() {{ invoke_static_method_async ('[debugger-test] DebuggerTests.GetPropertiesTests.{type_name}:run'); }})", - wait_for_event_fn: async (pause_location) => - { - var frame_id = pause_location["callFrames"][0]["callFrameId"].Value(); - var frame_locals = await GetProperties(frame_id); - var this_obj = GetAndAssertObjectWithName(frame_locals, "this"); - var this_props = await GetProperties(this_obj["value"]?["objectId"]?.Value(), own_properties: own_properties, accessors_only: accessors_only); - AssertHasOnlyExpectedProperties(expected_names, this_props.Values()); - await CheckExpectedProperties(expected_names, name => GetAndAssertObjectWithName(this_props, name), all_props, auto_evaluate_status == AutoEvaluate.On); - - // indexer properties shouldn't show up here - var item = this_props.FirstOrDefault(jt => jt["name"]?.Value() == "Item"); - Assert.Null(item); - }); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/HarnessTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/HarnessTests.cs deleted file mode 100644 index ad2dabd4637e45..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/HarnessTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -#nullable enable - -namespace DebuggerTests -{ - public class HarnessTests : DebuggerTests - { - public HarnessTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task TimedOutWaitingForInvalidBreakpoint() - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 100, 0); - var tce = await Assert.ThrowsAsync( - async () => await EvaluateAndCheck("window.setTimeout(function() { invoke_add(); }, 1);", null, -1, -1, null)); - Assert.Contains("timed out", tce.Message); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task ExceptionThrown() - { - var ae = await Assert.ThrowsAsync( - async () => await EvaluateAndCheck("window.setTimeout(function() { non_existent_fn(); }, 3000);", null, -1, -1, null)); - Assert.Contains("non_existent_fn is not defined", ae.Message); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task BrowserCrash() - { - TaskCompletionSource clientRunLoopStopped = new(); - insp.Client.RunLoopStopped += (_, args) => clientRunLoopStopped.TrySetResult(args); - try - { - await SendCommandAndCheck(null, "Browser.crash", null, -1, -1, null); - } - catch (Exception ex) - { - Task t = await Task.WhenAny(clientRunLoopStopped.Task, Task.Delay(10000)); - if (t != clientRunLoopStopped.Task) - Assert.Fail($"Proxy did not stop, as expected"); - RunLoopExitState? state = await clientRunLoopStopped.Task; - if (state.reason != RunLoopStopReason.ConnectionClosed) - Assert.Fail($"Client runloop did not stop with ConnectionClosed. state: {state}.{Environment.NewLine}SendCommand had failed with {ex}"); - } - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InspectorWaitForAfterMessageAlreadyReceived() - { - Result res = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - Assert.True(res.IsOk, $"setBreakpoint failed with {res}"); - - res = await cli.SendCommand( - "Runtime.evaluate", - JObject.FromObject(new { expression = "window.setTimeout(function() { invoke_add(); }, 0);" }), - token); - Assert.True(res.IsOk, $"evaluating the function failed with {res}"); - - // delay, so that we can get the Debugger.pause event - await Task.Delay(1000); - - await insp.WaitFor(Inspector.PAUSE); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InspectorWaitForMessageThatNeverArrives() - { - var tce = await Assert.ThrowsAsync(async () => await insp.WaitFor("Message.that.never.arrives")); - Assert.Contains("timed out", tce.Message); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/HotReloadTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/HotReloadTests.cs deleted file mode 100644 index 3a5174d12eec9d..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/HotReloadTests.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using System.IO; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class HotReloadTests : DebuggerTests - { - public HotReloadTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethodChangedUserBreak() - { - var pause_location = await LoadAssemblyAndTestHotReload( - Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"), - Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"), - Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"), - "MethodBody1", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 16, "ApplyUpdateReferencedAssembly.MethodBody1.StaticMethod1"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "b", 15); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 12, "ApplyUpdateReferencedAssembly.MethodBody1.StaticMethod1"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckBool(locals, "c", true); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethodUnchanged() - { - var pause_location = await LoadAssemblyAndTestHotReload( - Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"), - Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"), - Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"), - "MethodBody2", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, "ApplyUpdateReferencedAssembly.MethodBody2.StaticMethod1"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, "ApplyUpdateReferencedAssembly.MethodBody2.StaticMethod1"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("ApplyUpdateReferencedAssembly")] - [InlineData("ApplyUpdateReferencedAssemblyChineseCharInPath\u3128")] - public async Task DebugHotReloadMethodAddBreakpoint(string assembly_name) - { - int line = 30; - await SetBreakpoint(".*/MethodBody1.cs$", line, 12, use_regex: true); - var pause_location = await LoadAssemblyAndTestHotReload( - Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"), - Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb"), - Path.Combine(DebuggerTestAppPath, $"../wasm/{assembly_name}.dll"), - "MethodBody3", "StaticMethod3", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", $"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "b", 15); - - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", $"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckBool(locals, "c", true); - - await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", - locals_fn: async (locals) => - { - CheckNumber(locals, "d", 10); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", - locals_fn: async (locals) => - { - CheckNumber(locals, "d", 10); - CheckNumber(locals, "e", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", - locals_fn: async (locals) => - { - CheckNumber(locals, "d", 10); - CheckNumber(locals, "e", 20); - CheckNumber(locals, "f", 50); - await Task.CompletedTask; - } - ); - } - - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethodEmpty() - { - int line = 38; - await SetBreakpoint(".*/MethodBody1.cs$", line, 0, use_regex: true); - var pause_location = await LoadAssemblyAndTestHotReload( - Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"), - Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"), - Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"), - "MethodBody4", "StaticMethod4", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 38, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 39, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 40, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 41, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 42, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 43, 8, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 38, 8, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethodChangedUserBreakUsingSDB() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody1", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody1", "StaticMethod1", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody1.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 16, scripts, top_frame["location"]); - - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "b", 15); - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody1", "StaticMethod1", 2); - - top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody1.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 12, 12, scripts, top_frame["location"]); - - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckBool(locals, "c", true); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethodUnchangedUsingSDB() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody2", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody2", "StaticMethod1", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody2.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, scripts, top_frame["location"]); - - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody2", "StaticMethod1", 2); - - top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody2.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 21, 12, scripts, top_frame["location"]); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("ApplyUpdateReferencedAssembly")] - [InlineData("ApplyUpdateReferencedAssemblyChineseCharInPath\u3128")] - public async Task DebugHotReloadMethodAddBreakpointUsingSDB(string assembly_name) - { - string asm_file = Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, $"../wasm/{assembly_name}.dll"); - - int line = 30; - await SetBreakpoint(".*/MethodBody1.cs$", line, 12, use_regex: true); - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody3", "StaticMethod3", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody3", "StaticMethod3", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation($"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, scripts, top_frame["location"]); - - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "b", 15); - - //apply second update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody3", "StaticMethod3", 2); - - top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation($"dotnet://{assembly_name}.dll/MethodBody1.cs", 30, 12, scripts, top_frame["location"]); - - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckBool(locals, "c", true); - - await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 31, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", - locals_fn: async (locals) => - { - CheckNumber(locals, "d", 10); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 32, 12, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", - locals_fn: async (locals) => - { - CheckNumber(locals, "d", 10); - CheckNumber(locals, "e", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, $"dotnet://{assembly_name}.dll/MethodBody1.cs", 33, 8, "ApplyUpdateReferencedAssembly.MethodBody3.StaticMethod3", - locals_fn: async (locals) => - { - CheckNumber(locals, "d", 10); - CheckNumber(locals, "e", 20); - CheckNumber(locals, "f", 50); - await Task.CompletedTask; - } - ); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethodEmptyUsingSDB() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - int line = 38; - await SetBreakpoint(".*/MethodBody1.cs$", line, 0, use_regex: true); - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody4", "StaticMethod4", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody4", "StaticMethod4", 1); - - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 39, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 40, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 41, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 42, 12, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 43, 8, "ApplyUpdateReferencedAssembly.MethodBody4.StaticMethod4", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - await Task.CompletedTask; - } - ); - //pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 38, 8, "StaticMethod4"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_CheckBreakpointLineUpdated_ByVS_Simulated() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp = await SetBreakpoint(".*/MethodBody1.cs$", 48, 12, use_regex: true); - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody5", "StaticMethod1", 1, - rebindBreakpoint : async () => - { - await RemoveBreakpoint(bp.Value["breakpointId"].Value()); - await SetBreakpoint(".*/MethodBody1.cs$", 49, 12, use_regex: true); - }); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody5.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 49, 12, scripts, top_frame["location"]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_CheckBreakpointLineUpdated_ByVS_Simulated_ReceivingBreakpointBeforeUpdate2() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp = await SetBreakpoint(".*/MethodBody1.cs$", 49, 12, use_regex: true); - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody5", "StaticMethod1", 1, - rebindBreakpoint : async () => - { - await RemoveBreakpoint(bp.Value["breakpointId"].Value()); - await SetBreakpoint(".*/MethodBody1.cs$", 50, 12, use_regex: true); - }, - rebindBeforeUpdates : true); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody5.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 50, 12, scripts, top_frame["location"]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_CheckBreakpointLineUpdated_ByVS_Simulated_ReceivingBreakpointBeforeUpdate_BPNotChanged() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 48, 12, use_regex: true); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 48, 12, scripts, pause_location["callFrames"]?[0]["location"]); - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody5", "StaticMethod1", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody5.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 48, 12, scripts, top_frame["location"]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_AddingNewMethod() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 55, 12, use_regex: true); - var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 59, 12, use_regex: true); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 55, 12, scripts, pause_location["callFrames"]?[0]["location"]); - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody6", "NewMethodStatic", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody6.NewMethodStatic", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 59, 12, scripts, top_frame["location"]); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 60, 12, "ApplyUpdateReferencedAssembly.MethodBody6.NewMethodStatic", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 20); - await Task.CompletedTask; - } - ); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_AddingNewStaticField() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 55, 12, use_regex: true); - var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 59, 12, use_regex: true); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 55, 12, scripts, pause_location["callFrames"]?[0]["location"]); - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody6", "NewMethodStatic", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody6.NewMethodStatic", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 59, 12, scripts, top_frame["location"]); - - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 61, 12, "ApplyUpdateReferencedAssembly.MethodBody6.NewMethodStatic", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 20); - await Task.CompletedTask; - }, times: 2 - ); - await EvaluateOnCallFrameAndCheck(top_frame["callFrameId"].Value(), - ("ApplyUpdateReferencedAssembly.MethodBody6.newStaticField", TNumber(10))); - - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_AddingNewClass() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 55, 12, use_regex: true); - var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 73, 12, use_regex: true); - var bp_invalid1 = await SetBreakpoint(".*/MethodBody1.cs$", 83, 12, use_regex: true); - var bp_invalid2 = await SetBreakpoint(".*/MethodBody1.cs$", 102, 12, use_regex: true); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 55, 12, scripts, pause_location["callFrames"]?[0]["location"]); - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody7", "StaticMethod1", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody7.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 73, 12, scripts, top_frame["location"]); - - pause_location = await StepAndCheck(StepKind.Resume, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 83, 12, "ApplyUpdateReferencedAssembly.MethodBody7.InstanceMethod", - locals_fn: async (locals) => - { - CheckNumber(locals, "aLocal", 50); - await Task.CompletedTask; - } - ); - - var props = await GetObjectOnFrame(pause_location["callFrames"][0], "this"); - Assert.Equal(3, props.Count()); - CheckNumber(props, "attr1", 15); - await CheckString(props, "attr2", "20"); - - await EvaluateOnCallFrameAndCheck(pause_location["callFrames"]?[0]["callFrameId"].Value(), - ("ApplyUpdateReferencedAssembly.MethodBody7.staticField", TNumber(80))); - - //apply second update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody8", "StaticMethod1", 2); - - top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody8.InstanceMethod", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 102, 12, scripts, top_frame["location"]); - - await EvaluateOnCallFrameAndCheck(pause_location["callFrames"]?[0]["callFrameId"].Value(), - ("ApplyUpdateReferencedAssembly.MethodBody8.staticField", TNumber(80))); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_AddingNewMethodWithoutAnyOtherChange() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly2.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly2.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly2.dll"); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "AddMethod", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody2.cs" }); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 12, 12, scripts, pause_location["callFrames"]?[0]["location"]); - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "AddMethod", "StaticMethod2", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.AddMethod.StaticMethod2", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 18, 12, scripts, top_frame["location"]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_AddingNewMethodWithoutAnyOtherChange_WithoutSDB() - { - var pause_location = await LoadAssemblyAndTestHotReload( - Path.Combine(DebuggerTestAppPath, $"ApplyUpdateReferencedAssembly2.dll"), - Path.Combine(DebuggerTestAppPath, $"ApplyUpdateReferencedAssembly2.pdb"), - Path.Combine(DebuggerTestAppPath, $"../wasm/ApplyUpdateReferencedAssembly2.dll"), - "AddMethod", "StaticMethod1", expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody2.cs" }, "StaticMethod2"); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 12, 12, scripts, pause_location["callFrames"]?[0]["location"]); - await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", $"dotnet://ApplyUpdateReferencedAssembly2.dll/MethodBody2.cs", 18, 12, "ApplyUpdateReferencedAssembly.AddMethod.StaticMethod2"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReload_NewInstanceFields() - { - string asm_name = "ApplyUpdateReferencedAssembly3"; - string asm_file = Path.Combine (DebuggerTestAppPath, asm_name + ".dll"); - string pdb_file = Path.Combine (DebuggerTestAppPath, asm_name + ".pdb"); - string asm_file_hot_reload = Path.Combine (DebuggerTestAppPath, "..", "wasm", asm_name+ ".dll"); - var pause_location = await LoadAssemblyAndTestHotReload(asm_file, pdb_file, asm_file_hot_reload, "AddInstanceFields", "StaticMethod1", - expectBpResolvedEvent: false, sourcesToWait: new string [] { "MethodBody2.cs" }); - var frame = pause_location["callFrames"][0]; - var locals = await GetProperties(frame["callFrameId"].Value()); - await CheckObject(locals, "c", "ApplyUpdateReferencedAssembly.AddInstanceFields.C"); - await SendCommandAndCheck (JObject.FromObject(new { }), "Debugger.resume", script_loc: null, line: -1, column: -1, function_name: null, - locals_fn: async (locals) => { - await CheckObject(locals, "c", "ApplyUpdateReferencedAssembly.AddInstanceFields.C"); - var c = await GetObjectOnLocals(locals, "c"); - await CheckProps (c, new { - Field1 = TNumber(123), - }, "c", num_fields: 1); - var cObj = GetAndAssertObjectWithName (locals, "c"); - await SetValueOnObject (cObj, "Field1", "456.5"); - - c = await GetObjectOnLocals(locals, "c"); - await CheckProps (c, new { - Field1 = TNumber("456.5", isDecimal: true), - }, "c", num_fields: 1); - }); - await SendCommandAndCheck (JObject.FromObject(new { }), "Debugger.resume", script_loc: null, line: -1, column: -1, function_name: null, - locals_fn: async (locals) => { - await CheckObject(locals, "c", "ApplyUpdateReferencedAssembly.AddInstanceFields.C"); - var c = await GetObjectOnLocals(locals, "c"); - await CheckProps (c, new { - Field1 = TNumber(123), - Field2 = TString("spqr"), - Field3Unused = TString(null), - }, "c", num_fields: 3); - }); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_AddingNewClassUsingDebugAttribute() - { - await SetJustMyCode(true); - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - await SetBreakpoint(".*/MethodBody1.cs$", 55, 12, use_regex: true); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody6", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 55, 12, scripts, pause_location["callFrames"]?[0]["location"]); - await SetBreakpoint(".*/MethodBody1.cs$", 118, 12, use_regex: true); - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody10", "StaticMethod1", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody10.StaticMethod1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 118, 12, scripts, top_frame["location"]); - - await StepAndCheck(StepKind.Into, $"dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 119, 12, "ApplyUpdateReferencedAssembly.MethodBody10.StaticMethod1"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugHotReloadMethod_AddingNewMethodAndThrowException() - { - //await SetPauseOnException("all"); - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 129, 12, use_regex: true); - var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 133, 12, use_regex: true); - - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody11", "StaticMethod1", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 129, 12, scripts, pause_location["callFrames"]?[0]["location"]); - //apply first update - pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - asm_file_hot_reload, "MethodBody11", "NewMethodStaticWithThrow", 1); - - JToken top_frame = pause_location["callFrames"]?[0]; - AssertEqual("ApplyUpdateReferencedAssembly.MethodBody11.NewMethodStaticWithThrow", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 133, 12, scripts, top_frame["location"]); - await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 134, 12, "ApplyUpdateReferencedAssembly.MethodBody11.NewMethodStaticWithThrow", - locals_fn: async (locals) => - { - CheckNumber(locals, "i", 20); - await Task.CompletedTask; - } - ); - - await SetPauseOnException("all"); - - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null); - - await CheckValue(pause_location["data"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "System.Exception", - uncaught = false - }), "exception0.data"); - - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null); - try - { - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", null, 0, 0, null); - } - catch (System.Exception ae) - { - System.Console.WriteLine(ae); - var eo = JObject.Parse(ae.Message); - - AssertEqual("Uncaught", eo["exceptionDetails"]?["text"]?.Value(), "text"); - - await CheckValue(eo["exceptionDetails"]?["exception"], JObject.FromObject(new - { - type = "object", - subtype = "error", - className = "Error" - }), "exception"); - } - } - // Enable this test when https://github.com/dotnet/hotreload-utils/pull/264 flows into dotnet/runtime repo - // [ConditionalFact(nameof(RunningOnChrome))] - // public async Task DebugHotReloadMethod_ChangeParameterName() - // { - // string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - // string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - // string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - // var bp_notchanged = await SetBreakpoint(".*/MethodBody1.cs$", 89, 12, use_regex: true); - // // var bp_invalid = await SetBreakpoint(".*/MethodBody1.cs$", 59, 12, use_regex: true); - - // var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - // asm_file, pdb_file, "MethodBody9", "test", expectBpResolvedEvent: true, sourcesToWait: new string [] { "MethodBody0.cs", "MethodBody1.cs" }); - - // CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 89, 12, scripts, pause_location["callFrames"]?[0]["location"]); - // await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 90, 12, "ApplyUpdateReferencedAssembly.MethodBody9.M1", - // locals_fn: async (locals) => - // { - // CheckNumber(locals, "a", 1); - // await Task.CompletedTask; - // } - // ); - // //apply first update - // pause_location = await LoadAssemblyAndTestHotReloadUsingSDB( - // asm_file_hot_reload, "MethodBody9", "test", 1); - - // JToken top_frame = pause_location["callFrames"]?[0]; - // AssertEqual("ApplyUpdateReferencedAssembly.MethodBody9.M1", top_frame?["functionName"]?.Value(), top_frame?.ToString()); - // CheckLocation("dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 89, 12, scripts, top_frame["location"]); - // await StepAndCheck(StepKind.Over, "dotnet://ApplyUpdateReferencedAssembly.dll/MethodBody1.cs", 90, 12, "ApplyUpdateReferencedAssembly.MethodBody9.M1", - // locals_fn: async (locals) => - // { - // CheckNumber(locals, "x", 1); - // await Task.CompletedTask; - // } - // ); - // } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs b/src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs deleted file mode 100644 index 6a333cdd851bbe..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/Inspector.cs +++ /dev/null @@ -1,469 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using System.Runtime.ExceptionServices; -using Xunit.Abstractions; -using System.Collections.Concurrent; - -#nullable enable - -namespace DebuggerTests -{ - class Inspector - { - // https://console.spec.whatwg.org/#formatting-specifiers - private static Regex _consoleArgsRegex = new(@"(%[sdifoOc])", RegexOptions.Compiled); - - ConcurrentDictionary> notifications = new(); - ConcurrentDictionary>> eventListeners = new(); - ConcurrentQueue<(string, JObject)> nextNotifications = new(); //in a multithreaded runtime we can receive more than one pause at same time - public const string PAUSE = "pause"; - public const string APP_READY = "app-ready"; - public CancellationToken Token { get; set; } - public InspectorClient Client { get; } - public DebuggerProxyBase? Proxy { get; } - public bool DetectAndFailOnAssertions { get; set; } = true; - - private CancellationTokenSource _cancellationTokenSource; - private Exception? _isFailingWithException; - private bool _gotRuntimeReady = false; - private bool _gotAppReady = false; - - protected static Lazy s_loggerFactory = new(() => - LoggerFactory.Create(builder => - { - if (TestOptions.LogToConsole) - { - builder - .AddSimpleConsole(options => - { - options.SingleLine = true; - options.TimestampFormat = "[HH:mm:ss] "; - }) - .AddFilter(null, LogLevel.Debug); - // .AddFile(logFilePath, minimumLevel: LogLevel.Debug) - } - })); - - protected ILogger _logger; - public int Id { get; init; } - - public Inspector(int testId, ITestOutputHelper testOutput) - { - Id = testId; - _cancellationTokenSource = new CancellationTokenSource(); - Token = _cancellationTokenSource.Token; - - if (Id == 0) - s_loggerFactory.Value.AddXunit(testOutput); - - _logger = s_loggerFactory.Value - .CreateLogger($"{nameof(Inspector)}-{Id}"); - if (DebuggerTestBase.RunningOnChrome) - Client = new InspectorClient(_logger); - else - Client = new FirefoxInspectorClient(_logger); - } - - public Task WaitFor(string what) - { - if (notifications.TryGetValue(what, out TaskCompletionSource? tcs)) - { - if (tcs.Task.IsCompleted) - { - Client.CurrentSessionId = new SessionId(tcs.Task.Result["sessionId"]?.Value()); - notifications.Remove(what, out _); - return tcs.Task; - } - - throw new Exception($"Invalid internal state, waiting for {what} while another wait is already setup"); - } - else if (nextNotifications.TryDequeue(out (string what, JObject args) notification)) - { - var n = new TaskCompletionSource(); - Client.CurrentSessionId = new SessionId(notification.args["sessionId"]?.Value()); - if (what != notification.what) - throw new Exception($"Unexpected different notification type"); - n.SetResult(notification.args); - return n.Task; - } - else - { - var n = new TaskCompletionSource(); - notifications[what] = n; - return n.Task; - } - } - - public void ClearWaiterFor(string what) - { - if (notifications.ContainsKey(what)) - notifications.Remove(what, out _); - } - - void NotifyOf(string what, JObject args) - { - if (notifications.TryGetValue(what, out TaskCompletionSource? tcs)) - { - if (tcs.Task.IsCompleted) - { - nextNotifications.Enqueue((what, args)); - return; - //throw new Exception($"Invalid internal state. Notifying for {what} again, but the previous one hasn't been read."); - } - Client.CurrentSessionId = new SessionId(args["sessionId"]?.Value()); - notifications[what].SetResult(args); - notifications.Remove(what, out _); - } - else - { - var n = new TaskCompletionSource(); - notifications[what] = n; - n.SetResult(args); - } - } - - public void On(string evtName, Func> cb) - { - eventListeners[evtName] = cb; - } - - public Task WaitForEvent(string evtName) - { - var eventReceived = new TaskCompletionSource(); - On(evtName, async (args, token) => - { - eventReceived.SetResult(args); - return await Task.FromResult(ProtocolEventHandlerReturn.RemoveHandler); - }); - - return eventReceived.Task.WaitAsync(Token); - } - - void FailAllWaiters(Exception? exception = null) - { - // Because we can create already completed tasks, - // when we get a NotifyOf before the corresponding - // WaitFor, it might already be completed. So, use - // *Try* methods - - if (exception != null) - { - _isFailingWithException = exception; - foreach (var tcs in notifications.Values) - tcs.TrySetException(exception); - } - else - { - foreach (var tcs in notifications.Values) - tcs.TrySetCanceled(); - } - } - - internal (string line, string type) FormatConsoleAPICalled(JObject args) - { - string? type = args?["type"]?.Value(); - List consoleArgs = new(); - foreach (JToken? arg in args?["args"] ?? Enumerable.Empty()) - { - if (arg?["value"] != null) - consoleArgs.Add(arg!["value"]!.ToString()); - } - - type ??= "log"; - if (consoleArgs.Count == 0) - return (line: "console: ", type); - - int position = 1; - string first = consoleArgs[0]; - string output = _consoleArgsRegex.Replace(first, (_) => $"{consoleArgs[position++]}"); - if (position == 1) - { - // first arg wasn't a format string so concat things together - // with a space instead. - StringBuilder builder = new StringBuilder(first); - for (position = 1; position < consoleArgs.Count(); position++) - { - builder.Append(" "); - builder.Append(consoleArgs[position]); - } - output = builder.ToString(); - } - else - { - if (output.EndsWith('\n')) - output = output[..^1]; - } - - return ($"console.{type}: {output}", type); - } - - async Task OnMessage(string sessionId, string method, JObject args, CancellationToken token) - { - bool fail = false; - switch (method) - { - case "Target.attachedToTarget": - { - var sessionIdNewTarget = new SessionId(args["sessionId"]?.Value()); - await Client.SendCommand(sessionIdNewTarget, "Profiler.enable", null, token); - await Client.SendCommand(sessionIdNewTarget, "Runtime.enable", null, token); - await Client.SendCommand(sessionIdNewTarget, "Debugger.enable", null, token); - await Client.SendCommand(sessionIdNewTarget, "Runtime.runIfWaitingForDebugger", null, token); - await Client.SendCommand(sessionIdNewTarget, "Debugger.setAsyncCallStackDepth", JObject.FromObject(new { maxDepth = 32}), token); - break; - } - case "Debugger.paused": - { - if (sessionId != "") - args.Add("sessionId", sessionId); - NotifyOf(PAUSE, args); - break; - } - case "Mono.runtimeReady": - { - _gotRuntimeReady = true; - if (_gotAppReady || !DebuggerTestBase.RunningOnChrome) - { - // got both the events - NotifyOf(APP_READY, args); - } - break; - } - case "Runtime.consoleAPICalled": - { - (string line, string type) = FormatConsoleAPICalled(args); - switch (type) - { - case "log": _logger.LogInformation(line); break; - case "debug": _logger.LogDebug(line); break; - case "error": _logger.LogError(line); break; - case "warn": _logger.LogWarning(line); break; - case "trace": _logger.LogTrace(line); break; - default: _logger.LogInformation(line); break; - } - if (line == "console.debug: #debugger-app-ready#") - await Client.SendCommand("DotnetDebugger.runTests", JObject.FromObject(new { type = "DotnetDebugger.runTests", to = "root" }), token); - - if (!_gotAppReady && line == "console.debug: #debugger-app-ready#") - { - _gotAppReady = true; - - if (_gotRuntimeReady) - { - // got both the events - NotifyOf(APP_READY, args); - } - } - - if (DetectAndFailOnAssertions && - (line.Contains("console.error: [MONO]") || line.Contains("console.warning: [MONO]"))) - { - args["__forMethod"] = method; - Client.Fail(new ArgumentException($"Unexpected runtime error/warning message detected: {line}{Environment.NewLine}{args}")); - TestHarnessProxy.ShutdownProxy(Id.ToString()); - return; - } - - break; - } - case "Inspector.detached": - case "Inspector.targetCrashed": - case "Inspector.targetReloadedAfterCrash": - fail = true; - break; - case "Runtime.exceptionThrown": - _logger.LogDebug($"Failing all waiters because: {method}: {args}"); - fail = true; - break; - } - if (eventListeners.TryGetValue(method, out Func>? listener) - && listener != null) - { - if (sessionId != "") - args.Add("sessionId", sessionId); - ProtocolEventHandlerReturn result = await listener(args, token).ConfigureAwait(false); - if (result is ProtocolEventHandlerReturn.RemoveHandler) - eventListeners.Remove(method, out _); - } - else if (fail) - { - args["__forMethod"] = method; - FailAllWaiters(new ArgumentException(args.ToString())); - } - } - - public async Task LaunchBrowser(DateTime start, TimeSpan span) - { - if (!System.Diagnostics.Debugger.IsAttached) - _cancellationTokenSource.CancelAfter(span); - string uriStr = $"ws://{TestHarnessProxy.Endpoint.Authority}/launch-host-and-connect/?test_id={Id}"; - if (!DebuggerTestBase.RunningOnChrome) - { - uriStr += $"&host=firefox&firefox-proxy-port={DebuggerTestBase.FirefoxProxyPort}"; - // Ensure the listener is running early, so trying to - // connect to that does not race with the starting of it - FirefoxDebuggerProxy.StartListener(DebuggerTestBase.FirefoxProxyPort, _logger); - } - - await Client.Connect(new Uri(uriStr), OnMessage, _cancellationTokenSource); - Client.RunLoopStopped += (_, args) => - { - switch (args.reason) - { - case RunLoopStopReason.Exception: - if (TestHarnessProxy.TryGetProxyExitState(Id.ToString(), out var state)) - { - Console.WriteLine ($"client exiting with exception, and proxy has: {state}"); - } - FailAllWaiters(args.exception); - break; - - case RunLoopStopReason.Cancelled when Token.IsCancellationRequested: - if (_isFailingWithException is null) - FailAllWaiters(new TaskCanceledException($"Test timed out (elapsed time: {(DateTime.Now - start).TotalSeconds})")); - break; - - default: - if (_isFailingWithException is null) - FailAllWaiters(); - break; - }; - }; - - TestHarnessProxy.RegisterExitHandler(Id.ToString(), state => - { - if (_isFailingWithException is null && state.reason == RunLoopStopReason.Exception) - { - Client.Fail(state.exception); - FailAllWaiters(state.exception); - } - }); - } - - public async Task OpenSessionAsync(Func)>> getInitCmds, string urlToInspect, TimeSpan span) - { - var start = DateTime.Now; - try - { - await LaunchBrowser(start, span); - var init_cmds = getInitCmds(Client, _cancellationTokenSource.Token); - - Task readyTask = Task.Run(async () => Result.FromJson(await WaitFor(APP_READY))); - init_cmds.Add((APP_READY, readyTask)); - - _logger.LogInformation("waiting for the runtime to be ready"); - while (!_cancellationTokenSource.IsCancellationRequested && init_cmds.Count > 0) - { - var cmd_tasks = init_cmds.Select(ct => ct.Item2); - Task completedTask = await Task.WhenAny(cmd_tasks); - - int cmdIdx = init_cmds.FindIndex(ct => ct.Item2 == completedTask); - string cmd_name = init_cmds[cmdIdx].Item1; - - if (_isFailingWithException is not null) - { - _logger.LogError($"_isFailingWithException. {_isFailingWithException}."); - throw _isFailingWithException; - } - - if (completedTask.IsCanceled) - { - throw new TaskCanceledException( - $"Command {cmd_name} timed out during init for the test." + - $"Remaining commands: {RemainingCommandsToString(cmd_name, init_cmds)}." + - $"Total time: {(DateTime.Now - start).TotalSeconds}"); - } - - if (completedTask.IsFaulted) - { - _logger.LogError($"Command {cmd_name} failed with {completedTask.Exception}. Remaining commands: {RemainingCommandsToString(cmd_name, init_cmds)}."); - throw completedTask.Exception!; - } - - await Client.ProcessCommand(completedTask.Result, _cancellationTokenSource.Token); - Result res = completedTask.Result; - - if (!res.IsOk) - throw new ArgumentException($"Command {cmd_name} failed with: {res.Error}. Remaining commands: {RemainingCommandsToString(cmd_name, init_cmds)}"); - - if (DebuggerTestBase.RunningOnChrome && cmd_name == "Debugger.enable") - await Client.SendCommand("Page.navigate", JObject.FromObject(new { url = urlToInspect }), _cancellationTokenSource.Token); - init_cmds.RemoveAt(cmdIdx); - } - - _logger.LogInformation("runtime ready, TEST TIME"); - } - catch (Exception ex) - { - _logger.LogDebug(ex.ToString()); - if (TestHarnessProxy.TryGetProxyExitState(Id.ToString(), out var state)) - { - Console.WriteLine ($"OpenSession crashing. proxy state: {state}"); - if (state.reason == RunLoopStopReason.Exception && state.exception is not null) - ExceptionDispatchInfo.Capture(state.exception).Throw(); - } - - throw; - } - - static string RemainingCommandsToString(string cmd_name, IList<(string, Task)> cmds) - { - var sb = new StringBuilder(); - for (int i = 0; i < cmds.Count; i++) - { - var (name, task) = cmds[i]; - - if (cmd_name == name) - continue; - - sb.Append($"[{name}: {task.Status}], "); - } - - if (sb.Length > 2) - sb.Length -= 2; - - return sb.ToString(); - } - } - - public async Task ShutdownAsync() - { - if (Client == null) - throw new InvalidOperationException($"InspectorClient is null. Duplicate Shutdown?"); - - try - { - TestHarnessProxy.ShutdownProxy(Id.ToString()); - await Client.ShutdownAsync(_cancellationTokenSource.Token).ConfigureAwait(false); - } - catch (Exception ex) - { - _logger?.LogError(ex.ToString()); - throw; - } - finally - { - _cancellationTokenSource.Cancel(); - Client.Dispose(); - _cancellationTokenSource.Dispose(); - } - } - } - - public enum ProtocolEventHandlerReturn - { - KeepHandler, - RemoveHandler - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/InspectorClient.cs b/src/mono/browser/debugger/DebuggerTestSuite/InspectorClient.cs deleted file mode 100644 index 16f715ecd7137f..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/InspectorClient.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Concurrent; -using System.Net; -using System.Net.Sockets; -using System.Net.WebSockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; - -namespace DebuggerTests -{ - internal class InspectorClient : DevToolsClient - { - protected readonly ConcurrentDictionary> pending_cmds = new(); - protected Func onEvent; - protected int next_cmd_id; - - public SessionId CurrentSessionId { get; set; } = SessionId.Null; - - public InspectorClient(ILogger logger) : base(logger) { } - - protected override async Task SetupConnection(Uri webserverUri, CancellationToken token) - => new DevToolsDebuggerConnection( - await ConnectToWebServer(webserverUri, token), - "client", - logger); - - protected virtual Task HandleMessage(string msg, CancellationToken token) - { - var res = JObject.Parse(msg); - - if (res["id"] == null) - return onEvent(res["sessionId"]?.Value(), res["method"].Value(), res["params"] as JObject, token); - - var id = res.ToObject(); - if (!pending_cmds.TryRemove(id, out var item)) - logger.LogError($"Unable to find command {id}"); - - item.SetResult(Result.FromJson(res)); - return null; - } - - public virtual async Task ProcessCommand(Result command, CancellationToken token) - { - await Task.FromResult(true); - } - - public virtual async Task Connect( - Uri uri, - Func onEvent, - CancellationTokenSource cts) - { - this.onEvent = onEvent; - - RunLoopStopped += (_, args) => - { - logger.LogDebug($"Failing {pending_cmds.Count} pending cmds"); - if (args.reason == RunLoopStopReason.Exception) - { - foreach (var cmd in pending_cmds.Values) - cmd.SetException(args.exception); - } - else - { - foreach (var cmd in pending_cmds.Values) - cmd.SetCanceled(); - } - }; - - await ConnectAndStartRunLoopAsync(uri, HandleMessage, cts); - } - - public Task SendCommand(string method, JObject args, CancellationToken token) - => SendCommand(CurrentSessionId, method, args, token); - - public virtual Task SendCommand(SessionId sessionId, string method, JObject args, CancellationToken token) - { - int id = Interlocked.Increment(ref next_cmd_id); - if (args == null) - args = new JObject(); - - var o = JObject.FromObject(new - { - id = id, - method = method, - @params = args - }); - - if (sessionId != SessionId.Null) - o.Add("sessionId", sessionId.sessionId); - var tcs = new TaskCompletionSource(); - - MessageId msgId = new MessageId(sessionId.sessionId, id); - pending_cmds.AddOrUpdate(msgId, tcs, (key, oldValue) => tcs); - - var str = o.ToString(); - - var bytes = Encoding.UTF8.GetBytes(str); - Send(bytes, token); - return tcs.Task; - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs deleted file mode 100644 index 555c23a79b6d3f..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/MiscTests.cs +++ /dev/null @@ -1,1223 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly)] - -namespace DebuggerTests -{ - - public class MiscTests : DebuggerTests - { - public MiscTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [Fact] - public void CheckThatAllSourcesAreSent() - { - Assert.Contains("dotnet://debugger-test.dll/debugger-test.cs", scripts.Values); - Assert.Contains("dotnet://debugger-test.dll/debugger-test2.cs", scripts.Values); - Assert.Contains("dotnet://debugger-test.dll/dependency.cs", scripts.Values); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task ExceptionThrownInJS() - { - var eval_req = JObject.FromObject(new - { - expression = "invoke_bad_js_test();" - }); - - var eval_res = await cli.SendCommand("Runtime.evaluate", eval_req, token); - Assert.False(eval_res.IsOk); - Assert.Equal("Uncaught", eval_res.Error["exceptionDetails"]?["text"]?.Value()); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task ExceptionThrownInJSOutOfBand() - { - await SetBreakpoint("/debugger-driver.html", 27, 2); - - var eval_req = JObject.FromObject(new - { - expression = "window.setTimeout(function() { invoke_bad_js_test(); }, 1);", - }); - - var task = insp.WaitFor("Runtime.exceptionThrown"); - var eval_res = await cli.SendCommand("Runtime.evaluate", eval_req, token); - // Response here will be the id for the timer from JS! - Assert.True(eval_res.IsOk); - - var ex = await Assert.ThrowsAsync(async () => await task); - var ex_json = JObject.Parse(ex.Message); - Assert.Equal(dicFileToUrl["/debugger-driver.html"], ex_json["exceptionDetails"]?["url"]?.Value()); - } - - [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsAtBreakpointSite(bool use_cfo) => - await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "Math.IntAdd", - "window.setTimeout(function() { invoke_add(); }, 1);", - use_cfo: use_cfo, - test_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - CheckNumber(locals, "c", 30); - CheckNumber(locals, "d", 0); - CheckNumber(locals, "e", 0); - await Task.CompletedTask; - } - ); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task InspectPrimitiveTypeLocalsAtBreakpointSite() => - await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", 154, 8, "Math.PrimitiveTypesTest", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] Math:PrimitiveTypesTest'); }, 1);", - test_fn: async (locals) => - { - await CheckSymbol(locals, "c0", '\u20AC'); - await CheckSymbol(locals, "c1", 'A'); - await Task.CompletedTask; - } - ); - - [Fact] - public async Task InspectLocalsTypesAtBreakpointSite() => - await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test2.cs", 50, 8, "Fancy.Types", - "window.setTimeout(function() { invoke_static_method (\"[debugger-test] Fancy:Types\")(); }, 1);", - use_cfo: false, - test_fn: async (locals) => - { - CheckNumber(locals, "dPI", Math.PI); - CheckNumber(locals, "fPI", (float)Math.PI); - CheckNumber(locals, "iMax", int.MaxValue); - CheckNumber(locals, "iMin", int.MinValue); - CheckNumber(locals, "uiMax", uint.MaxValue); - CheckNumber(locals, "uiMin", uint.MinValue); - - CheckNumber(locals, "l", uint.MaxValue * (long)2); - //CheckNumber (locals, "lMax", long.MaxValue); // cannot be represented as double - //CheckNumber (locals, "lMin", long.MinValue); // cannot be represented as double - - CheckNumber(locals, "sbMax", sbyte.MaxValue); - CheckNumber(locals, "sbMin", sbyte.MinValue); - CheckNumber(locals, "bMax", byte.MaxValue); - CheckNumber(locals, "bMin", byte.MinValue); - - CheckNumber(locals, "sMax", short.MaxValue); - CheckNumber(locals, "sMin", short.MinValue); - CheckNumber(locals, "usMin", ushort.MinValue); - CheckNumber(locals, "usMax", ushort.MaxValue); - await Task.CompletedTask; - } - ); - - [Fact] - public async Task InspectSimpleStringLocals() => - await CheckInspectLocalsAtBreakpointSite( - "Math", "TestSimpleStrings", 13, "Math.TestSimpleStrings", - "window.setTimeout(function() { invoke_static_method ('[debugger-test] Math:TestSimpleStrings')(); }, 1);", - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var str_null = TString(null); - var str_empty = TString(String.Empty); - var str_spaces = TString(" "); - var str_esc = TString("\\"); - - await CheckProps(locals, new - { - str_null, - str_empty, - str_spaces, - str_esc, - - strings = TArray("string[]", "string[4]") - }, "locals"); - - var strings_arr = await GetObjectOnLocals(locals, "strings"); - await CheckProps(strings_arr, new[] - { - str_null, - str_empty, - str_spaces, - str_esc - }, "locals#strings"); - } - ); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("TestNullableLocal", false)] - [InlineData("TestNullableLocalAsync", true)] - public async Task InspectNullableLocals(string method_name, bool is_async) => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.NullableTests", - method_name, - 10, - $"DebuggerTests.NullableTests.{method_name}", - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTests.NullableTests:{method_name}'); }}, 1);", - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var dt = new DateTime(2310, 1, 2, 3, 4, 5); - await CheckProps(locals, new - { - n_int = TNumber(5), - n_int_null = TObject("System.Nullable", null), - - n_dt = TDateTime(dt), - n_dt_null = TObject("System.Nullable", null), - - n_gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - n_gs_null = TObject("System.Nullable>", null), - }, "locals"); - - // check gs - - var n_gs = GetAndAssertObjectWithName(locals, "n_gs"); - var n_gs_props = await GetProperties(n_gs["value"]?["objectId"]?.Value()); - await CheckProps(n_gs_props, new - { - List = TObject("System.Collections.Generic.List", is_null: true), - StringField = TString("n_gs#StringField"), - Options = TEnum("DebuggerTests.Options", "None") - }, nameof(n_gs)); - }); - - [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsWithGenericTypesAtBreakpointSite(bool use_cfo) => - await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-test.cs", 74, 8, "Math.GenericTypesTest", - "window.setTimeout(function() { invoke_generic_types_test (); }, 1);", - use_cfo: use_cfo, - test_fn: async (locals) => - { - await CheckObject(locals, "list", "System.Collections.Generic.Dictionary", description: "Count = 0"); - await CheckObject(locals, "list_null", "System.Collections.Generic.Dictionary", is_null: true); - - await CheckArray(locals, "list_arr", "System.Collections.Generic.Dictionary[]", "System.Collections.Generic.Dictionary[1]"); - await CheckObject(locals, "list_arr_null", "System.Collections.Generic.Dictionary[]", is_null: true); - - // Unused locals - await CheckObject(locals, "list_unused", "System.Collections.Generic.Dictionary", description: "Count = 0"); - await CheckObject(locals, "list_null_unused", "System.Collections.Generic.Dictionary", is_null: true); - - await CheckArray(locals, "list_arr_unused", "System.Collections.Generic.Dictionary[]", "System.Collections.Generic.Dictionary[1]"); - await CheckObject(locals, "list_arr_null_unused", "System.Collections.Generic.Dictionary[]", is_null: true); - await Task.CompletedTask; - } - ); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task RuntimeGetPropertiesWithInvalidScopeIdTest() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 49, 8); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_delegates_test (); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 49, 8, - "Math.DelegatesTest", - wait_for_event_fn: async (pause_location) => - { - //make sure we're on the right bp - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - - var scope = top_frame["scopeChain"][0]; - - // Try to get an invalid scope! - var get_prop_req = JObject.FromObject(new - { - objectId = "dotnet:scope:23490871", - }); - - var frame_props = await cli.SendCommand("Runtime.getProperties", get_prop_req, token); - Assert.False(frame_props.IsOk); - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsWithStructs(bool use_cfo) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; - - await SetBreakpoint(debugger_test_loc, 24, 8); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_method_with_structs(); }, 1);", - debugger_test_loc, 24, 8, "DebuggerTests.ValueTypesTest.MethodWithLocalStructs"); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(locals, new - { - ss_local = TValueType("DebuggerTests.ValueTypesTest.SimpleStruct"), - gs_local = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - vt_local = TObject("DebuggerTests.ValueTypesTest") - }, "locals"); - - var dt = new DateTime(2021, 2, 3, 4, 6, 7); - var vt_local_props = await GetObjectOnFrame(pause_location["callFrames"][0], "vt_local"); - Assert.Equal(5, vt_local_props.Count()); - - await CheckString(vt_local_props, "StringField", "string#0"); - await CheckValueType(vt_local_props, "SimpleStructField", "DebuggerTests.ValueTypesTest.SimpleStruct"); - await CheckValueType(vt_local_props, "SimpleStructProperty", "DebuggerTests.ValueTypesTest.SimpleStruct"); - await CheckDateTime(vt_local_props, "DT", new DateTime(2020, 1, 2, 3, 4, 5)); - await CheckEnum(vt_local_props, "RGB", "DebuggerTests.RGB", "Blue"); - - // Check ss_local's properties - var ss_local_props = await GetObjectOnFrame(pause_location["callFrames"][0], "ss_local"); - await CheckProps(ss_local_props, new - { - V = TGetter("V"), - str_member = TString("set in MethodWithLocalStructs#SimpleStruct#str_member"), - dt = TDateTime(dt), - gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - Kind = TEnum("System.DateTimeKind", "Utc") - }, "ss_local"); - - { - var gres = await InvokeGetter(GetAndAssertObjectWithName(locals, "ss_local"), "V"); - await CheckValue(gres.Value["result"], TNumber(0xDEADBEEF + 2), $"ss_local#V"); - - // Check ss_local.gs - var gs_props = await GetObjectOnLocals(ss_local_props, "gs"); - await CheckString(gs_props, "StringField", "set in MethodWithLocalStructs#SimpleStruct#gs#StringField"); - await CheckObject(gs_props, "List", "System.Collections.Generic.List", description: "Count = 1"); - } - - // Check gs_local's properties - var gs_local_props = await GetObjectOnFrame(pause_location["callFrames"][0], "gs_local"); - await CheckProps(gs_local_props, new - { - StringField = TString("gs_local#GenericStruct#StringField"), - List = TObject("System.Collections.Generic.List", is_null: true), - Options = TEnum("DebuggerTests.Options", "None") - }, "gs_local"); - - // Check vt_local's properties - - var exp = new[] - { - ("SimpleStructProperty", 2, "Utc"), - ("SimpleStructField", 5, "Local") - }; - - foreach (var (name, bias, dt_kind) in exp) - { - dt = new DateTime(2020 + bias, 1 + bias, 2 + bias, 3 + bias, 5 + bias, 6 + bias); - await CompareObjectPropertiesFor(vt_local_props, name, - new - { - V = TGetter("V"), - str_member = TString($"{name}#string#0#SimpleStruct#str_member"), - dt = TDateTime(dt), - gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - Kind = TEnum("System.DateTimeKind", dt_kind) - }, - label: $"vt_local_props.{name}"); - - var gres = await InvokeGetter(GetAndAssertObjectWithName(vt_local_props, name), "V"); - await CheckValue(gres.Value["result"], TNumber(0xDEADBEEF + (uint)dt.Month), $"{name}#V"); - } - - // FIXME: check ss_local.gs.List's members - } - - [Theory] - [InlineData("BoxingTest", false)] - [InlineData("BoxingTestAsync", true)] - public async Task InspectBoxedLocals(string method_name, bool is_async) => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTest", - method_name, - 17, - $"DebuggerTest.{method_name}", - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTest:{method_name}'); }}, 1);", - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var dt = new DateTime(2310, 1, 2, 3, 4, 5); - await CheckProps(locals, new - { - n_i = TNumber(5), - o_i = TNumber(5), - o_n_i = TNumber(5), - o_s = TString("foobar"), - o_obj = TObject("Math"), - - n_gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - o_gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - o_n_gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - - n_dt = TDateTime(dt), - o_dt = TDateTime(dt), - o_n_dt = TDateTime(dt), - - o_null = TObject("object", is_null: true), - o_ia = TArray("int[]", "int[2]"), - }, "locals"); - - foreach (var name in new[] { "n_gs", "o_gs", "o_n_gs" }) - { - var gs = GetAndAssertObjectWithName(locals, name); - var gs_props = await GetProperties(gs["value"]?["objectId"]?.Value()); - await CheckProps(gs_props, new - { - List = TObject("System.Collections.Generic.List", is_null: true), - StringField = TString("n_gs#StringField"), - Options = TEnum("DebuggerTests.Options", "None") - }, name); - } - - var o_ia_props = await GetObjectOnLocals(locals, "o_ia"); - await CheckProps(o_ia_props, new[] - { - TNumber(918), - TNumber(58971) - }, nameof(o_ia_props)); - }); - - [Theory] - [InlineData("BoxedTypeObjectTest", false)] - [InlineData("BoxedTypeObjectTestAsync", true)] - public async Task InspectBoxedTypeObject(string method_name, bool is_async) => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTest", - method_name, - 9, - $"DebuggerTest.{method_name}", - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTest:{method_name}'); }}, 1);", - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var dt = new DateTime(2310, 1, 2, 3, 4, 5); - await CheckProps(locals, new - { - i = TNumber(5), - o0 = TNumber(5), - o1 = TNumber(5), - o2 = TNumber(5), - o3 = TNumber(5), - - oo = TObject("object"), - oo0 = TObject("object"), - }, "locals"); - }); - - [Theory] - [InlineData("BoxedAsClass", false)] - [InlineData("BoxedAsClassAsync", true)] - public async Task InspectBoxedAsClassLocals(string method_name, bool is_async) => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTest", - method_name, - 6, - $"DebuggerTest.{method_name}", - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTest:{method_name}'); }}, 1);", - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var dt = new DateTime(2310, 1, 2, 3, 4, 5); - - await CheckProps(locals, new - { - vt_dt = TDateTime(new DateTime(4819, 5, 6, 7, 8, 9)), - vt_gs = TValueType("Math.GenericStruct"), - e = TEnum("System.IO.FileMode", "0"), - ee = TEnum("System.IO.FileMode", "Append") - }, "locals"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsWithStructsStaticAsync(bool use_cfo) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; - - await SetBreakpoint(debugger_test_loc, 54, 12); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async (" + - "'[debugger-test] DebuggerTests.ValueTypesTest:MethodWithLocalStructsStaticAsync'" + - "); }, 1);", - debugger_test_loc, 54, 12, "DebuggerTests.ValueTypesTest.MethodWithLocalStructsStaticAsync"); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(locals, new - { - ss_local = TObject("DebuggerTests.ValueTypesTest.SimpleStruct"), - gs_local = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - result = TBool(true) - }, - "locals#0"); - - var dt = new DateTime(2021, 2, 3, 4, 6, 7); - // Check ss_local's properties - var ss_local_props = await GetObjectOnFrame(pause_location["callFrames"][0], "ss_local"); - await CheckProps(ss_local_props, new - { - V = TGetter("V"), - str_member = TString("set in MethodWithLocalStructsStaticAsync#SimpleStruct#str_member"), - dt = TDateTime(dt), - gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - Kind = TEnum("System.DateTimeKind", "Utc") - }, "ss_local"); - - { - var gres = await InvokeGetter(GetAndAssertObjectWithName(locals, "ss_local"), "V"); - await CheckValue(gres.Value["result"], TNumber(0xDEADBEEF + 2), $"ss_local#V"); - - // Check ss_local.gs - await CompareObjectPropertiesFor(ss_local_props, "gs", - new - { - StringField = TString("set in MethodWithLocalStructsStaticAsync#SimpleStruct#gs#StringField"), - List = TObject("System.Collections.Generic.List", description: "Count = 1"), - Options = TEnum("DebuggerTests.Options", "Option1") - } - ); - } - - // Check gs_local's properties - var gs_local_props = await GetObjectOnFrame(pause_location["callFrames"][0], "gs_local"); - await CheckProps(gs_local_props, new - { - StringField = TString("gs_local#GenericStruct#StringField"), - List = TObject("System.Collections.Generic.List", description: "Count = 2"), - Options = TEnum("DebuggerTests.Options", "Option2") - }, "gs_local"); - - // FIXME: check ss_local.gs.List's members - } - - [Theory] - [InlineData(137, 12, "MethodWithLocalsForToStringTest", false, false)] - /*[InlineData(147, 12, "MethodWithArgumentsForToStringTest", true, false)] - [InlineData(192, 12, "MethodWithArgumentsForToStringTestAsync", true, true)] - [InlineData(182, 12, "MethodWithArgumentsForToStringTestAsync", false, true)]*/ - public async Task InspectLocalsForToStringDescriptions(int line, int col, string method_name, bool call_other, bool invoke_async) - { - string entry_method_name = $"[debugger-test] DebuggerTests.ValueTypesTest:MethodWithLocalsForToStringTest{(invoke_async ? "Async" : String.Empty)}"; - int frame_idx = 0; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; - - await SetBreakpoint(debugger_test_loc, line, col); - - var eval_expr = "window.setTimeout(function() {" + - (invoke_async ? "invoke_static_method_async (" : "invoke_static_method (") + - $"'{entry_method_name}'," + - (call_other ? "true" : "false") + - "); }, 1);"; - _testOutput.WriteLine($"{eval_expr}"); - - var pause_location = await EvaluateAndCheck(eval_expr, debugger_test_loc, line, col, $"DebuggerTests.ValueTypesTest.{method_name}{(invoke_async ? "Async" : String.Empty)}"); - - var dt0 = new DateTime(2020, 1, 2, 3, 4, 5); - var dt1 = new DateTime(2010, 5, 4, 3, 2, 1); - var ts = dt0 - dt1; - var dto = new DateTimeOffset(dt0, new TimeSpan(4, 5, 0)); - - var frame_locals = await GetProperties(pause_location["callFrames"][frame_idx]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - call_other = TBool(call_other), - dt0 = TDateTime(dt0), - dt1 = TDateTime(dt1), - dto = TValueType("System.DateTimeOffset", dto.ToString()), - ts = TValueType("System.TimeSpan", ts.ToString()), - dec = TValueType("System.Decimal", "123987123"), - guid = TValueType("System.Guid", "3D36E07E-AC90-48C6-B7EC-A481E289D014"), - dts = TArray("System.DateTime[]", "System.DateTime[2]"), - obj = TObject("DebuggerTests.ClassForToStringTests"), - sst = TObject("DebuggerTests.StructForToStringTests") - }, "locals#0"); - - var dts_0 = new DateTime(1983, 6, 7, 5, 6, 10); - var dts_1 = new DateTime(1999, 10, 15, 1, 2, 3); - var dts_elements = await GetObjectOnLocals(frame_locals, "dts"); - await CheckDateTime(dts_elements, "0", dts_0); - await CheckDateTime(dts_elements, "1", dts_1); - - // TimeSpan - await CompareObjectPropertiesFor(frame_locals, "ts", - new - { - Days = TNumber(3530), - Minutes = TNumber(2), - Seconds = TNumber(4), - }, "ts_props", skip_num_fields_check: true); - - // DateTimeOffset - await CompareObjectPropertiesFor(frame_locals, "dto", - new - { - Day = TNumber(2), - Year = TNumber(2020), - DayOfWeek = TEnum("System.DayOfWeek", "Thursday") - }, "dto_props", skip_num_fields_check: true); - - var DT = new DateTime(2004, 10, 15, 1, 2, 3); - var DTO = new DateTimeOffset(dt0, new TimeSpan(2, 14, 0)); - - await CompareObjectPropertiesFor(frame_locals, "obj", - new - { - DT = TDateTime(DT), - DTO = TValueType("System.DateTimeOffset", DTO.ToString()), - TS = TValueType("System.TimeSpan", ts.ToString()), - Dec = TValueType("System.Decimal", "1239871"), - Guid = TValueType("System.Guid", "3D36E07E-AC90-48C6-B7EC-A481E289D014") - }, "obj_props"); - - DTO = new DateTimeOffset(dt0, new TimeSpan(3, 15, 0)); - var sst_props = await CompareObjectPropertiesFor(frame_locals, "sst", - new - { - DT = TDateTime(DT), - DTO = TValueType("System.DateTimeOffset", DTO.ToString()), - TS = TValueType("System.TimeSpan", ts.ToString()), - Dec = TValueType("System.Decimal", "1239871"), - Guid = TValueType("System.Guid", "3D36E07E-AC90-48C6-B7EC-A481E289D014") - }, "sst_props"); - } - - [Fact] - public async Task InspectLocals() - { - var wait_res = await RunUntil("locals_inner"); - var locals = await GetProperties(wait_res["callFrames"][1]["callFrameId"].Value()); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsForStructInstanceMethod(bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - "dotnet://debugger-test.dll/debugger-array-test.cs", 258, 12, - "DebuggerTests.Point.GenericInstanceMethod", - "window.setTimeout(function() { invoke_static_method_async ('[debugger-test] DebuggerTests.EntryClass:run'); })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - await CheckProps(frame_locals, new - { - sc_arg = TObject("DebuggerTests.SimpleClass"), - @this = TValueType("DebuggerTests.Point"), - local_gs = TValueType("DebuggerTests.SimpleGenericStruct") - }, - "locals#0"); - - await CompareObjectPropertiesFor(frame_locals, "local_gs", - new - { - Id = TString("local_gs#Id"), - Color = TEnum("DebuggerTests.RGB", "Green"), - Value = TNumber(4) - }, - label: "local_gs#0"); - - await CompareObjectPropertiesFor(frame_locals, "sc_arg", - TSimpleClass(10, 45, "sc_arg#Id", "Blue"), - label: "sc_arg#0"); - - await CompareObjectPropertiesFor(frame_locals, "this", - TPoint(90, -4, "point#Id", "Green"), - label: "this#0"); - - }); - - [Fact] - public async Task MulticastDelegateTest() => await CheckInspectLocalsAtBreakpointSite( - "MulticastDelegateTestClass", "Test", 5, "MulticastDelegateTestClass.Test", - "window.setTimeout(function() { invoke_static_method('[debugger-test] MulticastDelegateTestClass:run'); })", - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var this_props = await GetObjectOnLocals(frame_locals, "this"); - await CheckProps(this_props, new - { - Delegate = TSymbol("System.MulticastDelegate") - }, "this_props"); - }); - - [Theory] - [InlineData("EmptyClass", false)] - [InlineData("EmptyClass", true)] - [InlineData("EmptyStruct", false)] - [InlineData("EmptyStruct", true)] - public async Task EmptyTypeWithNoLocalsOrParams(string type_name, bool is_async) => await CheckInspectLocalsAtBreakpointSite( - type_name, - $"StaticMethodWithNoLocals{ (is_async ? "Async" : "") }", - 1, - $"{type_name}.StaticMethodWithNoLocals{ (is_async ? "Async" : "") }", - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] {type_name}:run'); }})", - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - AssertEqual(0, frame_locals.Values().Count(), "locals"); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task StaticMethodWithLocalEmptyStructThatWillGetExpanded(bool is_async) => await CheckInspectLocalsAtBreakpointSite( - "EmptyStruct", - $"StaticMethodWithLocalEmptyStruct{ (is_async ? "Async" : "") }", - 1, - $"EmptyStruct.StaticMethodWithLocalEmptyStruct{ (is_async ? "Async" : "") }", - $"window.setTimeout(function() {{ invoke_static_method('[debugger-test] EmptyStruct:run'); }})", - wait_for_event_fn: async (pause_location) => - { - var frame_locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(frame_locals, new - { - es = TValueType("EmptyStruct") - }, "locals"); - - var es = GetAndAssertObjectWithName(frame_locals, "es"); - var es_props = await GetProperties(es["value"]["objectId"]?.Value()); - AssertEqual(0, es_props.Values().Count(), "es_props"); - }); - - - [Fact] - public async Task PreviousFrameForAReflectedCall() => await CheckInspectLocalsAtBreakpointSite( - "DebuggerTests.GetPropertiesTests.CloneableStruct", "SimpleStaticMethod", 1, "DebuggerTests.GetPropertiesTests.CloneableStruct.SimpleStaticMethod", - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.GetPropertiesTests.TestWithReflection:run'); })", - wait_for_event_fn: async (pause_location) => - { - var frame = FindFrame(pause_location, "DebuggerTests.GetPropertiesTests.TestWithReflection.InvokeReflectedStaticMethod"); - Assert.NotNull(frame); - - var frame_locals = await GetProperties(frame["callFrameId"].Value()); - - await CheckProps(frame_locals, new - { - mi = TObject("System.Reflection.RuntimeMethodInfo", description: "Void SimpleStaticMethod(System.DateTime, System.String)"), //this is what is returned when debugging desktop apps using VS - dt = TDateTime(new DateTime(4210, 3, 4, 5, 6, 7)), - i = TNumber(4), - strings = TArray("string[]", "string[1]"), - cs = TValueType("DebuggerTests.GetPropertiesTests.CloneableStruct"), - - num = TNumber(10), - name = TString("foobar"), - some_date = TDateTime(new DateTime(1234, 6, 7, 8, 9, 10)), - num1 = TNumber(100), - str2 = TString("xyz"), - num3 = TNumber(345), - str3 = TString("abc") - }, "InvokeReflectedStaticMethod#locals"); - }); - - JObject FindFrame(JObject pause_location, string function_name) - => pause_location["callFrames"] - ?.Values() - ?.Where(f => f["functionName"]?.Value() == function_name) - ?.FirstOrDefault(); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("lazy-debugger-test")] - [InlineData("lazy-debugger-test-chinese-char-in-path-\u3128")] - public async Task DebugLazyLoadedAssemblyWithPdb(string assembly_name) - { - Task bpResolved = WaitForBreakpointResolvedEvent(); - int line = 9; - await SetBreakpoint(".*/lazy-debugger-test.cs$", line, 0, use_regex: true); - await LoadAssemblyDynamically( - Path.Combine(DebuggerTestAppPath, $"{assembly_name}.dll"), - Path.Combine(DebuggerTestAppPath, $"{assembly_name}.pdb")); - - var source_location = $"dotnet://{assembly_name}.dll/lazy-debugger-test.cs"; - Assert.Contains(source_location, scripts.Values); - - await bpResolved; - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function () { invoke_static_method('[" + assembly_name + "] LazyMath:IntAdd', 5, 10); }, 1);", - source_location, line, 8, - "LazyMath.IntAdd"); - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 5); - CheckNumber(locals, "b", 10); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugLazyLoadedAssemblyWithEmbeddedPdb() - { - Task bpResolved = WaitForBreakpointResolvedEvent(); - int line = 9; - await SetBreakpoint(".*/lazy-debugger-test-embedded.cs$", line, 0, use_regex: true); - await LoadAssemblyDynamically( - Path.Combine(DebuggerTestAppPath, "lazy-debugger-test-embedded.dll"), - null); - - var source_location = "dotnet://lazy-debugger-test-embedded.dll/lazy-debugger-test-embedded.cs"; - Assert.Contains(source_location, scripts.Values); - - await bpResolved; - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function () { invoke_static_method('[lazy-debugger-test-embedded] LazyMath:IntAdd', 5, 10); }, 1);", - source_location, line, 8, - "LazyMath.IntAdd"); - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 5); - CheckNumber(locals, "b", 10); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebugLazyLoadedAssemblyWithEmbeddedPdbALC() - { - int line = 9; - await SetBreakpoint(".*/lazy-debugger-test-embedded.cs$", line, 0, use_regex: true); - var pause_location = await LoadAssemblyDynamicallyALCAndRunMethod( - Path.Combine(DebuggerTestAppPath, "lazy-debugger-test-embedded.dll"), - null, "LazyMath", "IntAdd"); - - var source_location = "dotnet://lazy-debugger-test-embedded.dll/lazy-debugger-test-embedded.cs"; - Assert.Contains(source_location, scripts.Values); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 5); - CheckNumber(locals, "b", 10); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CannotDebugLazyLoadedAssemblyWithoutPdb() - { - int line = 9; - await SetBreakpoint(".*/lazy-debugger-test.cs$", line, 0, use_regex: true); - await LoadAssemblyDynamically( - Path.Combine(DebuggerTestAppPath, "lazy-debugger-test.dll"), - null); - - // wait to bit to catch if the event might be raised a bit late - await Task.Delay(1000); - - var source_location = "dotnet://lazy-debugger-test.dll/lazy-debugger-test.cs"; - Assert.DoesNotContain(source_location, scripts.Values); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task GetSourceUsingSourceLink() - { - var bp = await SetBreakpointInMethod("debugger-test-with-source-link.dll", "DebuggerTests.ClassToBreak", "TestBreakpoint", 0); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test-with-source-link] DebuggerTests.ClassToBreak:TestBreakpoint'); }, 1);", - "dotnet://debugger-test-with-source-link.dll/test.cs", - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - "DebuggerTests.ClassToBreak.TestBreakpoint"); - - var sourceToGet = JObject.FromObject(new - { - scriptId = pause_location["callFrames"][0]["functionLocation"]["scriptId"].Value() - }); - - var source = await cli.SendCommand("Debugger.getScriptSource", sourceToGet, token); - Assert.True(source.IsOk, $"Failed to getScriptSource: {source}"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task GetSourceEmbeddedSource() - { - string asm_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.dll"); - string pdb_file = Path.Combine(DebuggerTestAppPath, "ApplyUpdateReferencedAssembly.pdb"); - string asm_file_hot_reload = Path.Combine(DebuggerTestAppPath, "../wasm/ApplyUpdateReferencedAssembly.dll"); - - var bp = await SetBreakpoint(".*/MethodBody1.cs$", 48, 12, use_regex: true); - var pause_location = await LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges( - asm_file, pdb_file, "MethodBody5", "StaticMethod1", expectBpResolvedEvent: true); - - var sourceToGet = JObject.FromObject(new - { - scriptId = pause_location["callFrames"][0]["functionLocation"]["scriptId"].Value() - }); - - var source = await cli.SendCommand("Debugger.getScriptSource", sourceToGet, token); - Assert.False(source.Value["scriptSource"].Value().Contains("// Unable to read document")); - } - - [ConditionalFact(nameof(WasmSingleThreaded), nameof(RunningOnChrome))] - public async Task InspectTaskAtLocals() => await CheckInspectLocalsAtBreakpointSite( - "InspectTask", - "RunInspectTask", - 10, - "InspectTask.RunInspectTask.AnonymousMethod__0" , - $"window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] InspectTask:RunInspectTask'); }}, 1);", - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - CheckNumber(locals, "a", 10); - - var t_props = await GetObjectOnLocals(locals, "t"); - await CheckProps(t_props, new - { - Status = TGetter("Status") - }, "t_props", num_fields: 33); - }); - - - [Fact] - public async Task InspectLocalsWithIndexAndPositionWithDifferentValues() //https://github.com/xamarin/xamarin-android/issues/6161 - { - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] MainPage:CallSetValue'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 758, 16, - "MainPage.set_SomeValue", - locals_fn: async (locals) => - { - CheckNumber(locals, "view", 150); - await Task.CompletedTask; - } - ); - } - - [Fact] - public async Task MallocUntilReallocate() //https://github.com/xamarin/xamarin-android/issues/6161 - { - string eval_expr = "window.setTimeout(function() { malloc_to_reallocate_test (); }, 1)"; - - var result = await Evaluate(eval_expr); - - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - - var eval_req = JObject.FromObject(new - { - expression = "window.setTimeout(function() { invoke_add(); }, 1);", - }); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd", - wait_for_event_fn: (pause_location) => - { - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - Assert.Equal("Math.IntAdd", top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - - //now check the scope - var scope = top_frame["scopeChain"][0]; - Assert.Equal("local", scope["type"]); - Assert.Equal("Math.IntAdd", scope["name"]); - - Assert.Equal("object", scope["object"]["type"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, scope["startLocation"]); - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 14, 4, scripts, scope["endLocation"]); - return Task.CompletedTask; - } - ); - } - - [Fact] - public async Task InspectLocalsUsingClassFromLibraryUsingDebugTypeFull() - { - /*DebugType.Full generates symbols in a format that we don't understand (vs portable). If JMC=true (default for tests) then we will not load the assemblies - that don't have debug symbols. With JMC=false, the assembly will be loaded, even with unusable symbols, and the proxy will use the assembly metadata - instead. - - This test specifically tries to inspect an object defined in the external library, so we need JMC=false here.*/ - await SetJustMyCode(false); - var expression = $"{{ invoke_static_method('[debugger-test] DebugTypeFull:CallToEvaluateLocal'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 965, 8, - "DebugTypeFull.CallToEvaluateLocal", - wait_for_event_fn: async (pause_location) => - { - var a_props = await GetObjectOnFrame(pause_location["callFrames"][0], "a"); - await CheckProps(a_props, new - { - a = TNumber(10), - b = TNumber(20), - c = TNumber(30) - }, "a"); - } - ); - } - //TODO add tests covering basic stepping behavior as step in/out/over - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData( - "DebuggerTests.CheckSpecialCharactersInPath", - "dotnet://debugger-test-special-char-in-path.dll/test%23.cs", - "debugger-test-special-char-in-path-%23%40/test%23.cs")] - [InlineData( - "DebuggerTests.CheckSNonAsciiCharactersInPath", - "dotnet://debugger-test-special-char-in-path.dll/non-ascii-test-%C4%85%C5%82%C3%85.cs", - "debugger-test-special-char-in-path-%23%40/non-ascii-test-%C4%85%C5%82%C3%85.cs")] - public async Task SetBreakpointInProjectWithSpecialCharactersInPath( - string classWithNamespace, string expectedFileLocation, string expectedFileNameEscaped) - { - var bp = await SetBreakpointInMethod("debugger-test-special-char-in-path.dll", classWithNamespace, "Evaluate", 1); - var ret = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test-special-char-in-path] {classWithNamespace}:Evaluate'); }}, 1);", - expectedFileLocation, - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - $"{classWithNamespace}.Evaluate"); - Assert.EndsWith(expectedFileNameEscaped, ret["callFrames"][0]["url"].Value(), StringComparison.InvariantCulture); - } - - [ConditionalFact(nameof(RunningOnChromeAndLinux))] - public async Task SetBreakpointInProjectWithColonInSourceName() - { - var bp = await SetBreakpointInMethod("debugger-test-with-colon-in-source-name.dll", "DebuggerTests.CheckColonInSourceName", "Evaluate", 1); - var ret = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test-with-colon-in-source-name] DebuggerTests.CheckColonInSourceName:Evaluate'); }}, 1);", - "dotnet://debugger-test-with-colon-in-source-name.dll/test:.cs", - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - $"DebuggerTests.CheckColonInSourceName.Evaluate"); - Assert.EndsWith("debugger-test-with-colon-in-source-name/test:.cs", ret["callFrames"][0]["url"].Value(), StringComparison.InvariantCulture); - } - - [Theory] - [InlineData( - "DebugWithDeletedPdb", - 1148)] - [InlineData( - "DebugWithoutDebugSymbols", - 1160)] - public async Task InspectPropertiesOfObjectFromExternalLibrary(string className, int line) - { - //Setting JustMyCode = false because we are trying to inspect an object from an external library, and this is only allowed when JMC is disabled - await SetJustMyCode(false); - var expression = $"{{ invoke_static_method('[debugger-test] {className}:Run'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", line, 8, - $"{className}.Run", - wait_for_event_fn: async (pause_location) => - { - var exc_props = await GetObjectOnFrame(pause_location["callFrames"][0], "exc"); - await CheckProps(exc_props, new - { - propA = TNumber(10), - propB = TNumber(20), - propC = TNumber(30), - d = TNumber(40) - }, "exc"); - } - ); - } - - [Theory] - [InlineData("TestAsyncGeneric1Parm", "AsyncGeneric.GetAsyncMethod")] - [InlineData("TestKlassGenericAsyncGeneric", "AsyncGeneric.MyKlass.GetAsyncMethod")] - [InlineData("TestKlassGenericAsyncGeneric2", "AsyncGeneric.MyKlass.GetAsyncMethod")] - [InlineData("TestKlassGenericAsyncGeneric3", "AsyncGeneric.MyKlass.GetAsyncMethod2")] - [InlineData("TestKlassGenericAsyncGeneric4", "AsyncGeneric.MyKlass.GetAsyncMethod2")] - [InlineData("TestKlassGenericAsyncGeneric5", "AsyncGeneric.MyKlass.MyKlassNested.GetAsyncMethod")] - [InlineData("TestKlassGenericAsyncGeneric6", "AsyncGeneric.MyKlass>.GetAsyncMethod")] - public async Task CheckCallStackOfAsyncGenericMethods(string method_name, string method_name_call_stack) - { - var expression = $"{{ invoke_static_method_async ('[debugger-test] AsyncGeneric:{method_name}'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", -1, -1, - method_name_call_stack - ); - } - - [Fact] - public async Task InspectLocalRecursiveFieldValue() - { - var expression = $"{{ invoke_static_method('[debugger-test] InspectIntPtr:Run'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1258, 8, - $"InspectIntPtr.Run", - locals_fn: async (locals) => - { - await CheckValueType(locals, "myInt", "System.IntPtr"); - await CheckValueType(locals, "myInt2", "System.IntPtr"); - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("ClassInheritsFromClassWithoutDebugSymbols", 1287, true)] - [InlineData("ClassInheritsFromClassWithoutDebugSymbols", 1287, false)] - [InlineData("ClassInheritsFromNonUserCodeClass", 1335, true)] - [InlineData("ClassInheritsFromNonUserCodeClass", 1335, false)] - [InlineData("ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass", 1352, true)] - [InlineData("ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass", 1352, false)] - [InlineData("GenericCustomAttributeDecoratedClassInheritsFromClassWithoutDebugSymbols", 1618, true)] - [InlineData("GenericCustomAttributeDecoratedClassInheritsFromClassWithoutDebugSymbols", 1618, false)] - [InlineData("GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClass", 1635, true)] - [InlineData("GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClass", 1635, false)] - [InlineData("GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass", 1653, true)] - [InlineData("GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass", 1653, false)] - public async Task InspectThisThatInheritsFromClassNonUserCode(string class_name, int line, bool jmc) - { - await SetJustMyCode(jmc); - var expression = "{{ invoke_static_method('[debugger-test] " + class_name + ":Run'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", line, 8, - $"{class_name}.CallMethod", - locals_fn: async (locals) => - { - var this_props = await GetObjectOnLocals(locals, "this"); - if (jmc) - { - await CheckProps(this_props, new - { - myField = TNumber(0), - myField2 = TNumber(0), - propB = TGetter("propB"), - propC = TGetter("propC"), - e = TNumber(50), - f = TNumber(60), - }, "this_props", num_fields: 6); - } - else - { - await CheckProps(this_props, new - { - propA = TNumber(10), - propB = TNumber(20), - propC = TNumber(30), - d = TNumber(40), - e = TNumber(50), - f = TNumber(60), - G = TGetter("G"), - H = TGetter("H"), - myField = TNumber(0), - myField2 = TNumber(0), - }, "this_props", num_fields: 10); - } - } - ); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task SetBreakpointInProjectWithChineseCharactereInPath() - { - var bp = await SetBreakpointInMethod("debugger-test-chinese-char-in-path-ㄨ.dll", "DebuggerTests.CheckChineseCharacterInPath", "Evaluate", 1); - var ret = await EvaluateAndCheck( - $"window.setTimeout(function() {{ invoke_static_method ('[debugger-test-chinese-char-in-path-ㄨ] DebuggerTests.CheckChineseCharacterInPath:Evaluate'); }}, 1);", - "dotnet://debugger-test-chinese-char-in-path-ㄨ.dll/test.cs", - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - $"DebuggerTests.CheckChineseCharacterInPath.Evaluate"); - Assert.EndsWith("debugger-test-chinese-char-in-path-%E3%84%A8/test.cs", ret["callFrames"][0]["url"].Value(), StringComparison.InvariantCulture); - } - - [Fact] - public async Task InspectRefFields() - { - var expression = $"{{ invoke_static_method('[debugger-test] ReadOnlySpanTest:Run'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1427, 8, - "ReadOnlySpanTest.CheckArguments", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("parameters.ToString()", TString("System.ReadOnlySpan[1]")), - ("myR1.Run()", TNumber(10)), - ("r2.Run()", TNumber(456)) - ); - } - ); - await StepAndCheck(StepKind.Resume, "dotnet://debugger-test.dll/debugger-test.cs", 1406, 8, "ReadOnlySpanTest.Run", - locals_fn: async (locals) => - { - await CheckValueType(locals, "var1", "System.ReadOnlySpan", description: "System.ReadOnlySpan[0]"); - } - ); - } - - public static TheoryData CountToTen() - { - var data = new TheoryData(); - for (int i=0;i<10;i++) - { - data.Add(i); - } - return data; - } - - [ActiveIssue("https://github.com/dotnet/runtime/issues/98110")] - [ConditionalTheory(nameof(WasmMultiThreaded))] - [MemberData(nameof(CountToTen))] - public async Task TestDebugUsingMultiThreadedRuntime(int _attempt) - { - var bp = await SetBreakpointInMethod("debugger-test.dll", "MultiThreadedTest", "Write", 2); - var expression = $"{{ invoke_static_method('[debugger-test] MultiThreadedTest:Run'); }}"; - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1598, 8, - "MultiThreadedTest.Write"); - - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - Assert.Equal(locals[1]["value"]["type"], "number"); - Assert.Equal(locals[1]["name"], "currentThread"); - - pause_location = await StepAndCheck(StepKind.Resume, "dotnet://debugger-test.dll/debugger-test.cs", 1598, 8, "MultiThreadedTest.Write"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - Assert.Equal(locals[1]["value"]["type"], "number"); - Assert.Equal(locals[1]["name"], "currentThread"); - - pause_location = await StepAndCheck(StepKind.Resume, "dotnet://debugger-test.dll/debugger-test.cs", 1598, 8, "MultiThreadedTest.Write"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - Assert.Equal(locals[1]["value"]["type"], "number"); - Assert.Equal(locals[1]["name"], "currentThread"); - } - - [Fact] - public async Task InspectSpanByte() - { - var expression = $"{{ invoke_static_method('[debugger-test] SpanByte:Run'); }}"; - - await EvaluateAndCheck( - "window.setTimeout(function() {" + expression + "; }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1684, 8, - "SpanByte.Run", - wait_for_event_fn: async (pause_location) => - { - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, - ("span", TObject("System.Span", null)) - ); - } - ); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/MonoJsTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/MonoJsTests.cs deleted file mode 100644 index 9e365c05589260..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/MonoJsTests.cs +++ /dev/null @@ -1,169 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class MonoJsTests : DebuggerTests - { - public MonoJsTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task BadRaiseDebugEventsTest() - { - var bad_expressions = new[] - { - "getDotnetRuntime(0).INTERNAL.mono_wasm_raise_debug_event('')", - "getDotnetRuntime(0).INTERNAL.mono_wasm_raise_debug_event(undefined)", - "getDotnetRuntime(0).INTERNAL.mono_wasm_raise_debug_event({})", - - "getDotnetRuntime(0).INTERNAL.mono_wasm_raise_debug_event({eventName:'foo'}, '')", - "getDotnetRuntime(0).INTERNAL.mono_wasm_raise_debug_event({eventName:'foo'}, 12)" - }; - - foreach (var expression in bad_expressions) - { - var res = await cli.SendCommand($"Runtime.evaluate", - JObject.FromObject(new - { - expression, - returnByValue = true - }), token); - Assert.False(res.IsOk, $"Expected to fail for {expression}"); - } - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(true)] - [InlineData(false)] - [InlineData(null)] - public async Task RaiseDebugEventTraceTest(bool? trace) - { - var tcs = new TaskCompletionSource(); - insp.On("Runtime.consoleAPICalled", async (args, token) => - { - if (args?["type"]?.Value() == "debug" && - args?["args"]?.Type == JTokenType.Array && - args?["args"]?[0]?["value"]?.Value()?.StartsWith("mono_wasm_debug_event_raised:") == true) - { - tcs.SetResult(true); - } - - return tcs.Task.IsCompleted - ? await Task.FromResult(ProtocolEventHandlerReturn.RemoveHandler) - : await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - }); - - var trace_str = trace.HasValue ? $"trace: {trace.ToString().ToLower()}" : String.Empty; - var expression = $"getDotnetRuntime(0).INTERNAL.mono_wasm_raise_debug_event({{ eventName:'qwe' }}, {{ {trace_str} }})"; - var res = await cli.SendCommand($"Runtime.evaluate", JObject.FromObject(new { expression }), token); - Assert.True(res.IsOk, $"Expected to pass for {expression}"); - - var t = await Task.WhenAny(tcs.Task, Task.Delay(2000)); - - if (trace == true) - Assert.True(tcs.Task == t, "Timed out waiting for the event to be logged"); - else - Assert.False(tcs.Task == t, "Event should not have been logged"); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(true, 1)] - [InlineData(false, 0)] - public async Task DuplicateAssemblyLoadedEventNotLoadedFromBundle(bool load_pdb, int expected_count) - => await AssemblyLoadedEventTest( - "lazy-debugger-test", - Path.Combine(DebuggerTestAppPath, "lazy-debugger-test.dll"), - load_pdb ? Path.Combine(DebuggerTestAppPath, "lazy-debugger-test.pdb") : null, - "/lazy-debugger-test.cs", - expected_count - ); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(true, 1)] - [InlineData(false, 1)] // Since it's being loaded from the bundle, it will have the pdb even if we don't provide one - public async Task DuplicateAssemblyLoadedEventForAssemblyFromBundle(bool load_pdb, int expected_count) - => await AssemblyLoadedEventTest( - "debugger-test", - Path.Combine(DebuggerTestAppPath, "_framework/debugger-test.dll"), - load_pdb ? Path.Combine(DebuggerTestAppPath, "_framework/debugger-test.pdb") : null, - "/debugger-test.cs", - expected_count - ); - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DuplicateAssemblyLoadedEventWithEmbeddedPdbNotLoadedFromBundle() - => await AssemblyLoadedEventTest( - "lazy-debugger-test-embedded", - Path.Combine(DebuggerTestAppPath, "lazy-debugger-test-embedded.dll"), - null, - "/lazy-debugger-test-embedded.cs", - expected_count: 1 - ); - - async Task AssemblyLoadedEventTest(string asm_name, string asm_path, string pdb_path, string source_file, int expected_count) - { - int event_count = 0; - var tcs = new TaskCompletionSource(); - insp.On("Debugger.scriptParsed", async (args, c) => - { - try - { - var url = args["url"]?.Value(); - if (url?.EndsWith(source_file) == true) - { - event_count++; - if (event_count > expected_count) - tcs.SetResult(false); - } - } - catch (Exception ex) - { - tcs.SetException(ex); - } - - return tcs.Task.IsCompleted - ? await Task.FromResult(ProtocolEventHandlerReturn.RemoveHandler) - : await Task.FromResult(ProtocolEventHandlerReturn.KeepHandler); - }); - - byte[] bytes = File.Exists(asm_path) ? File.ReadAllBytes(asm_path) : File.ReadAllBytes(Path.ChangeExtension(asm_path, WebcilInWasmExtension)); // hack! - string asm_base64 = Convert.ToBase64String(bytes); - - string pdb_base64 = String.Empty; - if (pdb_path != null) - { - bytes = File.ReadAllBytes(pdb_path); - pdb_base64 = Convert.ToBase64String(bytes); - } - - var expression = $@"getDotnetRuntime(0).INTERNAL.mono_wasm_raise_debug_event({{ - eventName: 'AssemblyLoaded', - assembly_name: '{asm_name}', - assembly_b64: '{asm_base64}', - pdb_b64: '{pdb_base64}' - }});"; - - var res = await cli.SendCommand($"Runtime.evaluate", JObject.FromObject(new { expression }), token); - Assert.True(res.IsOk, $"Expected to pass for {expression}"); - - res = await cli.SendCommand($"Runtime.evaluate", JObject.FromObject(new { expression }), token); - Assert.True(res.IsOk, $"Expected to pass for {expression}"); - - var t = await Task.WhenAny(tcs.Task, Task.Delay(2000)); - if (t.IsFaulted) - throw t.Exception; - - Assert.True(event_count <= expected_count, $"number of scriptParsed events received. Expected: {expected_count}, Actual: {event_count}"); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/PointerTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/PointerTests.cs deleted file mode 100644 index 32077f95601b7d..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/PointerTests.cs +++ /dev/null @@ -1,559 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - - public class PointerTests : DebuggerTests - { - public PointerTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - public static TheoryData PointersTestData => - new TheoryData - { { $"invoke_static_method ('[debugger-test] DebuggerTests.PointerTests:LocalPointers');", "DebuggerTests.PointerTests", "LocalPointers", 32, "DebuggerTests.PointerTests.LocalPointers", false }, - { $"invoke_static_method ('[debugger-test] DebuggerTests.PointerTests:LocalPointers');", "DebuggerTests.PointerTests", "LocalPointers", 32, "DebuggerTests.PointerTests.LocalPointers", true }, - { $"invoke_static_method_async ('[debugger-test] DebuggerTests.PointerTests:LocalPointersAsync');", "DebuggerTests.PointerTests", "LocalPointersAsync", 32, "DebuggerTests.PointerTests.LocalPointersAsync", false }, - { $"invoke_static_method_async ('[debugger-test] DebuggerTests.PointerTests:LocalPointersAsync');", "DebuggerTests.PointerTests", "LocalPointersAsync", 32, "DebuggerTests.PointerTests.LocalPointersAsync", true } - }; - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalPointersToPrimitiveTypes(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - ip = TPointer("int*"), - ip_null = TPointer("int*", is_null: true), - ipp = TPointer("int**"), - ipp_null = TPointer("int**"), - - cvalue0 = TChar('q'), - cp = TPointer("char*"), - - vp = TPointer("void*"), - vp_null = TPointer("void*", is_null: true), - }, "locals", num_fields: 26); - - var props = await GetObjectOnLocals(locals, "ip"); - await CheckPointerValue(props, "*ip", TNumber(5), "locals"); - - { - var ipp_props = await GetObjectOnLocals(locals, "ipp"); - await CheckPointerValue(ipp_props, "*ipp", TPointer("int*")); - - ipp_props = await GetObjectOnLocals(ipp_props, "*ipp"); - await CheckPointerValue(ipp_props, "**ipp", TNumber(5)); - } - - { - var ipp_props = await GetObjectOnLocals(locals, "ipp_null"); - await CheckPointerValue(ipp_props, "*ipp_null", TPointer("int*", is_null: true)); - } - - // *cp - props = await GetObjectOnLocals(locals, "cp"); - await CheckPointerValue(props, "*cp", TChar('q')); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalPointerArrays(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - ipa = TArray("int*[]", "int*[3]") - }, "locals", num_fields: 26); - - var ipa_elems = await CompareObjectPropertiesFor(locals, "ipa", new[] - { - TPointer("int*"), - TPointer("int*"), - TPointer("int*", is_null : true) - }); - - await CheckArrayElements(ipa_elems, new[] - { - TNumber(5), - TNumber(10), - null - }); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalDoublePointerToPrimitiveTypeArrays(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - ippa = TArray("int**[]", "int**[5]") - }, "locals", num_fields: 26); - - var ippa_elems = await CompareObjectPropertiesFor(locals, "ippa", new[] - { - TPointer("int**"), - TPointer("int**"), - TPointer("int**"), - TPointer("int**"), - TPointer("int**", is_null : true) - }); - - { - var actual_elems = await CheckArrayElements(ippa_elems, new[] - { - TPointer("int*"), - TPointer("int*", is_null : true), - TPointer("int*"), - TPointer("int*", is_null : true), - null - }); - - var val = await GetObjectOnLocals(actual_elems[0], "*[0]"); - await CheckPointerValue(val, "**[0]", TNumber(5)); - - val = await GetObjectOnLocals(actual_elems[2], "*[2]"); - await CheckPointerValue(val, "**[2]", TNumber(5)); - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalPointersToValueTypes(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - dt = TDateTime(dt), - dtp = TPointer("System.DateTime*"), - dtp_null = TPointer("System.DateTime*", is_null: true), - - gsp = TPointer("DebuggerTests.GenericStructWithUnmanagedT*"), - gsp_null = TPointer("DebuggerTests.GenericStructWithUnmanagedT*") - }, "locals", num_fields: 26); - - // *dtp - var props = await GetObjectOnLocals(locals, "dtp"); - await CheckDateTime(props, "*dtp", dt); - - var gsp_props = await GetObjectOnLocals(locals, "gsp"); - await CheckPointerValue(gsp_props, "*gsp", TValueType("DebuggerTests.GenericStructWithUnmanagedT"), "locals#gsp"); - - { - var gs_dt = new DateTime(1, 2, 3, 4, 5, 6); - - var gsp_deref_props = await GetObjectOnLocals(gsp_props, "*gsp"); - await CheckProps(gsp_deref_props, new - { - Value = TDateTime(gs_dt), - IntField = TNumber(4), - DTPP = TPointer("System.DateTime**") - }, "locals#gsp#deref"); - { - var dtpp_props = await GetObjectOnLocals(gsp_deref_props, "DTPP"); - await CheckPointerValue(dtpp_props, "*DTPP", TPointer("System.DateTime*"), "locals#*gsp"); - - var dtpp_deref_props = await GetObjectOnLocals(dtpp_props, "*DTPP"); - await CheckDateTime(dtpp_deref_props, "**DTPP", dt); - } - } - - // gsp_null - var gsp_w_n_props = await GetObjectOnLocals(locals, "gsp_null"); - await CheckPointerValue(gsp_w_n_props, "*gsp_null", TValueType("DebuggerTests.GenericStructWithUnmanagedT"), "locals#gsp"); - - { - var gs_dt = new DateTime(1, 2, 3, 4, 5, 6); - - var gsp_deref_props = await GetObjectOnLocals(gsp_w_n_props, "*gsp_null"); - await CheckProps(gsp_deref_props, new - { - Value = TDateTime(gs_dt), - IntField = TNumber(4), - DTPP = TPointer("System.DateTime**") - }, "locals#gsp#deref"); - { - var dtpp_props = await GetObjectOnLocals(gsp_deref_props, "DTPP"); - await CheckPointerValue(dtpp_props, "*DTPP", TPointer("System.DateTime*", is_null: true), "locals#*gsp"); - } - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalPointersToValueTypeArrays(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - dtpa = TArray("System.DateTime*[]", "System.DateTime*[2]") - }, "locals", num_fields: 26); - - // dtpa - var dtpa_elems = (await CompareObjectPropertiesFor(locals, "dtpa", new[] - { - TPointer("System.DateTime*"), - TPointer("System.DateTime*", is_null : true) - })); - { - var actual_elems = await CheckArrayElements(dtpa_elems, new[] - { - TValueType("System.DateTime", dt.ToString()), - null - }); - - await CheckDateTime(actual_elems[0], "*[0]", dt); - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalPointersToGenericValueTypeArrays(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - gspa = TArray("DebuggerTests.GenericStructWithUnmanagedT*[]", "DebuggerTests.GenericStructWithUnmanagedT*[3]"), - }, "locals", num_fields: 26); - - // dtpa - var gspa_elems = await CompareObjectPropertiesFor(locals, "gspa", new[] - { - TPointer("DebuggerTests.GenericStructWithUnmanagedT*", is_null : true), - TPointer("DebuggerTests.GenericStructWithUnmanagedT*"), - TPointer("DebuggerTests.GenericStructWithUnmanagedT*"), - }); - { - var gs_dt = new DateTime(1, 2, 3, 4, 5, 6); - var actual_elems = await CheckArrayElements(gspa_elems, new[] - { - null, - TValueType("DebuggerTests.GenericStructWithUnmanagedT"), - TValueType("DebuggerTests.GenericStructWithUnmanagedT") - }); - - // *[1] - { - var gsp_deref_props = await GetObjectOnLocals(actual_elems[1], "*[1]"); - await CheckProps(gsp_deref_props, new - { - Value = TDateTime(gs_dt), - IntField = TNumber(4), - DTPP = TPointer("System.DateTime**") - }, "locals#gsp#deref"); - { - var dtpp_props = await GetObjectOnLocals(gsp_deref_props, "DTPP"); - await CheckPointerValue(dtpp_props, "*DTPP", TPointer("System.DateTime*"), "locals#*gsp"); - - dtpp_props = await GetObjectOnLocals(dtpp_props, "*DTPP"); - await CheckDateTime(dtpp_props, "**DTPP", dt); - } - } - - // *[2] - { - var gsp_deref_props = await GetObjectOnLocals(actual_elems[2], "*[2]"); - await CheckProps(gsp_deref_props, new - { - Value = TDateTime(gs_dt), - IntField = TNumber(4), - DTPP = TPointer("System.DateTime**") - }, "locals#gsp#deref"); - { - var dtpp_props = await GetObjectOnLocals(gsp_deref_props, "DTPP"); - await CheckPointerValue(dtpp_props, "*DTPP", TPointer("System.DateTime*", is_null: true), "locals#*gsp"); - } - } - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalDoublePointersToValueTypeArrays(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - dtppa = TArray("System.DateTime**[]", "System.DateTime**[3]"), - }, "locals", num_fields: 26); - - // DateTime**[] dtppa = new DateTime**[] { &dtp, &dtp_null, null }; - var dtppa_elems = (await CompareObjectPropertiesFor(locals, "dtppa", new[] - { - TPointer("System.DateTime**"), - TPointer("System.DateTime**"), - TPointer("System.DateTime**", is_null : true) - })); - - var exp_elems = new[] - { - TPointer("System.DateTime*"), - TPointer("System.DateTime*", is_null : true), - null - }; - - var actual_elems = new JToken[exp_elems.Length]; - for (int i = 0; i < exp_elems.Length; i++) - { - if (exp_elems[i] != null) - { - actual_elems[i] = await GetObjectOnLocals(dtppa_elems, i.ToString()); - await CheckPointerValue(actual_elems[i], $"*[{i}]", exp_elems[i], $"dtppa->"); - } - } - }); - - [Theory] - [MemberDataAttribute(nameof(PointersTestData))] - public async Task InspectLocalPointersInClasses(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - cwp = TObject("DebuggerTests.GenericClassWithPointers"), - cwp_null = TObject("DebuggerTests.GenericClassWithPointers") - }, "locals", num_fields: 26); - - var cwp_props = await GetObjectOnLocals(locals, "cwp"); - var ptr_props = await GetObjectOnLocals(cwp_props, "Ptr"); - await CheckDateTime(ptr_props, "*Ptr", dt); - }); - - public static TheoryData PointersAsMethodArgsTestData => - new TheoryData - { { $"invoke_static_method ('[debugger-test] DebuggerTests.PointerTests:LocalPointers');", "DebuggerTests.PointerTests", "PointersAsArgsTest", 2, "DebuggerTests.PointerTests.PointersAsArgsTest", false }, - { $"invoke_static_method ('[debugger-test] DebuggerTests.PointerTests:LocalPointers');", "DebuggerTests.PointerTests", "PointersAsArgsTest", 2, "DebuggerTests.PointerTests.PointersAsArgsTest", true }, - }; - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersAsMethodArgsTestData))] - public async Task InspectPrimitiveTypePointersAsMethodArgs(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - ip = TPointer("int*"), - ipp = TPointer("int**"), - ipa = TArray("int*[]", "int*[3]"), - ippa = TArray("int**[]", "int**[5]") - }, "locals", num_fields: 8); - - // ip - var props = await GetObjectOnLocals(locals, "ip"); - await CheckPointerValue(props, "*ip", TNumber(5), "locals"); - - // ipp - var ipp_props = await GetObjectOnLocals(locals, "ipp"); - await CheckPointerValue(ipp_props, "*ipp", TPointer("int*")); - - ipp_props = await GetObjectOnLocals(ipp_props, "*ipp"); - await CheckPointerValue(ipp_props, "**ipp", TNumber(5)); - - // ipa - var ipa_elems = await CompareObjectPropertiesFor(locals, "ipa", new[] - { - TPointer("int*"), - TPointer("int*"), - TPointer("int*", is_null : true) - }); - - await CheckArrayElements(ipa_elems, new[] - { - TNumber(5), - TNumber(10), - null - }); - - // ippa - var ippa_elems = await CompareObjectPropertiesFor(locals, "ippa", new[] - { - TPointer("int**"), - TPointer("int**"), - TPointer("int**"), - TPointer("int**"), - TPointer("int**", is_null : true) - }); - - { - var actual_elems = await CheckArrayElements(ippa_elems, new[] - { - TPointer("int*"), - TPointer("int*", is_null : true), - TPointer("int*"), - TPointer("int*", is_null : true), - null - }); - - var val = await GetObjectOnLocals(actual_elems[0], "*[0]"); - await CheckPointerValue(val, "**[0]", TNumber(5)); - - val = await GetObjectOnLocals(actual_elems[2], "*[2]"); - await CheckPointerValue(val, "**[2]", TNumber(5)); - } - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [MemberDataAttribute(nameof(PointersAsMethodArgsTestData))] - public async Task InspectValueTypePointersAsMethodArgs(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - - var dt = new DateTime(5, 6, 7, 8, 9, 10); - await CheckProps(locals, new - { - dtp = TPointer("System.DateTime*"), - dtpp = TPointer("System.DateTime**"), - dtpa = TArray("System.DateTime*[]", "System.DateTime*[2]"), - dtppa = TArray("System.DateTime**[]", "System.DateTime**[3]") - }, "locals", num_fields: 8); - - // *dtp - var dtp_props = await GetObjectOnLocals(locals, "dtp"); - await CheckDateTime(dtp_props, "*dtp", dt); - - // *dtpp - var dtpp_props = await GetObjectOnLocals(locals, "dtpp"); - await CheckPointerValue(dtpp_props, "*dtpp", TPointer("System.DateTime*"), "locals"); - - dtpp_props = await GetObjectOnLocals(dtpp_props, "*dtpp"); - await CheckDateTime(dtpp_props, "**dtpp", dt); - - // dtpa - var dtpa_elems = (await CompareObjectPropertiesFor(locals, "dtpa", new[] - { - TPointer("System.DateTime*"), - TPointer("System.DateTime*", is_null : true) - })); - { - var actual_elems = await CheckArrayElements(dtpa_elems, new[] - { - TDateTime(dt), - null - }); - - await CheckDateTime(actual_elems[0], "*[0]", dt); - } - - // dtppa = new DateTime**[] { &dtp, &dtp_null, null }; - var dtppa_elems = (await CompareObjectPropertiesFor(locals, "dtppa", new[] - { - TPointer("System.DateTime**"), - TPointer("System.DateTime**"), - TPointer("System.DateTime**", is_null : true) - })); - - var exp_elems = new[] - { - TPointer("System.DateTime*"), - TPointer("System.DateTime*", is_null : true), - null - }; - - await CheckArrayElements(dtppa_elems, exp_elems); - }); - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("invoke_static_method ('[debugger-test] Math:UseComplex', 0, 0);", "Math", "UseComplex", 3, "Math.UseComplex", false)] - [InlineData("invoke_static_method ('[debugger-test] Math:UseComplex', 0, 0);", "Math", "UseComplex", 3, "Math.UseComplex", true)] - public async Task DerefNonPointerObject(string eval_fn, string type, string method, int line_offset, string bp_function_name, bool use_cfo) => await CheckInspectLocalsAtBreakpointSite( - type, method, line_offset, bp_function_name, - "window.setTimeout(function() { " + eval_fn + " })", - use_cfo: use_cfo, - wait_for_event_fn: async (pause_location) => - { - - // this will generate the object ids - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - var complex = GetAndAssertObjectWithName(locals, "complex"); - - // try to deref the non-pointer object, as a pointer - await GetProperties(complex["value"]["objectId"].Value().Replace(":object:", ":pointer:"), expect_ok: false); - - // try to deref an invalid pointer id - await GetProperties("dotnet:pointer:123897", expect_ok: false); - }); - - async Task CheckArrayElements(JToken array, JToken[] exp_elems) - { - var actual_elems = new JToken[exp_elems.Length]; - for (int i = 0; i < exp_elems.Length; i++) - { - if (exp_elems[i] != null) - { - actual_elems[i] = await GetObjectOnLocals(array, i.ToString()); - await CheckPointerValue(actual_elems[i], $"*[{i}]", exp_elems[i], $"dtppa->"); - } - } - - return actual_elems; - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/README.md b/src/mono/browser/debugger/DebuggerTestSuite/README.md deleted file mode 100644 index b9830978a8ff28..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Logging - -Test output gets logged to `*-test.log` in the output directory. And proxy output is logged to `*-proxy.log`, but only for Info messages. - -Change the `AddFile` calls in `Inspector`, and `TestHarnessStartup` to get more detailed logging. diff --git a/src/mono/browser/debugger/DebuggerTestSuite/SetNextIpTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/SetNextIpTests.cs deleted file mode 100644 index d2cafa0886717e..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/SetNextIpTests.cs +++ /dev/null @@ -1,288 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using System.IO; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests; - -public class SetNextIpTests : DebuggerTests -{ - public SetNextIpTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task SetAndCheck() - { - async Task CheckLocalsAsync(JToken locals, int c, int d, int e, bool f) - { - CheckNumber(locals, "c", c); - CheckNumber(locals, "d", d); - CheckNumber(locals, "e", e); - await CheckBool(locals, "f", f); - } - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 9, 8); - - //calling invoke_add twice to check if the breakpoint continue working after calling SetNextIP - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 9, 8, - "Math.IntAdd" - ); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-test.cs", 12, 8, "Math.IntAdd", - locals_fn: async (locals) => await CheckLocalsAsync(locals, 0, 0, 0, false)); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 13, 8, "Math.IntAdd", - locals_fn: async (locals) => await CheckLocalsAsync(locals, 0, 0, 0, true)); - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-test.cs", 9, 8, "Math.IntAdd", - locals_fn: async (locals) => await CheckLocalsAsync(locals, 0, 0, 0, true)); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "Math.IntAdd", - locals_fn: async (locals) => await CheckLocalsAsync(locals, 30, 0, 0, true)); - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, "Math.IntAdd", - locals_fn: async (locals) => await CheckLocalsAsync(locals, 30, 0, 0, true)); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 12, 8, "Math.IntAdd", - locals_fn: async (locals) => await CheckLocalsAsync(locals, 30, 0, 10, true)); - - //to check that after moving the execution pointer to the same line that there is already - //a breakpoint, the breakpoint continue working - pause_location = await StepAndCheck(StepKind.Resume, - "dotnet://debugger-test.dll/debugger-test.cs", 9, 8, - "Math.IntAdd"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task OutsideTheCurrentMethod() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 9, 8); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 9, 8, - "Math.IntAdd"); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-test.cs", 20, 8, "Math.IntAdd", - expected_error: true); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, "c", 30); - CheckNumber(locals, "d", 0); - CheckNumber(locals, "e", 0); - await CheckBool(locals, "f", false); - }); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task AsyncMethod() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-test.cs"; - - await SetBreakpoint(debugger_test_loc, 140, 12); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_async_method_with_await(); }, 1);", - debugger_test_loc, 140, 12, "Math.NestedInMath.AsyncTest", - locals_fn: async (locals) => - { - CheckNumber(locals, "li", 0); - CheckNumber(locals, "i", 42); - await CheckString(locals, "ls", null); - } - ); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-test.cs", 141, 12, "Math.NestedInMath.AsyncTest", - locals_fn: async (locals) => - { - CheckNumber(locals, "li", 0); - CheckNumber(locals, "i", 42); - await CheckString(locals, "ls", null); - }); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 142, 12, "Math.NestedInMath.AsyncTest", - locals_fn: async (locals) => - { - CheckNumber(locals, "li", 0); - CheckNumber(locals, "i", 42); - await CheckString(locals, "ls", "string from jstest"); - }); - } - - [ConditionalFact(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task Lambda() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-async-test.cs"; - - await SetBreakpoint(debugger_test_loc, 77, 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - debugger_test_loc, 77, 12, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-async-test.cs", 79, 16, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-test.cs", 80, 16, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckDateTime(locals, "dt0", new DateTime(3412, 4, 6, 8, 0, 2)); - }); - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-async-test.cs", 91, 16, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckDateTime(locals, "dt0", new DateTime(3412, 4, 6, 8, 0, 2)); - }); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-test.cs", 92, 12, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckDateTime(locals, "dt0", new DateTime(3412, 4, 6, 8, 0, 2)); - }); - } - - [ConditionalFact(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task Lambda_InvalidLocation() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-async-test.cs"; - - await SetBreakpoint(debugger_test_loc, 77, 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - debugger_test_loc, 77, 12, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-async-test.cs", 92, 8, "MoveNext", - expected_error: true); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-test.cs", 79, 16, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "RanToCompletion"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }, - times: 2); - } - - [ConditionalFact(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task Lambda_ToNestedLambda() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-async-test.cs"; - - await SetBreakpoint(debugger_test_loc, 77, 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - debugger_test_loc, 77, 12, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-async-test.cs", 88, 20, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - expected_error: true); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-test.cs", 79, 16, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "RanToCompletion"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }, - times: 2); - } - - [ConditionalFact(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task Lambda_ToNestedSingleLineLambda_Invalid() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-async-test.cs"; - - await SetBreakpoint(debugger_test_loc, 77, 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - debugger_test_loc, 77, 12, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-async-test.cs", 91, 58, "MoveNext", - expected_error: true); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-test.cs", 79, 16, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "RanToCompletion"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }, - times: 2); - } - - [ConditionalFact(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task Lambda_ToNestedSingleLineLambda_Valid() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-async-test.cs"; - - await SetBreakpoint(debugger_test_loc, 77, 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsync'); })", - debugger_test_loc, 77, 12, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - var top_frame = pause_location["callFrames"][0]["functionLocation"]; - - await SetNextIPAndCheck(top_frame["scriptId"].Value(), "dotnet://debugger-test.dll/debugger-async-test.cs", 91, 16, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-test.cs", 92, 12, "DebuggerTests.AsyncTests.ContinueWithTests.NestedContinueWithInstanceAsync", - locals_fn: async (locals) => - { - await CheckString(locals, "str", "foobar"); - await CheckValueType(locals, "code", "System.Threading.Tasks.TaskStatus", description: "Created"); - await CheckValueType(locals, "dt0", "System.DateTime", description: "1/1/0001 12:00:00 AM"); - }); - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/SetVariableValueTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/SetVariableValueTests.cs deleted file mode 100644 index b93a525b012c4e..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/SetVariableValueTests.cs +++ /dev/null @@ -1,325 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class SetVariableValueTests : DebuggerTests - { - public SetVariableValueTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("a", 1, 30, 130)] - [InlineData("a", 1, -30, -130)] - [InlineData("a1", 1, 20, -1)] - [InlineData("a1", 1, 20, 256)] - [InlineData("b", 2, 200, -32769)] - [InlineData("b", 2, -500, 32769)] - [InlineData("b2", 3, 30000, -500)] - [InlineData("b2", 3, 30000, 65550)] - [InlineData("d", 5, 70, -2147483649)] - [InlineData("d", 5, 70, 2147483648)] - [InlineData("d2", 6, 70, -50)] - [InlineData("d2", 6, 70, 4294967296)] - public async Task SetLocalPrimitiveTypeVariableOutOfRange(string variableName, long originalValue, long newValue, long overflowValue) { - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.SetVariableLocals", "run", 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTests.SetVariableLocals:run');}}, 1);", - "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 22, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, originalValue); - await Task.CompletedTask; - } - ); - var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue}) })); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 23, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, newValue); - await Task.CompletedTask; - } - ); - - callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=overflowValue}) }), false); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 24, 8, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, newValue); - await Task.CompletedTask; - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("f", 9, 150.15616, 0.4564)] - [InlineData("f", 9, -454.54654, -0.5648)] - public async Task SetLocalFloatVariable(string variableName, float originalValue, float newValue, float newValue2) { - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.SetVariableLocals", "run", 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTests.SetVariableLocals:run');}}, 1);", - "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 22, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, originalValue); - await Task.CompletedTask; - } - ); - var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue}) })); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 23, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, newValue); - await Task.CompletedTask; - } - ); - - callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue2}) })); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 24, 8, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, newValue2); - await Task.CompletedTask; - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("g", 10, 150.15615844726562, 0.4564000070095062)] - [InlineData("g", 10, -454.5465393066406, -0.5648000240325928)] - public async Task SetLocalDoubleVariable(string variableName, double originalValue, double newValue, double newValue2) { - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.SetVariableLocals", "run", 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTests.SetVariableLocals:run');}}, 1);", - "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 22, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, originalValue); - await Task.CompletedTask; - } - ); - var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue}) })); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 23, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, newValue); - await Task.CompletedTask; - } - ); - - callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue2}) })); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 24, 8, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, newValue2); - await Task.CompletedTask; - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("a", "1", "30", "127")] - [InlineData("a", "1", "-30", "-128")] - [InlineData("a1", "1", "20", "0")] - [InlineData("a1", "1", "20", "255")] - [InlineData("b", "2", "200", "-32768")] - [InlineData("b", "2", "-500", "32767")] - [InlineData("b2", "3", "30000", "65535")] - [InlineData("d", "5", "70", "-2147483648")] - [InlineData("d", "5", "70", "2147483647")] - [InlineData("d2", "6", "70", "4294967295")] - [InlineData("e", "7", "70", "-9223372036854775808")] - [InlineData("e", "7", "70", "9254456")] - [InlineData("e2", "8", "70", "184467")] - public async Task SetLocalPrimitiveTypeVariableValid(string variableName, string originalValue, string newValue, string newValue2) { - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.SetVariableLocals", "run", 12); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() {{ invoke_static_method_async('[debugger-test] DebuggerTests.SetVariableLocals:run');}}, 1);", - "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 22, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumberAsString(locals, variableName, originalValue.ToString()); - await Task.CompletedTask; - } - ); - var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue}) })); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 23, 12, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumberAsString(locals, variableName, newValue.ToString()); - await Task.CompletedTask; - } - ); - - callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue2}) })); - - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-set-variable-value-test.cs", 24, 8, "DebuggerTests.SetVariableLocals.run", - locals_fn: async (locals) => - { - CheckNumberAsString(locals, variableName, newValue2.ToString()); - await Task.CompletedTask; - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(1, "a", 10, 30)] - [InlineData(1, "a", 10, -1)] - [InlineData(1, "b", 20, 30)] - [InlineData(2, "c", 30, 60)] - [InlineData(3, "d", 50, 70)] - public async Task SetLocalPrimitiveTypeVariable(int offset, string variableName, int originalValue, int newValue){ - await SetBreakpointInMethod("debugger-test.dll", "Math", "IntAdd", offset); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 8+offset, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, originalValue); - await Task.CompletedTask; - } - ); - var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue}) })); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 9+offset, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, newValue); - await Task.CompletedTask; - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(1, "a", 10, "wrongValue")] - [InlineData(1, "b", 20, "wrongValue")] - [InlineData(2, "c", 30, "wrongValue")] - [InlineData(3, "d", 50, "wrongValue")] - [InlineData(3, "d", 50, "123wrongValue")] - public async Task SetVariableValuesAtBreakpointSiteFail(int offset, string variableName, int originalValue, string invalidValue){ - await SetBreakpointInMethod("debugger-test.dll", "Math", "IntAdd", offset); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 8+offset, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, originalValue); - await Task.CompletedTask; - } - ); - var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=invalidValue}) }), false); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 9+offset, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, variableName, originalValue); - await Task.CompletedTask; - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(5, "f", true, false)] - [InlineData(5, "f", true, true)] - public async Task SetLocalBoolTypeVariable(int offset, string variableName, bool originalValue, bool newValue){ - await SetBreakpointInMethod("debugger-test.dll", "Math", "IntAdd", offset); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 8+offset, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - await CheckBool(locals, variableName, originalValue); - } - ); - var callFrameId = pause_location["callFrames"][0]["callFrameId"].Value(); - - await SetVariableValueOnCallFrame( JObject.FromObject(new {callFrameId, variableName, newValue=JObject.FromObject(new {value=newValue}) })); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 9+offset, 4, "Math.IntAdd", - locals_fn: async (locals) => - { - await CheckBool(locals, variableName, newValue); - } - ); - } - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("A", 10, "20", true)] - [InlineData("A", 10, "error", false)] - [InlineData("d", 15, "20", true)] - [InlineData("d", 15, "error", false)] - [InlineData("d", 15, "123error", false)] - public async Task TestSetValueOnObject(string prop_name, int prop_value, string prop_new_value, bool expect_ok) - { - var bp = await SetBreakpointInMethod("debugger-test.dll", "Math", "UseComplex", 5); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_use_complex(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp.Value["locations"][0]["lineNumber"].Value(), - bp.Value["locations"][0]["columnNumber"].Value(), - "Math.UseComplex"); - - - var frame = pause_location["callFrames"][0]; - var props = await GetObjectOnFrame(frame, "complex"); - var locals = await GetProperties(frame["callFrameId"].Value()); - var obj = GetAndAssertObjectWithName(locals, "complex"); - Assert.Equal(4, props.Count()); - CheckNumber(props, prop_name, prop_value); - await CheckString(props, "B", "xx"); - - await SetValueOnObject(obj, prop_name, prop_new_value, expect_ok: expect_ok); - - pause_location = await StepAndCheck( - StepKind.Over, - "dotnet://debugger-test.dll/debugger-test.cs", - bp.Value["locations"][0]["lineNumber"].Value()+1, - bp.Value["locations"][0]["columnNumber"].Value(), - "Math.UseComplex"); - - frame = pause_location["callFrames"][0]; - props = await GetObjectOnFrame(frame, "complex"); - locals = await GetProperties(frame["callFrameId"].Value()); - Assert.Equal(4, props.Count()); - CheckNumber(props, prop_name, expect_ok ? Int32.Parse(prop_new_value) : prop_value); - await CheckString(props, "B", "xx"); - } - } - -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/Settings.cs b/src/mono/browser/debugger/DebuggerTestSuite/Settings.cs deleted file mode 100644 index 3b51a4bcd73d8f..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/Settings.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -#nullable enable - -namespace DebuggerTests; - -internal static class TestOptions -{ - internal static readonly bool LogToConsole = Environment.GetEnvironmentVariable("SKIP_LOG_TO_CONSOLE") != "1"; -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/SteppingTests.cs b/src/mono/browser/debugger/DebuggerTestSuite/SteppingTests.cs deleted file mode 100644 index 2d7f86b950ee97..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/SteppingTests.cs +++ /dev/null @@ -1,1190 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Newtonsoft.Json.Linq; -using Xunit; -using Xunit.Abstractions; - -namespace DebuggerTests -{ - public class SteppingTests : DebuggerTests - { - public SteppingTests(ITestOutputHelper testOutput) : base(testOutput) - {} - - [Fact] - public async Task TrivalStepping() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd", - wait_for_event_fn: (pause_location) => - { - //make sure we're on the right bp - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - var top_frame = pause_location["callFrames"][0]; - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - return Task.CompletedTask; - } - ); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 11, 8, "Math.IntAdd", - wait_for_event_fn: (pause_location) => - { - var top_frame = pause_location["callFrames"][0]; - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 8, 4, scripts, top_frame["functionLocation"]); - return Task.CompletedTask; - } - ); - } - - [Fact] - public async Task InspectLocalsDuringStepping() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-test.cs"; - await SetBreakpoint(debugger_test_loc, 10, 8); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); }, 1);", - debugger_test_loc, 10, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - CheckNumber(locals, "c", 30); - CheckNumber(locals, "d", 0); - CheckNumber(locals, "e", 0); - await Task.CompletedTask; - } - ); - - await StepAndCheck(StepKind.Over, debugger_test_loc, 11, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - CheckNumber(locals, "c", 30); - CheckNumber(locals, "d", 50); - CheckNumber(locals, "e", 0); - await Task.CompletedTask; - } - ); - - //step and get locals - await StepAndCheck(StepKind.Over, debugger_test_loc, 12, 8, "Math.IntAdd", - locals_fn: async (locals) => - { - CheckNumber(locals, "a", 10); - CheckNumber(locals, "b", 20); - CheckNumber(locals, "c", 30); - CheckNumber(locals, "d", 50); - CheckNumber(locals, "e", 60); - await Task.CompletedTask; - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsInPreviousFramesDuringSteppingIn2(bool use_cfo) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - - var dep_cs_loc = "dotnet://debugger-test.dll/dependency.cs"; - await SetBreakpoint(dep_cs_loc, 35, 8); - - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-test.cs"; - - // Will stop in Complex.DoEvenMoreStuff - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_use_complex (); }, 1);", - dep_cs_loc, 35, 8, "Simple.Complex.DoEvenMoreStuff", - locals_fn: async (locals) => - { - Assert.Single(locals); - await CheckObject(locals, "this", "Simple.Complex"); - } - ); - - var props = await GetObjectOnFrame(pause_location["callFrames"][0], "this"); - Assert.Equal(4, props.Count()); - CheckNumber(props, "A", 10); - await CheckString(props, "B", "xx"); - await CheckString(props, "c", "20_xx"); - - // Check UseComplex frame - var locals_m1 = await GetLocalsForFrame(pause_location["callFrames"][3], debugger_test_loc, 23, 8, "Math.UseComplex"); - Assert.Equal(7, locals_m1.Count()); - - CheckNumber(locals_m1, "a", 10); - CheckNumber(locals_m1, "b", 20); - await CheckObject(locals_m1, "complex", "Simple.Complex"); - CheckNumber(locals_m1, "c", 30); - CheckNumber(locals_m1, "d", 50); - CheckNumber(locals_m1, "e", 60); - CheckNumber(locals_m1, "f", 0); - - props = await GetObjectOnFrame(pause_location["callFrames"][3], "complex"); - Assert.Equal(4, props.Count()); - CheckNumber(props, "A", 10); - await CheckString(props, "B", "xx"); - await CheckString(props, "c", "20_xx"); - - pause_location = await StepAndCheck(StepKind.Over, dep_cs_loc, 25, 8, "Simple.Complex.DoStuff", times: 4); - // Check UseComplex frame again - locals_m1 = await GetLocalsForFrame(pause_location["callFrames"][1], debugger_test_loc, 23, 8, "Math.UseComplex"); - Assert.Equal(7, locals_m1.Count()); - - CheckNumber(locals_m1, "a", 10); - CheckNumber(locals_m1, "b", 20); - await CheckObject(locals_m1, "complex", "Simple.Complex"); - CheckNumber(locals_m1, "c", 30); - CheckNumber(locals_m1, "d", 50); - CheckNumber(locals_m1, "e", 60); - CheckNumber(locals_m1, "f", 0); - - props = await GetObjectOnFrame(pause_location["callFrames"][1], "complex"); - Assert.Equal(4, props.Count()); - CheckNumber(props, "A", 10); - await CheckString(props, "B", "xx"); - await CheckString(props, "c", "20_xx"); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsInPreviousFramesDuringSteppingIn(bool use_cfo) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-test.cs"; - await SetBreakpoint(debugger_test_loc, 111, 12); - - // Will stop in InnerMethod - var wait_res = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_outer_method(); }, 1);", - debugger_test_loc, 111, 12, "Math.NestedInMath.InnerMethod", - locals_fn: async (locals) => - { - Assert.Equal(4, locals.Count()); - CheckNumber(locals, "i", 5); - CheckNumber(locals, "j", 24); - await CheckString(locals, "foo_str", "foo"); - await CheckObject(locals, "this", "Math.NestedInMath"); - await Task.CompletedTask; - } - ); - - var this_props = await GetObjectOnFrame(wait_res["callFrames"][0], "this"); - Assert.Equal(2, this_props.Count()); - await CheckObject(this_props, "m", "Math"); - await CheckValueType(this_props, "SimpleStructProperty", "Math.SimpleStruct"); - - var ss_props = await GetObjectOnLocals(this_props, "SimpleStructProperty"); - var dt = new DateTime(2020, 1, 2, 3, 4, 5); - await CheckProps(ss_props, new - { - dt = TDateTime(dt), - gs = TValueType("Math.GenericStruct") - }, "ss_props"); - - // Check OuterMethod frame - var locals_m1 = await GetLocalsForFrame(wait_res["callFrames"][1], debugger_test_loc, 87, 8, "Math.OuterMethod"); - Assert.Equal(5, locals_m1.Count()); - // FIXME: Failing test CheckNumber (locals_m1, "i", 5); - // FIXME: Failing test CheckString (locals_m1, "text", "Hello"); - CheckNumber(locals_m1, "new_i", 0); - CheckNumber(locals_m1, "k", 0); - await CheckObject(locals_m1, "nim", "Math.NestedInMath"); - - // step back into OuterMethod - await StepAndCheck(StepKind.Over, debugger_test_loc, 91, 8, "Math.OuterMethod", times: 7, - locals_fn: async (locals) => - { - Assert.Equal(5, locals.Count()); - - // FIXME: Failing test CheckNumber (locals_m1, "i", 5); - await CheckString(locals, "text", "Hello"); - // FIXME: Failing test CheckNumber (locals, "new_i", 24); - CheckNumber(locals, "k", 19); - await CheckObject(locals, "nim", "Math.NestedInMath"); - } - ); - - //await StepAndCheck (StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 81, 2, "OuterMethod", times: 2); - - // step into InnerMethod2 - await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 96, 4, "Math.InnerMethod2", - locals_fn: async (locals) => - { - Assert.Equal(3, locals.Count()); - - await CheckString(locals, "s", "test string"); - //out var: CheckNumber (locals, "k", 0); - CheckNumber(locals, "i", 24); - await Task.CompletedTask; - } - ); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 100, 4, "Math.InnerMethod2", times: 4, - locals_fn: async (locals) => - { - Assert.Equal(3, locals.Count()); - - await CheckString(locals, "s", "test string"); - // FIXME: Failing test CheckNumber (locals, "k", 34); - CheckNumber(locals, "i", 24); - await Task.CompletedTask; - } - ); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 92, 8, "Math.OuterMethod", times: 2, - locals_fn: async (locals) => - { - Assert.Equal(5, locals.Count()); - - await CheckString(locals, "text", "Hello"); - // FIXME: failing test CheckNumber (locals, "i", 5); - CheckNumber(locals, "new_i", 22); - CheckNumber(locals, "k", 34); - await CheckObject(locals, "nim", "Math.NestedInMath"); - } - ); - } - - [Fact] - public async Task InspectLocalsDuringSteppingIn() - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 86, 8); - - await EvaluateAndCheck("window.setTimeout(function() { invoke_outer_method(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 86, 8, "Math.OuterMethod", - locals_fn: async (locals) => - { - Assert.Equal(5, locals.Count()); - - await CheckObject(locals, "nim", "Math.NestedInMath"); - CheckNumber(locals, "i", 5); - CheckNumber(locals, "k", 0); - CheckNumber(locals, "new_i", 0); - await CheckString(locals, "text", null); - } - ); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 87, 8, "Math.OuterMethod", - locals_fn: async (locals) => - { - Assert.Equal(5, locals.Count()); - - await CheckObject(locals, "nim", "Math.NestedInMath"); - // FIXME: Failing test CheckNumber (locals, "i", 5); - CheckNumber(locals, "k", 0); - CheckNumber(locals, "new_i", 0); - await CheckString(locals, "text", "Hello"); - await Task.CompletedTask; - } - ); - - // Step into InnerMethod - await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 105, 8, "Math.NestedInMath.InnerMethod"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 110, 12, "Math.NestedInMath.InnerMethod", times: 5, - locals_fn: async (locals) => - { - Assert.Equal(4, locals.Count()); - - CheckNumber(locals, "i", 5); - CheckNumber(locals, "j", 15); - await CheckString(locals, "foo_str", "foo"); - await CheckObject(locals, "this", "Math.NestedInMath"); - await Task.CompletedTask; - } - ); - - // Step back to OuterMethod - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 90, 8, "Math.OuterMethod", times: 7, - locals_fn: async (locals) => - { - Assert.Equal(5, locals.Count()); - - await CheckObject(locals, "nim", "Math.NestedInMath"); - // FIXME: Failing test CheckNumber (locals, "i", 5); - CheckNumber(locals, "k", 0); - CheckNumber(locals, "new_i", 24); - await CheckString(locals, "text", "Hello"); - } - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectLocalsInAsyncMethods(bool use_cfo) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-test.cs"; - - await SetBreakpoint(debugger_test_loc, 120, 12); - await SetBreakpoint(debugger_test_loc, 135, 12); - - // Will stop in Asyncmethod0 - var wait_res = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_async_method_with_await(); }, 1);", - debugger_test_loc, 120, 12, "Math.NestedInMath.AsyncMethod0", - locals_fn: async (locals) => - { - Assert.Equal(4, locals.Count()); - await CheckString(locals, "s", "string from js"); - CheckNumber(locals, "i", 42); - await CheckString(locals, "local0", "value0"); - await CheckObject(locals, "this", "Math.NestedInMath"); - } - ); - _testOutput.WriteLine(wait_res.ToString()); - -#if false // Disabled for now, as we don't have proper async traces - var locals = await GetProperties(wait_res["callFrames"][2]["callFrameId"].Value()); - Assert.Equal(4, locals.Count()); - await CheckString(locals, "ls", "string from jstest").ConfigureAwait(false); - CheckNumber(locals, "li", 52); -#endif - - // TODO: previous frames have async machinery details, so no point checking that right now - - var pause_loc = await SendCommandAndCheck(null, "Debugger.resume", debugger_test_loc, 135, 12, "Math.NestedInMath.AsyncMethodNoReturn", - locals_fn: async (locals) => - { - Assert.Equal(4, locals.Count()); - await CheckString(locals, "str", "AsyncMethodNoReturn's local"); - await CheckObject(locals, "this", "Math.NestedInMath"); - //FIXME: check fields - await CheckValueType(locals, "ss", "Math.SimpleStruct"); - await CheckArray(locals, "ss_arr", "Math.SimpleStruct[]", "Math.SimpleStruct[0]"); - // TODO: struct fields - await Task.CompletedTask; - } - ); - - var this_props = await GetObjectOnFrame(pause_loc["callFrames"][0], "this"); - Assert.Equal(2, this_props.Count()); - await CheckObject(this_props, "m", "Math"); - await CheckValueType(this_props, "SimpleStructProperty", "Math.SimpleStruct"); - - // TODO: Check `this` properties - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(false)] - [InlineData(true)] - public async Task InspectValueTypeMethodArgsWhileStepping(bool use_cfo) - { - UseCallFunctionOnBeforeGetProperties = use_cfo; - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; - - await SetBreakpoint(debugger_test_loc, 36, 12); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ValueTypesTest:TestStructsAsMethodArgs'); }, 1);", - debugger_test_loc, 36, 12, "DebuggerTests.ValueTypesTest.MethodWithStructArgs"); - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - { - Assert.Equal(3, locals.Count()); - await CheckString(locals, "label", "TestStructsAsMethodArgs#label"); - await CheckValueType(locals, "ss_arg", "DebuggerTests.ValueTypesTest.SimpleStruct"); - CheckNumber(locals, "x", 3); - } - - var dt = new DateTime(2025, 6, 7, 8, 10, 11); - var ss_local_as_ss_arg = new - { - V = TGetter("V"), - str_member = TString("ss_local#SimpleStruct#string#0#SimpleStruct#str_member"), - dt = TDateTime(dt), - gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - Kind = TEnum("System.DateTimeKind", "Local") - }; - var ss_local_gs = new - { - StringField = TString("ss_local#SimpleStruct#string#0#SimpleStruct#gs#StringField"), - List = TObject("System.Collections.Generic.List", description: "Count = 1"), - Options = TEnum("DebuggerTests.Options", "Option1") - }; - - // Check ss_arg's properties - var ss_arg_props = await GetObjectOnFrame(pause_location["callFrames"][0], "ss_arg"); - await CheckProps(ss_arg_props, ss_local_as_ss_arg, "ss_arg"); - - var res = await InvokeGetter(GetAndAssertObjectWithName(locals, "ss_arg"), "V"); - await CheckValue(res.Value["result"], TNumber(0xDEADBEEF + (uint)dt.Month), "ss_arg#V"); - - { - // Check ss_local.gs - await CompareObjectPropertiesFor(ss_arg_props, "gs", ss_local_gs); - } - - pause_location = await StepAndCheck(StepKind.Over, debugger_test_loc, 40, 8, "DebuggerTests.ValueTypesTest.MethodWithStructArgs", times: 4, - locals_fn: async (l) => { /* non-null to make sure that locals get fetched */ await Task.CompletedTask; }); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - { - Assert.Equal(3, locals.Count()); - - await CheckString(locals, "label", "TestStructsAsMethodArgs#label"); - await CheckValueType(locals, "ss_arg", "DebuggerTests.ValueTypesTest.SimpleStruct"); - CheckNumber(locals, "x", 3); - } - - var ss_arg_updated = new - { - V = TGetter("V"), - str_member = TString("ValueTypesTest#MethodWithStructArgs#updated#ss_arg#str_member"), - dt = TDateTime(dt), - gs = TValueType("DebuggerTests.ValueTypesTest.GenericStruct"), - Kind = TEnum("System.DateTimeKind", "Utc") - }; - - ss_arg_props = await GetObjectOnFrame(pause_location["callFrames"][0], "ss_arg"); - await CheckProps(ss_arg_props, ss_arg_updated, "ss_arg"); - - res = await InvokeGetter(GetAndAssertObjectWithName(locals, "ss_arg"), "V"); - await CheckValue(res.Value["result"], TNumber(0xDEADBEEF + (uint)dt.Month), "ss_arg#V"); - - { - // Check ss_local.gs - await CompareObjectPropertiesFor(ss_arg_props, "gs", new - { - StringField = TString("ValueTypesTest#MethodWithStructArgs#updated#gs#StringField#3"), - List = TObject("System.Collections.Generic.List", description: "Count = 1"), - Options = TEnum("DebuggerTests.Options", "Option1") - }); - } - - // Check locals on previous frame, same as earlier in this test - ss_arg_props = await GetObjectOnFrame(pause_location["callFrames"][1], "ss_local"); - await CheckProps(ss_arg_props, ss_local_as_ss_arg, "ss_local"); - - { - // Check ss_local.dt - await CheckDateTime(ss_arg_props, "dt", dt); - - // Check ss_local.gs - var gs_props = await GetObjectOnLocals(ss_arg_props, "gs"); - await CheckString(gs_props, "StringField", "ss_local#SimpleStruct#string#0#SimpleStruct#gs#StringField"); - await CheckObject(gs_props, "List", "System.Collections.Generic.List", description: "Count = 1"); - } - - // ----------- Step back to the caller --------- - - pause_location = await StepAndCheck(StepKind.Over, debugger_test_loc, 30, 12, "DebuggerTests.ValueTypesTest.TestStructsAsMethodArgs", - times: 2, locals_fn: async (l) => { /* non-null to make sure that locals get fetched */ await Task.CompletedTask; }); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(locals, new - { - ss_local = TValueType("DebuggerTests.ValueTypesTest.SimpleStruct"), - ss_ret = TValueType("DebuggerTests.ValueTypesTest.SimpleStruct") - }, - "locals#0"); - - ss_arg_props = await GetObjectOnFrame(pause_location["callFrames"][0], "ss_local"); - await CheckProps(ss_arg_props, ss_local_as_ss_arg, "ss_local"); - - { - // Check ss_local.gs - await CompareObjectPropertiesFor(ss_arg_props, "gs", ss_local_gs, label: "ss_local_gs"); - } - - // FIXME: check ss_local.gs.List's members - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CheckUpdatedValueTypeFieldsOnResume() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; - - var lines = new[] { 205, 208 }; - await SetBreakpoint(debugger_test_loc, lines[0], 12); - await SetBreakpoint(debugger_test_loc, lines[1], 12); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ValueTypesTest:MethodUpdatingValueTypeMembers'); }, 1);", - debugger_test_loc, lines[0], 12, "DebuggerTests.ValueTypesTest.MethodUpdatingValueTypeMembers"); - - await CheckLocals(pause_location, new DateTime(1, 2, 3, 4, 5, 6), new DateTime(4, 5, 6, 7, 8, 9)); - - // Resume - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", debugger_test_loc, lines[1], 12, "DebuggerTests.ValueTypesTest.MethodUpdatingValueTypeMembers"); - await CheckLocals(pause_location, new DateTime(9, 8, 7, 6, 5, 4), new DateTime(5, 1, 3, 7, 9, 10)); - - async Task CheckLocals(JToken pause_location, DateTime obj_dt, DateTime vt_dt) - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(locals, new - { - obj = TObject("DebuggerTests.ClassForToStringTests"), - vt = TObject("DebuggerTests.StructForToStringTests") - }, "locals"); - - var obj_props = await GetObjectOnLocals(locals, "obj"); - { - await CheckProps(obj_props, new - { - DT = TDateTime(obj_dt) - }, "locals#obj.DT", num_fields: 5); - } - - var vt_props = await GetObjectOnLocals(locals, "vt"); - { - await CheckProps(vt_props, new - { - DT = TDateTime(vt_dt) - }, "locals#obj.DT", num_fields: 5); - } - } - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CheckUpdatedValueTypeLocalsOnResumeAsync() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; - - var lines = new[] { 214, 216 }; - await SetBreakpoint(debugger_test_loc, lines[0], 12); - await SetBreakpoint(debugger_test_loc, lines[1], 12); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ValueTypesTest:MethodUpdatingValueTypeLocalsAsync'); }, 1);", - debugger_test_loc, lines[0], 12, "DebuggerTests.ValueTypesTest.MethodUpdatingValueTypeLocalsAsync"); - - var dt = new DateTime(1, 2, 3, 4, 5, 6); - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckDateTime(locals, "dt", dt); - - // Resume - dt = new DateTime(9, 8, 7, 6, 5, 4); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", debugger_test_loc, lines[1], 12, "DebuggerTests.ValueTypesTest.MethodUpdatingValueTypeLocalsAsync"); - locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckDateTime(locals, "dt", dt); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CheckUpdatedVTArrayMembersOnResume() - { - var debugger_test_loc = "dotnet://debugger-test.dll/debugger-valuetypes-test.cs"; - - var lines = new[] { 225, 227 }; - await SetBreakpoint(debugger_test_loc, lines[0], 12); - await SetBreakpoint(debugger_test_loc, lines[1], 12); - - var dt = new DateTime(1, 2, 3, 4, 5, 6); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] DebuggerTests.ValueTypesTest:MethodUpdatingVTArrayMembers'); }, 1);", - debugger_test_loc, lines[0], 12, "DebuggerTests.ValueTypesTest.MethodUpdatingVTArrayMembers"); - await CheckArrayElements(pause_location, dt); - - // Resume - dt = new DateTime(9, 8, 7, 6, 5, 4); - pause_location = await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", debugger_test_loc, lines[1], 12, "DebuggerTests.ValueTypesTest.MethodUpdatingVTArrayMembers"); - await CheckArrayElements(pause_location, dt); - - async Task CheckArrayElements(JToken pause_location, DateTime dt) - { - var locals = await GetProperties(pause_location["callFrames"][0]["callFrameId"].Value()); - await CheckProps(locals, new - { - ssta = TArray("DebuggerTests.StructForToStringTests[]", "DebuggerTests.StructForToStringTests[1]") - }, "locals"); - - var ssta = await GetObjectOnLocals(locals, "ssta"); - var sst0 = await GetObjectOnLocals(ssta, "0"); - await CheckProps(sst0, new - { - DT = TDateTime(dt) - }, "dta [0]", num_fields: 5); - } - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task SteppingIntoMscorlib() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 83, 8); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] Math:OuterMethod'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 83, 8, - "Math.OuterMethod"); - - //make sure we're on the right bp - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - pause_location = await SendCommandAndCheck(null, $"Debugger.stepInto", null, -1, -1, null); - var top_frame = pause_location["callFrames"][0]; - - AssertEqual("System.Console.WriteLine", top_frame["functionName"]?.Value(), "Expected to be in WriteLine method"); - var script_id = top_frame["functionLocation"]["scriptId"].Value(); - Assert.Matches("^dotnet://(mscorlib|System\\.Console)\\.dll/Console.cs", scripts[script_id]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateGoodBreakpointAndHitAndRemoveAndDontHit() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - var bp2 = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 12, 8); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); invoke_add()}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd"); - - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - await RemoveBreakpoint(bp.Value["breakpointId"]?.ToString()); - await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://debugger-test.dll/debugger-test.cs", 12, 8, "Math.IntAdd"); - await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://debugger-test.dll/debugger-test.cs", 12, 8, "Math.IntAdd"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateGoodBreakpointAndHitAndRemoveTwice() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - var bp2 = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 12, 8); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); invoke_add()}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd"); - - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - await RemoveBreakpoint(bp.Value["breakpointId"]?.ToString()); - await RemoveBreakpoint(bp.Value["breakpointId"]?.ToString()); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CreateGoodBreakpointAndHitAndRemoveAndDontHitAndCreateAgainAndHit() - { - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - var bp2 = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 12, 8); - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); invoke_add(); invoke_add(); invoke_add()}, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd"); - - Assert.Equal("other", pause_location["reason"]?.Value()); - Assert.Equal(bp.Value["breakpointId"]?.ToString(), pause_location["hitBreakpoints"]?[0]?.Value()); - - await RemoveBreakpoint(bp.Value["breakpointId"]?.ToString()); - await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://debugger-test.dll/debugger-test.cs", 12, 8, "Math.IntAdd"); - await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://debugger-test.dll/debugger-test.cs", 12, 8, "Math.IntAdd"); - bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - await SendCommandAndCheck(JObject.FromObject(new { }), "Debugger.resume", "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "Math.IntAdd"); - } - - // [ConditionalFact(nameof(RunningOnChrome))] - //https://github.com/dotnet/runtime/issues/42421 - public async Task BreakAfterAwaitThenStepOverTillBackToCaller() - { - var bp = await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "TestAsyncStepOut2", 2); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:TestAsyncStepOut'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 21, 12, - "MoveNext"); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-step.cs", 23, 12, "MoveNext"); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-step.cs", 24, 8, "MoveNext"); - - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-async-step.cs", 15, 12, "MoveNext"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/42421")] - public async Task StepOutOfAsyncMethod() - { - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "TestAsyncStepOut2", 2); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:TestAsyncStepOut'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 21, 12, - "MoveNext"); - - await StepAndCheck(StepKind.Out, source_file, 15, 4, "TestAsyncStepOut"); - } - - [ConditionalFact(nameof(WasmSingleThreaded))] - public async Task ResumeOutOfAsyncMethodToAsyncCallerWithBreakpoint() - { - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "TestAsyncStepOut2", 2); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:TestAsyncStepOut'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 21, 12, - "DebuggerTests.AsyncStepClass.TestAsyncStepOut2"); - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "TestAsyncStepOut", 2); - await SendCommandAndCheck(null, "Debugger.resume", source_file, 16, 8, "DebuggerTests.AsyncStepClass.TestAsyncStepOut"); - } - - [Fact] - public async Task StepOutOfNonAsyncMethod() - { - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "OtherMethod0", 1); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:SimpleMethod'); }, 1);", - source_file, -1, -1, - "DebuggerTests.AsyncStepClass.OtherMethod0"); - - await StepAndCheck(StepKind.Out, source_file, 29, 12, "DebuggerTests.AsyncStepClass.SimpleMethod"); - } - - [Fact] - public async Task BreakOnAwaitThenStepOverToNextAwaitCall() - { - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "MethodWithTwoAwaitsAsync", 2); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:StepOverTestAsync'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 53, 12, - "DebuggerTests.AsyncStepClass.MethodWithTwoAwaitsAsync"); - - await StepAndCheck(StepKind.Over, source_file, 54, 12, "DebuggerTests.AsyncStepClass.MethodWithTwoAwaitsAsync"); - } - - [Fact] - public async Task BreakOnAwaitThenStepOverToNextLine() - { - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "StepOverTestAsync", 1); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:StepOverTestAsync'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 46, 12, - "DebuggerTests.AsyncStepClass.StepOverTestAsync"); - - // BUG: chrome: not able to show any bp line indicator - await StepAndCheck(StepKind.Over, source_file, 47, 12, "DebuggerTests.AsyncStepClass.StepOverTestAsync"); - } - - [Fact] - public async Task BreakOnAwaitThenResumeToNextBreakpoint() - { - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "StepOverTestAsync", 1); - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "StepOverTestAsync", 3); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:StepOverTestAsync'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 46, 12, - "DebuggerTests.AsyncStepClass.StepOverTestAsync"); - - await StepAndCheck(StepKind.Resume, source_file, 48, 8, "DebuggerTests.AsyncStepClass.StepOverTestAsync"); - } - - [Fact] - public async Task BreakOnAwaitThenResumeToNextBreakpointAfterSecondAwaitInSameMethod() - { - string source_file = "dotnet://debugger-test.dll/debugger-async-step.cs"; - - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "MethodWithTwoAwaitsAsync", 1); - await SetBreakpointInMethod("debugger-test.dll", "DebuggerTests.AsyncStepClass", "MethodWithTwoAwaitsAsync", 5); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method_async('[debugger-test] DebuggerTests.AsyncStepClass:StepOverTestAsync'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-step.cs", 52, 12, - "DebuggerTests.AsyncStepClass.MethodWithTwoAwaitsAsync"); - - await StepAndCheck(StepKind.Resume, source_file, 56, 12, "DebuggerTests.AsyncStepClass.MethodWithTwoAwaitsAsync"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task BreakOnMethodCalledFromHiddenLine() - { - await SetBreakpointInMethod("debugger-test.dll", "HiddenSequencePointTest", "StepOverHiddenSP2", 0); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] HiddenSequencePointTest:StepOverHiddenSP'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 546, 4, - "HiddenSequencePointTest.StepOverHiddenSP2"); - - // Check previous frame - var top_frame = pause_location["callFrames"][1]; - Assert.Equal("HiddenSequencePointTest.StepOverHiddenSP", top_frame["functionName"].Value()); - Assert.Contains("debugger-test.cs", top_frame["url"].Value()); - - CheckLocation("dotnet://debugger-test.dll/debugger-test.cs", 537, 8, scripts, top_frame["location"]); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task StepOverHiddenLinesShouldResumeAtNextAvailableLineInTheMethod() - { - string source_loc = "dotnet://debugger-test.dll/debugger-test.cs"; - await SetBreakpoint(source_loc, 537, 8); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] HiddenSequencePointTest:StepOverHiddenSP'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 537, 8, - "HiddenSequencePointTest.StepOverHiddenSP"); - - await StepAndCheck(StepKind.Over, source_loc, 542, 8, "HiddenSequencePointTest.StepOverHiddenSP"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task StepOverHiddenLinesInMethodWithNoNextAvailableLineShouldResumeAtCallSite() - { - string source_loc = "dotnet://debugger-test.dll/debugger-test.cs"; - await SetBreakpoint(source_loc, 552, 8); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] HiddenSequencePointTest:StepOverHiddenSP'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 552, 8, - "HiddenSequencePointTest.MethodWithHiddenLinesAtTheEnd"); - - await StepAndCheck(StepKind.Over, source_loc, 544, 4, "HiddenSequencePointTest.StepOverHiddenSP", times:2); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(539, 8, 542, 8, "StepOverHiddenSP", "HiddenSequencePointTest.StepOverHiddenSP")] - [InlineData(1272, 8, 1266, 8, "StepOverHiddenSP3", "HiddenSequencePointTest.StepOverHiddenSP3")] - public async Task BreakpointOnHiddenLineShouldStopAtEarliestNextAvailableLine(int line_bp, int column_bp, int line_pause, int column_pause, string method_to_call, string method_name) - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", line_bp, column_bp); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] HiddenSequencePointTest:" + method_to_call + "'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", line_pause, column_pause, - method_name); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/73867")] - [InlineData(184, 20, 161, 8, "HiddenLinesContainingStartOfAnAsyncBlock")] - [InlineData(206, 20, 201, 8, "HiddenLinesAtTheEndOfANestedAsyncBlockWithWithLineDefaultOutsideTheMethod")] - [InlineData(224, 20, 220, 8, "HiddenLinesAtTheEndOfANestedAsyncBlockWithWithLineDefaultOutsideTheMethod2")] - public async Task BreakpointOnHiddenLineShouldStopAtEarliestNextAvailableLineAsync_PauseEarlier(int line_bp, int column_bp, int line_pause, int column_pause, string method_name) - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-async-test.cs", line_bp, column_bp); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsyncWithLineHidden'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-test.cs", line_pause, column_pause, - $"DebuggerTests.AsyncTests.ContinueWithTests.{method_name}"); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(112, 16, 114, 16, "HiddenLinesInAnAsyncBlock")] - [InlineData(130, 16, 133, 16, "HiddenLinesJustBeforeANestedAsyncBlock")] - [InlineData(153, 20, 155, 16, "HiddenLinesAtTheEndOfANestedAsyncBlockWithNoLinesAtEndOfTheMethod.AnonymousMethod__1")] - [InlineData(154, 20, 155, 16, "HiddenLinesAtTheEndOfANestedAsyncBlockWithNoLinesAtEndOfTheMethod.AnonymousMethod__1")] - [InlineData(170, 20, 172, 16, "HiddenLinesAtTheEndOfANestedAsyncBlockWithBreakableLineAtEndOfTheMethod.AnonymousMethod__1")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/86496", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task BreakpointOnHiddenLineShouldStopAtEarliestNextAvailableLineAsync(int line_bp, int column_bp, int line_pause, int column_pause, string method_name) - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-async-test.cs", line_bp, column_bp); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerTests.AsyncTests.ContinueWithTests:RunAsyncWithLineHidden'); }, 1);", - "dotnet://debugger-test.dll/debugger-async-test.cs", line_pause, column_pause, - $"DebuggerTests.AsyncTests.ContinueWithTests.{method_name}"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task BreakpointOnHiddenLineOfMethodWithNoNextVisibleLineShouldNotPause() - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 554, 12); - - string expression = "window.setTimeout(function() { invoke_static_method ('[debugger-test] HiddenSequencePointTest:StepOverHiddenSP'); }, 1);"; - await cli.SendCommand($"Runtime.evaluate", JObject.FromObject(new { expression }), token); - - Task pause_task = insp.WaitFor(Inspector.PAUSE); - Task t = await Task.WhenAny(pause_task, Task.Delay(2000)); - Assert.True(t != pause_task, "Debugger unexpectedly paused"); - } - - [Fact] - public async Task SimpleStep_RegressionTest_49141() - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 674, 0); - - string expression = "window.setTimeout(function() { invoke_static_method ('[debugger-test] Foo:RunBart'); }, 1);"; - await EvaluateAndCheck( - expression, - "dotnet://debugger-test.dll/debugger-test.cs", 674, 12, - "Foo.Bart"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 677, 8, "Foo.Bart"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 678, 4, "Foo.Bart"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task StepAndEvaluateExpression() - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 682, 0); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] Foo:RunBart'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 682, 8, - "Foo.RunBart"); - var pause_location = await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 671, 4, "Foo.Bart"); - var id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, ("this.Bar", TString("Same of something"))); - pause_location = await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 673, 8, "Foo.Bart"); - id = pause_location["callFrames"][0]["callFrameId"].Value(); - await EvaluateOnCallFrameAndCheck(id, ("this.Bar", TString("Same of something"))); - } - - [Fact] - public async Task StepOverWithMoreThanOneCommandInSameLine() - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 693, 0); - - string expression = "window.setTimeout(function() { invoke_static_method ('[debugger-test] Foo:RunBart'); }, 1);"; - await EvaluateAndCheck( - expression, - "dotnet://debugger-test.dll/debugger-test.cs", 693, 8, - "Foo.OtherBar"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 694, 8, "Foo.OtherBar"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 696, 8, "Foo.OtherBar"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 699, 8, "Foo.OtherBar"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 701, 8, "Foo.OtherBar"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 702, 4, "Foo.OtherBar"); - } - - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/97652", typeof(DebuggerTests), nameof(DebuggerTests.WasmMultiThreaded))] - public async Task StepOverWithMoreThanOneCommandInSameLineAsync() - { - await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 710, 0); - - string expression = "window.setTimeout(function() { invoke_static_method ('[debugger-test] Foo:RunBart'); }, 1);"; - await EvaluateAndCheck( - expression, - "dotnet://debugger-test.dll/debugger-test.cs", 710, 8, - "Foo.OtherBarAsync"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 711, 8, "Foo.OtherBarAsync"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 713, 8, "Foo.OtherBarAsync"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 716, 8, "Foo.OtherBarAsync"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 718, 8, "Foo.OtherBarAsync"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 719, 8, "Foo.OtherBarAsync"); - await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 720, 4, "Foo.OtherBarAsync"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task CheckResetFrameNumberForEachStep() - { - var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "SteppingInto", "MethodToStep", 1); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] SteppingInto:MethodToStep'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - bp_conditional.Value["locations"][0]["lineNumber"].Value(), - bp_conditional.Value["locations"][0]["columnNumber"].Value(), - "SteppingInto.MethodToStep" - ); - var pause_location = await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 799, 4, "MyIncrementer.Increment"); - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 800, 8, "MyIncrementer.Increment"); - Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1"); - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 801, 8, "MyIncrementer.Increment"); - Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1"); - pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 806, 8, "MyIncrementer.Increment"); - Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1"); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task DebuggerHiddenIgnoreStepInto() - { - var pause_location = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", "RunDebuggerHidden", 1); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerAttribute:RunDebuggerHidden'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - pause_location.Value["locations"][0]["lineNumber"].Value(), - pause_location.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute.RunDebuggerHidden" - ); - var step_into = await SendCommandAndCheck(null, $"Debugger.stepInto", null, -1, -1, null); - Assert.Equal( - step_into["callFrames"][0]["location"]["lineNumber"].Value(), - pause_location.Value["locations"][0]["lineNumber"].Value() + 1 - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData("Debugger.stepInto")] - [InlineData("Debugger.stepOver")] - public async Task DebuggerHiddenIgnoreStepUserBreakpoint(string steppingFunction) - { - var pause_location = await SetBreakpointInMethod("debugger-test.dll", "DebuggerAttribute", "RunDebuggerHidden", 1); - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method('[debugger-test] DebuggerAttribute:RunDebuggerHidden'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", - pause_location.Value["locations"][0]["lineNumber"].Value(), - pause_location.Value["locations"][0]["columnNumber"].Value(), - "DebuggerAttribute.RunDebuggerHidden" - ); - // stepOver HiddenMethod: - var step_into1 = await SendCommandAndCheck(null, steppingFunction, null, -1, -1, null); - Assert.Equal( - pause_location.Value["locations"][0]["lineNumber"].Value() + 1, - step_into1["callFrames"][0]["location"]["lineNumber"].Value() - ); - - // freeze on HiddenMethodUserBreak: - var step_into2 = await SendCommandAndCheck(null, steppingFunction, null, -1, -1, null); - Assert.Equal( - pause_location.Value["locations"][0]["lineNumber"].Value() + 1, - step_into2["callFrames"][0]["location"]["lineNumber"].Value() - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(true)] - [InlineData(false)] - public async Task SteppingIntoLibrarySymbolsLoadedFromSymbolServer(bool justMyCode) - { - //The test behavior is expecting to start with JustMyCode disabled - await SetJustMyCode(false); - string cachePath = _env.CreateTempDirectory("symbols-cache"); - _testOutput.WriteLine($"** Using cache path: {cachePath}"); - var searchPaths = new JArray - { - "https://symbols.nuget.org/download/symbols" - }; - var waitForScript = WaitForScriptParsedEventsAsync(new string [] { "JArray.cs" }); - var symbolOptions = JObject.FromObject(new { symbolOptions = JObject.FromObject(new { cachePath, searchPaths })}); - await SetJustMyCode(justMyCode); - await SetSymbolOptions(symbolOptions); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] TestLoadSymbols:Run'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1572, 8, - "TestLoadSymbols.Run" - ); - if (!justMyCode) - await waitForScript; - - await StepAndCheck(StepKind.Into, justMyCode ? "dotnet://debugger-test.dll/debugger-test.cs" : "dotnet://Newtonsoft.Json.dll/JArray.cs", justMyCode ? 1575 : 350, justMyCode ? 8 : 12, justMyCode ? "TestLoadSymbols.Run" : "Newtonsoft.Json.Linq.JArray.Add", - locals_fn: async (locals) => - { - if (!justMyCode) - await CheckObject(locals, "this", "Newtonsoft.Json.Linq.JArray", description: "[]"); - else - await CheckObject(locals, "array", "Newtonsoft.Json.Linq.JArray", description: "[\n \"Manual text\"\n]"); - }, times: 2 - ); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task SteppingIntoLibraryWithoutSymbolsAndStepAgainAfterLoadSymbols() - { - string cachePath = _env.CreateTempDirectory("symbols-cache"); - _testOutput.WriteLine($"** Using cache path: {cachePath}"); - var searchPaths = new JArray - { - "https://symbols.nuget.org/download/symbols" - }; - var waitForScript = WaitForScriptParsedEventsAsync(new string [] { "JArray.cs" }); - var symbolOptions = JObject.FromObject(new { symbolOptions = JObject.FromObject(new { cachePath, searchPaths })}); - await SetJustMyCode(false); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] TestLoadSymbols:Run'); invoke_static_method ('[debugger-test] TestLoadSymbols:Run'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1572, 8, - "TestLoadSymbols.Run" - ); - await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 1575, 8, "TestLoadSymbols.Run", - locals_fn: async (locals) => - { - await CheckObject(locals, "array", "Newtonsoft.Json.Linq.JArray", description: "[\n \"Manual text\"\n]"); - }, times: 2 - ); - - await SetSymbolOptions(symbolOptions); - await waitForScript; - - await SendCommandAndCheck(null, "Debugger.resume", - "dotnet://debugger-test.dll/debugger-test.cs", 1572, 8, - "TestLoadSymbols.Run" - ); - - await StepAndCheck(StepKind.Into, "dotnet://Newtonsoft.Json.dll/JArray.cs", 350, 12, "Newtonsoft.Json.Linq.JArray.Add", - locals_fn: async (locals) => - { - await CheckObject(locals, "this", "Newtonsoft.Json.Linq.JArray", description: "[]"); - }, times: 2 - ); - } - - [ConditionalFact(nameof(RunningOnChrome))] - public async Task SteppingIntoLibrarySymbolsLoadedFromSymbolServerAddOtherSymbolServerAndStepAgain() - { - string cachePath = _env.CreateTempDirectory("symbols-cache"); - _testOutput.WriteLine($"** Using cache path: {cachePath}"); - - var searchPaths = new JArray - { - "https://symbols.nuget.org/download/symbols" - }; - var waitForScript = WaitForScriptParsedEventsAsync(new string [] { "JArray.cs" }); - var symbolOptions = JObject.FromObject(new { symbolOptions = JObject.FromObject(new { cachePath, searchPaths })}); - await SetJustMyCode(false); - await SetSymbolOptions(symbolOptions); - - await EvaluateAndCheck( - "window.setTimeout(function() { invoke_static_method ('[debugger-test] TestLoadSymbols:Run'); invoke_static_method ('[debugger-test] TestLoadSymbols:Run'); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 1572, 8, - "TestLoadSymbols.Run" - ); - - await waitForScript; - - await StepAndCheck(StepKind.Into, "dotnet://Newtonsoft.Json.dll/JArray.cs", 350, 12, "Newtonsoft.Json.Linq.JArray.Add", - locals_fn: async (locals) => - { - await CheckObject(locals, "this", "Newtonsoft.Json.Linq.JArray", description: "[]"); - }, times: 2 - ); - - searchPaths.Add("https://msdl.microsoft.com/download/symbols"); - symbolOptions = JObject.FromObject(new { symbolOptions = JObject.FromObject(new { cachePath, searchPaths })}); - await SetSymbolOptions(symbolOptions); - - await SendCommandAndCheck(null, "Debugger.resume", - "dotnet://debugger-test.dll/debugger-test.cs", 1572, 8, - "TestLoadSymbols.Run" - ); - - await StepAndCheck(StepKind.Into, "dotnet://Newtonsoft.Json.dll/JArray.cs", 350, 12, "Newtonsoft.Json.Linq.JArray.Add", - locals_fn: async (locals) => - { - await CheckObject(locals, "this", "Newtonsoft.Json.Linq.JArray", description: "[]"); - }, times: 2 - ); - } - - [ConditionalTheory(nameof(RunningOnChrome))] - [InlineData(true)] - [InlineData(false)] - public async Task SkipWasmFunctionsAccordinglyJustMyCode(bool justMyCode) - { - await SetJustMyCode(justMyCode); - var bp = await SetBreakpoint("dotnet://debugger-test.dll/debugger-test.cs", 10, 8); - - var pause_location = await EvaluateAndCheck( - "window.setTimeout(function() { invoke_add(); invoke_add(); }, 1);", - "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, - "Math.IntAdd" - ); - if (justMyCode) - Assert.False(pause_location["callFrames"].Value().Any(f => f?["scopeChain"]?[0]?["type"]?.Value()?.Equals("wasm-expression-stack") == true)); - else - Assert.True(pause_location["callFrames"].Value().Any(f => f?["scopeChain"]?[0]?["type"]?.Value()?.Equals("wasm-expression-stack") == true)); - if (justMyCode && ReleaseRuntime) - await StepAndCheck(StepKind.Out, "dotnet://debugger-test.dll/debugger-test.cs", 10, 8, "Math.IntAdd", times: 4); - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/TestEnvironment.cs b/src/mono/browser/debugger/DebuggerTestSuite/TestEnvironment.cs deleted file mode 100644 index 71f1a29b095916..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/TestEnvironment.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using Xunit.Abstractions; - -namespace DebuggerTests; - -public class TestEnvironment : IDisposable -{ - private bool _disposed; - private readonly string _tempPath; - private readonly ITestOutputHelper _testOutput; - - public TestEnvironment(ITestOutputHelper testOutput) - { - _testOutput = testOutput; - _tempPath = Path.Combine(DebuggerTestBase.TempPath, Guid.NewGuid().ToString()); - if (Directory.Exists(_tempPath)) - Directory.Delete(_tempPath, recursive: true); - - Directory.CreateDirectory(_tempPath); - } - - public void Dispose() - { - if (_disposed || EnvironmentVariables.SkipCleanup) - return; - - Directory.Delete(_tempPath, recursive: true); - _disposed = true; - } - - public string CreateTempDirectory(string relativeDir, params string[] relativePathParts) - { - string newPath = Path.Combine(_tempPath, relativeDir, Path.Combine(relativePathParts)); - Directory.CreateDirectory(newPath); - return newPath; - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/TestExtensions.cs b/src/mono/browser/debugger/DebuggerTestSuite/TestExtensions.cs deleted file mode 100644 index e23554afadec77..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/TestExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.WebAssembly.Diagnostics; -using Xunit; - -namespace DebuggerTests; - -internal static class TestExtensions -{ - public static void AssertOk(this Result res, string prefix = "") - => Assert.True(res.IsOk, $"{prefix}: Expected Ok result but got {res}"); - - public static void AssertErr(this Result res, string prefix = "") - => Assert.False(res.IsOk, $"{prefix}: Expected error but got {res}"); -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessOptions.cs b/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessOptions.cs deleted file mode 100644 index 077e7a378e0866..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessOptions.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Microsoft.WebAssembly.Diagnostics; - -namespace DebuggerTests -{ - public class TestHarnessOptions : ProxyOptions - { - public string AppPath { get; set; } - public string PagePath { get; set; } - public string NodeApp { get; set; } - public string BrowserParms { get; set; } - public bool WebServerUseCors { get; set; } - public bool WebServerUseCrossOriginPolicy { get; set; } - public Func, Task> ExtractConnUrl { get; set; } - public string Locale { get; set; } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessProxy.cs b/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessProxy.cs deleted file mode 100644 index 3fd1aec644980d..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessProxy.cs +++ /dev/null @@ -1,175 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.WebAssembly.Diagnostics; -using Xunit.Abstractions; - -#nullable enable - -namespace DebuggerTests -{ - public class TestHarnessProxy - { - static IWebHost? host; - static Task? hostTask; - static CancellationTokenSource cts = new CancellationTokenSource(); - static object proxyLock = new object(); - - public static readonly Uri Endpoint = new Uri("http://localhost:9400"); - - private static readonly ConcurrentDictionary> s_proxyTable = new(); - private static readonly ConcurrentDictionary>> s_exitHandlers = new(); - private static readonly ConcurrentDictionary s_statusTable = new(); - - public static Task Start(string appPath, string pagePath, string url, ITestOutputHelper testOutput, string locale = "en-US") - { - TestHarnessOptions options = new() - { - AppPath = appPath, - PagePath = pagePath, - DevToolsUrl = new Uri(url), - WebServerUseCors = false, - WebServerUseCrossOriginPolicy = true, - Locale = locale - }; - - lock (proxyLock) - { - if (hostTask != null) - return hostTask; - - host = WebHost.CreateDefaultBuilder() - .UseSetting("UseIISIntegration", false.ToString()) - .ConfigureAppConfiguration((hostingContext, config) => - { - config.AddEnvironmentVariables(prefix: "WASM_TESTS_"); - }) - .ConfigureLogging(logging => - { - if (TestOptions.LogToConsole) - { - logging.AddSimpleConsole(options => - { - options.SingleLine = true; - options.TimestampFormat = "[HH:mm:ss] "; - }) - .AddFilter("DevToolsProxy", LogLevel.Debug); - } - else - { - // remove the default logger - console - logging.ClearProviders(); - } - - logging.AddXunit(testOutput) - .AddFile(Path.Combine(DebuggerTestBase.TestLogPath, "proxy.log"), - minimumLevel: LogLevel.Trace, - levelOverrides: new Dictionary - { - ["Microsoft.AspNetCore"] = LogLevel.Warning - }, - outputTemplate: "{Timestamp:o} [{Level:u3}] {SourceContext}: {Message}{NewLine}{Exception}") - .AddFilter(null, LogLevel.Information); - }) - .ConfigureServices((ctx, services) => - { - if (options.WebServerUseCors) - { - services.AddCors(o => o.AddPolicy("AnyCors", builder => - { - builder.AllowAnyOrigin() - .AllowAnyMethod() - .AllowAnyHeader() - .WithExposedHeaders("*"); - })); - } - services.AddSingleton(Options.Create(options)); - }) - .UseStartup() - .UseUrls(Endpoint.ToString()) - .Build(); - hostTask = host.StartAsync(cts.Token); - } - - testOutput.WriteLine("WebServer Ready!"); - return hostTask; - } - - public static void RegisterNewProxy(string id, DebuggerProxyBase proxy) - { - if (s_proxyTable.ContainsKey(id)) - throw new ArgumentException($"Proxy with id {id} already exists"); - - s_proxyTable[id] = new WeakReference(proxy); - } - - public static void RegisterExitHandler(string id, Action handler) - { - int intId = int.Parse(id); - if (s_exitHandlers.ContainsKey(intId)) - throw new Exception($"Cannot register a duplicate exit handler for {id}"); - - s_exitHandlers[intId] = new WeakReference>(handler); - } - - public static void RegisterProxyExitState(string id, RunLoopExitState status) - { - int intId = int.Parse(id); - s_statusTable[id] = status; - // we have the explicit state now, so we can drop the reference - // to the proxy - s_proxyTable.TryRemove(id, out _); - - if (s_exitHandlers.TryRemove(intId, out WeakReference>? handlerRef) - && handlerRef.TryGetTarget(out Action? handler)) - { - handler(status); - } - } - - // FIXME: remove - public static bool TryGetProxyExitState(string id, [NotNullWhen(true)] out RunLoopExitState? state) - { - state = null; - - if (s_proxyTable.TryGetValue(id, out WeakReference? proxyRef) && proxyRef.TryGetTarget(out DebuggerProxyBase? proxy)) - { - state = proxy.ExitState; - } - else if (!s_statusTable.TryGetValue(id, out state)) - { - Console.WriteLine($"[{id}] Cannot find exit proxy for {id}"); - state = null; - } - - return state is not null; - } - - public static DebuggerProxyBase? ShutdownProxy(string id) - { - if (!string.IsNullOrEmpty(id) - && s_proxyTable.TryGetValue(id, out WeakReference? proxyRef) - && proxyRef.TryGetTarget(out DebuggerProxyBase? proxy)) - { - proxy.Shutdown(); - return proxy; - } - return null; - } - } - -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessStartup.cs b/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessStartup.cs deleted file mode 100644 index 55f518fc24e179..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/TestHarnessStartup.cs +++ /dev/null @@ -1,208 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.AspNetCore.StaticFiles; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Microsoft.WebAssembly.Diagnostics; -using Newtonsoft.Json.Linq; - -namespace DebuggerTests -{ - public class TestHarnessStartup - { - public TestHarnessStartup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; set; } - public ILogger Logger { get; private set; } - - private ILoggerFactory _loggerFactory; - - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - services.AddRouting() - .Configure(Configuration); - } - - async Task SendNodeVersion(HttpContext context) - { - Logger.LogTrace("hello chrome! json/version"); - var resp_obj = new JObject(); - resp_obj["Browser"] = "node.js/v9.11.1"; - resp_obj["Protocol-Version"] = "1.1"; - - var response = resp_obj.ToString(); - await context.Response.WriteAsync(response, new CancellationTokenSource().Token); - } - - async Task SendNodeList(HttpContext context) - { - Logger.LogTrace("webserver: hello chrome! json/list"); - try - { - var response = new JArray(JObject.FromObject(new - { - description = "node.js instance", - devtoolsFrontendUrl = "chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:9300/91d87807-8a81-4f49-878c-a5604103b0a4", - faviconUrl = "https://nodejs.org/static/favicon.ico", - id = "91d87807-8a81-4f49-878c-a5604103b0a4", - title = "foo.js", - type = "node", - webSocketDebuggerUrl = "ws://localhost:9300/91d87807-8a81-4f49-878c-a5604103b0a4" - })).ToString(); - - Logger.LogTrace($"webserver: sending: {response}"); - await context.Response.WriteAsync(response, new CancellationTokenSource().Token); - } - catch (Exception e) { Logger.LogError(e, "webserver: SendNodeList failed"); } - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IOptions optionsContainer, IWebHostEnvironment env, ILogger logger, ILoggerFactory loggerFactory) - { - this.Logger = logger; - this._loggerFactory = loggerFactory; - TestHarnessOptions options = optionsContainer.Value; - - app.UseWebSockets(); - - var provider = new FileExtensionContentTypeProvider(); - provider.Mappings[".wasm"] = "application/wasm"; - - app.UseStaticFiles(new StaticFileOptions - { - FileProvider = new PhysicalFileProvider(options.AppPath), - ServeUnknownFileTypes = true, //Cuz .wasm is not a known file type :cry: - RequestPath = "", - ContentTypeProvider = provider, - OnPrepareResponse = (context) => { - if (options.WebServerUseCrossOriginPolicy) - { - context.Context.Response.Headers.Add("Cross-Origin-Embedder-Policy", "require-corp"); - context.Context.Response.Headers.Add("Cross-Origin-Opener-Policy", "same-origin"); - } - } - }); - - if (options.WebServerUseCors) - { - app.UseCors("AnyCors"); - } - - app.UseRouter(router => - { - router.MapGet("launch-host-and-connect", async context => - { - string test_id; - if (context.Request.Query.TryGetValue("test_id", out var value) && value.Count == 1) - test_id = value[0]; - else - test_id = "unknown"; - - WasmHost host = WasmHost.Chrome; - if (context.Request.Query.TryGetValue("host", out value) && value.Count == 1) - { - if (!Enum.TryParse(value[0], true, out host)) - throw new ArgumentException($"Unknown wasm host - {value[0]}"); - } - - int firefox_proxy_port = 6002; - if (context.Request.Query.TryGetValue("firefox-proxy-port", out value) && value.Count == 1 && - int.TryParse(value[0], out int port)) - { - firefox_proxy_port = port; - } - - string message_prefix = $"[testId: {test_id}]"; - Logger.LogInformation($"{message_prefix} New test request for test id {test_id}"); - CancellationTokenSource cts = new(); - try - { - int browserPort; - if (host == WasmHost.Chrome) - { - using var provider = new ChromeProvider(test_id, Logger); - browserPort = options.DevToolsUrl.Port; - await provider.StartBrowserAndProxyAsync(context, - $"http://{TestHarnessProxy.Endpoint.Authority}/{options.PagePath}", - browserPort, - message_prefix, - _loggerFactory, - cts, - locale: options.Locale).ConfigureAwait(false); - } - else if (host == WasmHost.Firefox) - { - using var provider = new FirefoxProvider(test_id, Logger); - browserPort = 6500 + int.Parse(test_id); - await provider.StartBrowserAndProxyAsync(context, - $"http://{TestHarnessProxy.Endpoint.Authority}/{options.PagePath}", - browserPort, - firefox_proxy_port, - message_prefix, - _loggerFactory, - cts, - locale: options.Locale).ConfigureAwait(false); - } - Logger.LogDebug($"{message_prefix} TestHarnessStartup done"); - } - catch (Exception ex) - { - Logger.LogError($"{message_prefix} launch-host-and-connect failed with {ex}"); - TestHarnessProxy.RegisterProxyExitState(test_id, new(RunLoopStopReason.Exception, ex)); - } - finally - { - Logger.LogDebug($"TestHarnessStartup: closing for {test_id}"); - cts.Cancel(); - } - }); - }); - - if (options.NodeApp != null) - { - Logger.LogTrace($"Doing the nodejs: {options.NodeApp}"); - var nodeFullPath = Path.GetFullPath(options.NodeApp); - Logger.LogTrace(nodeFullPath); - var psi = new ProcessStartInfo(); - - psi.UseShellExecute = false; - psi.RedirectStandardError = true; - psi.RedirectStandardOutput = true; - - psi.Arguments = $"--inspect-brk=localhost:0 {nodeFullPath}"; - psi.FileName = "node"; - - app.UseRouter(router => - { - //Inspector API for using chrome devtools directly - router.MapGet("json", SendNodeList); - router.MapGet("json/list", SendNodeList); - router.MapGet("json/version", SendNodeVersion); - router.MapGet("launch-done-and-connect", async context => - { - await Task.CompletedTask; - // await LaunchAndServe(psi, context, null, null, null, null); - }); - }); - } - } - } -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/WasmHostProvider.cs b/src/mono/browser/debugger/DebuggerTestSuite/WasmHostProvider.cs deleted file mode 100644 index 7f45bf44e414e0..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/WasmHostProvider.cs +++ /dev/null @@ -1,127 +0,0 @@ - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; - -#nullable enable - -namespace DebuggerTests; - -internal abstract class WasmHostProvider : IDisposable -{ - protected ILogger _logger; - public string Id { get; init; } - protected Process? _process; - protected bool _isDisposed; - protected bool _isDisposing; - - public WasmHostProvider(string id, ILogger logger) - { - Id = id; - _logger = logger; - } - - protected ProcessStartInfo GetProcessStartInfo(string browserPath, string arguments, string url) - => new() - { - Arguments = $"{arguments} {url}", - UseShellExecute = false, - FileName = browserPath, - RedirectStandardError = true, - RedirectStandardOutput = true - }; - - protected async Task LaunchHostAsync(ProcessStartInfo psi, - HttpContext context, - Func checkBrowserReady, - string messagePrefix, - int hostReadyTimeoutMs, - CancellationToken token) - { - ArgumentNullException.ThrowIfNull(psi); - ArgumentNullException.ThrowIfNull(context); - ArgumentNullException.ThrowIfNull(checkBrowserReady); - - if (!context.WebSockets.IsWebSocketRequest) - { - context.Response.StatusCode = 400; - return null; - } - - var browserReadyTCS = new TaskCompletionSource(); - - _logger.LogDebug($"[{Id}] Starting {psi.FileName} with {psi.Arguments}"); - _process = Process.Start(psi); - if (_process is null) - return null; - - Task waitForExitTask = _process.WaitForExitAsync(token); - _process.ErrorDataReceived += (sender, e) => ProcessOutput($"{messagePrefix} browser-stderr ", e?.Data); - _process.OutputDataReceived += (sender, e) => ProcessOutput($"{messagePrefix} browser-stdout ", e?.Data); - - _process.BeginErrorReadLine(); - _process.BeginOutputReadLine(); - - Task completedTask = await Task.WhenAny(browserReadyTCS.Task, waitForExitTask, Task.Delay(hostReadyTimeoutMs)) - .ConfigureAwait(false); - if (_process.HasExited) - throw new IOException($"Process for {psi.FileName} unexpectedly exited with {_process.ExitCode} during startup."); - - if (completedTask == browserReadyTCS.Task) - { - _process.Exited += (_, _) => - { - //Console.WriteLine ($"**Browser died!**"); - Dispose(); - }; - - return await browserReadyTCS.Task; - } - - // FIXME: use custom exception types - // Note: this message string is used in eng/test-configuration.json for triggering - // test retries - throw new IOException($"{messagePrefix} Timed out after {hostReadyTimeoutMs/1000}s waiting for the browser to be ready: {psi.FileName}"); - - void ProcessOutput(string prefix, string? msg) - { - if (!ShouldMessageBeLogged(prefix, msg)) - return; - - _logger.LogDebug($"{prefix}{msg}"); - - if (string.IsNullOrEmpty(msg) || browserReadyTCS.Task.IsCompleted) - return; - - string? result = checkBrowserReady(msg); - if (result is not null) - browserReadyTCS.TrySetResult(result); - } - } - - protected virtual bool ShouldMessageBeLogged(string prefix, string? msg) => true; - - public virtual void Dispose() - { - if (_process is not null && !_process.HasExited) - { - _process.CancelErrorRead(); - _process.CancelOutputRead(); - _process.Kill(); - _process.WaitForExit(); - _process.Close(); - - _process = null; - } - } - -} diff --git a/src/mono/browser/debugger/DebuggerTestSuite/appsettings.json b/src/mono/browser/debugger/DebuggerTestSuite/appsettings.json deleted file mode 100644 index 6e8868d50b4664..00000000000000 --- a/src/mono/browser/debugger/DebuggerTestSuite/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Error", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information", - "DebuggerTests.TestHarnessProxy": "Debug", - "Microsoft.WebAssembly.Diagnostics.DevToolsProxy": "Information", - "Inspector": "Debug", - "InspectorClient": "Debug", - "DevToolsProxy": "Information", - "DebuggerTests": "Debug" - } - } -} diff --git a/src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.props b/src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.props deleted file mode 100644 index 0909239ceb7771..00000000000000 --- a/src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.props +++ /dev/null @@ -1,7 +0,0 @@ - - - true - - - - diff --git a/src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.targets b/src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.targets deleted file mode 100644 index be4716c527cf75..00000000000000 --- a/src/mono/browser/debugger/Wasm.Debugger.Tests/Directory.Build.targets +++ /dev/null @@ -1,9 +0,0 @@ - - - - - $(OutDir) - $(OutDir)\RunTests.sh - $(OutDir)\RunTests.cmd - - diff --git a/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj b/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj deleted file mode 100644 index 3183d12fb9d7bc..00000000000000 --- a/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj +++ /dev/null @@ -1,88 +0,0 @@ - - - - - $(NetCoreAppToolCurrent) - false - false - false - false - true - true - xunit - chrome - - - BundleDebuggerTestsForHelix - true - $(Configuration) - - - - RunScriptTemplate.sh - RunScriptTemplate.cmd - - $(MSBuildThisFileDirectory)data\$(RunScriptInputName) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_DotnetCommand Condition="'$(OS)' != 'Windows_NT'">dotnet - <_DotnetCommand Condition="'$(OS)' == 'Windows_NT'">dotnet.exe - - $(_DotnetCommand) test DebuggerTestSuite/DebuggerTestSuite.dll - $(RunScriptCommand) /e:WasmEnableThreads=$(WasmEnableThreads) - $(RunScriptCommand) "-l:trx%3BLogFileName=testResults.trx" - $(RunScriptCommand) "-l:console%3BVerbosity=normal" - - $(RunScriptCommand) --results-directory "$TEST_LOG_PATH" - $(RunScriptCommand) --results-directory "%TEST_LOG_PATH%" - - $(RunScriptCommand) %24TEST_ARGS - $(RunScriptCommand) %TEST_ARGS% - - - $(RunScriptCommand) -v diag - - - - - diff --git a/src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.cmd b/src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.cmd deleted file mode 100644 index a8e2147883180d..00000000000000 --- a/src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.cmd +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -set EXECUTION_DIR=%~dp0 - -cd %EXECUTION_DIR% - -if [%HELIX_WORKITEM_UPLOAD_ROOT%] == [] ( - set XHARNESS_OUT=%EXECUTION_DIR%xharness-output -) else ( - set XHARNESS_OUT=%HELIX_WORKITEM_UPLOAD_ROOT%\xharness-output -) - -set TEST_LOG_PATH=%XHARNESS_OUT%\logs - -:: ========================= BEGIN Test Execution ============================= -echo ----- start %DATE% %TIME% =============== To repro directly: ===================================================== -echo pushd %EXECUTION_DIR% -[[RunCommandsEcho]] -echo popd -echo =========================================================================================================== -pushd %EXECUTION_DIR% -@echo on -[[RunCommands]] -set EXIT_CODE=%ERRORLEVEL% -@echo off -popd -echo ----- end %DATE% %TIME% ----- exit code %EXIT_CODE% ---------------------------------------------------------- - -echo artifacts: %XHARNESS_OUT% - -exit /b %EXIT_CODE% diff --git a/src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.sh b/src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.sh deleted file mode 100644 index 2e131fe110f942..00000000000000 --- a/src/mono/browser/debugger/Wasm.Debugger.Tests/data/RunScriptTemplate.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -EXECUTION_DIR=$(dirname $0) - -cd $EXECUTION_DIR - -if [[ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]]; then - XHARNESS_OUT="$EXECUTION_DIR/xharness-output" -else - XHARNESS_OUT="$HELIX_WORKITEM_UPLOAD_ROOT/xharness-output" -fi - -export TEST_LOG_PATH=${XHARNESS_OUT}/logs - -[[RunCommands]] - -_exitCode=$? - -echo "artifacts: $XHARNESS_OUT" - -exit $_exitCode diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj deleted file mode 100644 index 2ad4b9f34087e5..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - true - deltascript.json - library - false - true - - false - true - - false - false - false - true - - - true - - - - - - - - - - - - diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody0.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody0.cs deleted file mode 100644 index 833ac95a642f02..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody0.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; - -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBodyUnchangedAssembly { - public static string StaticMethod1 () { - Console.WriteLine("original"); - return "ok"; - } - } -} diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1.cs deleted file mode 100644 index bb23eb2b9d2b5a..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1.cs +++ /dev/null @@ -1,134 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBody1 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody2 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody3 { - public static string StaticMethod3 () { - int a = 10; - Console.WriteLine("original"); - return "OLD STRING"; - } - } - - - - public class MethodBody4 { - public static void StaticMethod4 () { - } - } -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE - public class MethodBody5 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - } - - public class MethodBody6 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - } -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE - // public class MethodBody9 { - // public static int M1(int a, int b) { - // return a + b; - // } - - // public static int test() { - // return M1(1, 2); - // } - // } - - - - - - - - - - - - - - public class MethodBody11 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - } -} diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v1.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v1.cs deleted file mode 100644 index 7b6c0403de45f5..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v1.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBody1 { - public static string StaticMethod1 () { - Console.WriteLine("v1"); - double b = 15; - Debugger.Break(); - return "NEW STRING"; - } - } - - public class MethodBody2 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody3 { - public static string StaticMethod3 () { - float b = 15; - Console.WriteLine("v1"); - return "NEW STRING"; - } - } - - - - public class MethodBody4 { - public static void StaticMethod4 () { - int a = 10; - int b = 20; - Console.WriteLine(a + b); - Console.WriteLine(a + b); - Console.WriteLine(a + b); - } - } - - public class MethodBody5 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("beforeoriginal"); - Console.WriteLine("original"); - } - } - public class MethodBody6 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - public static void NewMethodStatic () { - int i = 20; - newStaticField = 10; - Console.WriteLine($"add a breakpoint in the new static method, look at locals {newStaticField}"); - /*var newvar = new MethodBody6(); - newvar.NewMethodInstance (10);*/ - } - public static int newStaticField; - } - - public class MethodBody7 { - public static int staticField; - int attr1; - string attr2; - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - Console.WriteLine("original"); - MethodBody7 newvar = new MethodBody7(); - staticField = 80; - newvar.InstanceMethod(); - } - public void InstanceMethod () { - int aLocal = 50; - attr1 = 15; - attr2 = "20"; - Console.WriteLine($"add a breakpoint the instance method of the new class"); - } - } -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE - // public class MethodBody9 { - // public static int M1(int x, int y) { - // return x + y; - // } - - // public static int test() { - // return M1(1, 2); - // } - // } - - public class MethodBody10 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - StaticMethod2(); - Console.WriteLine("do not step into StaticMethod2"); - } - [System.Diagnostics.DebuggerStepThroughAttribute] - public static void StaticMethod2 () { - Console.WriteLine($"do not step into here"); - } - } - - public class MethodBody11 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - public static void NewMethodStaticWithThrow () { - int i = 20; - Console.WriteLine($"add a breakpoint in the new static method, look at locals {i}"); - throw new Exception("my exception"); - /*var newvar = new MethodBody6(); - newvar.NewMethodInstance (10);*/ - } - } -} diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v2.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v2.cs deleted file mode 100644 index dda7496ccc91e4..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/MethodBody1_v2.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBody1 { - public static string StaticMethod1 () - { - Console.WriteLine("v2"); - bool c = true; - Debugger.Break(); - return "NEWEST STRING"; - } - } - - public class MethodBody2 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody3 { - public static string StaticMethod3 () { - bool c = true; - int d = 10; - int e = 20; - int f = 50; - return "NEWEST STRING"; - } - } - - public class MethodBody4 { - public static void StaticMethod4 () { - } - } -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE - public class MethodBody5 { - public static void StaticMethod1 () { - Console.WriteLine("beforeoriginal"); - Console.WriteLine("original"); - } - } - - public class MethodBody6 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - public static void NewMethodStatic () { - int i = 20; - newStaticField = 10; - Console.WriteLine($"add a breakpoint in the new static method, look at locals {newStaticField}"); - /*var newvar = new MethodBody6(); - newvar.NewMethodInstance (10);*/ - } - public static int newStaticField; - } - - public class MethodBody7 { - public static int staticField; - int attr1; - string attr2; - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - Console.WriteLine("original"); - MethodBody7 newvar = new MethodBody7(); - staticField = 80; - newvar.InstanceMethod(); - } - public void InstanceMethod () { - int aLocal = 50; - attr1 = 15; - attr2 = "20"; - Console.WriteLine($"add a breakpoint the instance method of the new class"); - } - } - - public class MethodBody8 { - public static int staticField; - int attr1; - string attr2; - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - Console.WriteLine("original"); - MethodBody8 newvar = new MethodBody8(); - staticField = 80; - newvar.InstanceMethod(); - } - public void InstanceMethod () { - int aLocal = 50; - attr1 = 15; - attr2 = "20"; - Console.WriteLine($"add a breakpoint the instance method of the new class"); - } - } -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE -// DO NOT CHANGE - public class MethodBody10 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - StaticMethod2(); - Console.WriteLine("do not step into StaticMethod2"); - } - [System.Diagnostics.DebuggerStepThroughAttribute] - public static void StaticMethod2 () { - Console.WriteLine($"do not step into here"); - } - } - - public class MethodBody11 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - public static void NewMethodStaticWithThrow () { - int i = 20; - Console.WriteLine($"add a breakpoint in the new static method, look at locals {i}"); - throw new Exception("my exception"); - /*var newvar = new MethodBody6(); - newvar.NewMethodInstance (10);*/ - } - } -} diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/deltascript.json b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/deltascript.json deleted file mode 100644 index 8e738364bc7475..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly/deltascript.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "changes": [ - {"document": "MethodBody1.cs", "update": "MethodBody1_v1.cs"}, - {"document": "MethodBody1.cs", "update": "MethodBody1_v2.cs"}, - ] -} - diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/ApplyUpdateReferencedAssembly2.csproj b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/ApplyUpdateReferencedAssembly2.csproj deleted file mode 100644 index f024e0e58b3f6b..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/ApplyUpdateReferencedAssembly2.csproj +++ /dev/null @@ -1,35 +0,0 @@ - - - true - deltascript.json - library - false - true - - false - true - - false - false - false - true - - - true - - - - - - - - - - - diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2.cs deleted file mode 100644 index 9ae61a4ee789e5..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class AddMethod { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v1.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v1.cs deleted file mode 100644 index b8e75a4e39300b..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v1.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class AddMethod { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - public static string StaticMethod2 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v2.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v2.cs deleted file mode 100644 index 615e47f2c936b4..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/MethodBody2_v2.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class AddMethod { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - public static string StaticMethod2 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - public static string StaticMethod3 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/deltascript.json b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/deltascript.json deleted file mode 100644 index 6603dcff23d1f8..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly2/deltascript.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "changes": [ - {"document": "MethodBody2.cs", "update": "MethodBody2_v1.cs"}, - {"document": "MethodBody2.cs", "update": "MethodBody2_v2.cs"} - ] -} - diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/ApplyUpdateReferencedAssembly3.csproj b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/ApplyUpdateReferencedAssembly3.csproj deleted file mode 100644 index 82101932fa3636..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/ApplyUpdateReferencedAssembly3.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - true - deltascript.json - false - true - - false - true - - false - false - false - true - - - true - - - - - - - - - - - diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2.cs deleted file mode 100644 index 4c5f28e85e30b2..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class AddInstanceFields { - public static string StaticMethod1 () { - C c = new(); - Debugger.Break(); - return "OLD STRING"; - } - - public class C { - public C() - { - } - } - - } -} diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v1.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v1.cs deleted file mode 100644 index 92a4dde4a1acf0..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v1.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class AddInstanceFields { - public static string StaticMethod1 () { - C c = new(); - Debugger.Break(); - return "OLD STRING"; - } - - public class C { - public C() - { - Field1 = 123.0; - } - public double Field1; - } - } - -} diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v2.cs b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v2.cs deleted file mode 100644 index 7d89669cd454c1..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/MethodBody2_v2.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class AddInstanceFields { - public static string StaticMethod1 () { - C c = new(); - c.Field2 = "spqr"; - Debugger.Break(); - return "OLD STRING"; - } - - public class C { - public C() - { - Field1 = 123.0; - Field2 = "abcd"; - } - public double Field1; - public string Field2; - public string Field3Unused; - } - } - -} diff --git a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/deltascript.json b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/deltascript.json deleted file mode 100644 index 6603dcff23d1f8..00000000000000 --- a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssembly3/deltascript.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "changes": [ - {"document": "MethodBody2.cs", "update": "MethodBody2_v1.cs"}, - {"document": "MethodBody2.cs", "update": "MethodBody2_v2.cs"} - ] -} - diff --git "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250.csproj" "b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250.csproj" deleted file mode 100644 index 9b4c7a12d15077..00000000000000 --- "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250.csproj" +++ /dev/null @@ -1,36 +0,0 @@ - - - true - deltascript.json - library - false - true - - false - true - - false - false - false - true - - - true - - - - - - - - - - - - diff --git "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody0.cs" "b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody0.cs" deleted file mode 100644 index 833ac95a642f02..00000000000000 --- "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody0.cs" +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; - -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBodyUnchangedAssembly { - public static string StaticMethod1 () { - Console.WriteLine("original"); - return "ok"; - } - } -} diff --git "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1.cs" "b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1.cs" deleted file mode 100644 index 3abc1d4b538bb7..00000000000000 --- "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1.cs" +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBody1 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody2 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody3 { - public static string StaticMethod3 () { - int a = 10; - Console.WriteLine("original"); - return "OLD STRING"; - } - } - - - - public class MethodBody4 { - public static void StaticMethod4 () { - } - } - - - - - - - public class MethodBody5 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - } - - public class MethodBody6 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - } -} diff --git "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v1.cs" "b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v1.cs" deleted file mode 100644 index cef3214d9c89e9..00000000000000 --- "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v1.cs" +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBody1 { - public static string StaticMethod1 () { - Console.WriteLine("v1"); - double b = 15; - Debugger.Break(); - return "NEW STRING"; - } - } - - public class MethodBody2 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody3 { - public static string StaticMethod3 () { - float b = 15; - Console.WriteLine("v1"); - return "NEW STRING"; - } - } - - - - public class MethodBody4 { - public static void StaticMethod4 () { - int a = 10; - int b = 20; - Console.WriteLine(a + b); - Console.WriteLine(a + b); - Console.WriteLine(a + b); - } - } - - public class MethodBody5 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("beforeoriginal"); - Console.WriteLine("original"); - } - } - public class MethodBody6 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - public static void NewMethodStatic () { - int i = 20; - newStaticField = 10; - Console.WriteLine($"add a breakpoint in the new static method, look at locals {newStaticField}"); - /*var newvar = new MethodBody6(); - newvar.NewMethodInstance (10);*/ - } - public static int newStaticField; - } - - public class MethodBody7 { - public static int staticField; - int attr1; - string attr2; - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - Console.WriteLine("original"); - MethodBody7 newvar = new MethodBody7(); - staticField = 80; - newvar.InstanceMethod(); - } - public void InstanceMethod () { - int aLocal = 50; - attr1 = 15; - attr2 = "20"; - Console.WriteLine($"add a breakpoint the instance method of the new class"); - } - } -} diff --git "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v2.cs" "b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v2.cs" deleted file mode 100644 index 48c3b9911e8059..00000000000000 --- "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/MethodBody1_v2.cs" +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics; -using System; -//keep the same line number for class in the original file and the updates ones -namespace ApplyUpdateReferencedAssembly -{ - public class MethodBody1 { - public static string StaticMethod1 () - { - Console.WriteLine("v2"); - bool c = true; - Debugger.Break(); - return "NEWEST STRING"; - } - } - - public class MethodBody2 { - public static string StaticMethod1 () { - Console.WriteLine("original"); - int a = 10; - Debugger.Break(); - return "OLD STRING"; - } - } - - public class MethodBody3 { - public static string StaticMethod3 () { - bool c = true; - int d = 10; - int e = 20; - int f = 50; - return "NEWEST STRING"; - } - } - - public class MethodBody4 { - public static void StaticMethod4 () { - } - } - - - - - - - public class MethodBody5 { - public static void StaticMethod1 () { - Console.WriteLine("beforeoriginal"); - Console.WriteLine("original"); - } - } - - public class MethodBody6 { - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a line that will not be changed"); - Console.WriteLine("original"); - } - public static void NewMethodStatic () { - int i = 20; - newStaticField = 10; - Console.WriteLine($"add a breakpoint in the new static method, look at locals {newStaticField}"); - /*var newvar = new MethodBody6(); - newvar.NewMethodInstance (10);*/ - } - public static int newStaticField; - } - - public class MethodBody7 { - public static int staticField; - int attr1; - string attr2; - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - Console.WriteLine("original"); - MethodBody7 newvar = new MethodBody7(); - staticField = 80; - newvar.InstanceMethod(); - } - public void InstanceMethod () { - int aLocal = 50; - attr1 = 15; - attr2 = "20"; - Console.WriteLine($"add a breakpoint the instance method of the new class"); - } - } - - public class MethodBody8 { - public static int staticField; - int attr1; - string attr2; - public static void StaticMethod1 () { - Console.WriteLine("breakpoint in a method in a new class"); - Console.WriteLine("original"); - MethodBody8 newvar = new MethodBody8(); - staticField = 80; - newvar.InstanceMethod(); - } - public void InstanceMethod () { - int aLocal = 50; - attr1 = 15; - attr2 = "20"; - Console.WriteLine($"add a breakpoint the instance method of the new class"); - } - } -} diff --git "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/deltascript.json" "b/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/deltascript.json" deleted file mode 100644 index 8e738364bc7475..00000000000000 --- "a/src/mono/browser/debugger/tests/ApplyUpdateReferencedAssemblyChineseCharInPath\343\204\250/deltascript.json" +++ /dev/null @@ -1,7 +0,0 @@ -{ - "changes": [ - {"document": "MethodBody1.cs", "update": "MethodBody1_v1.cs"}, - {"document": "MethodBody1.cs", "update": "MethodBody1_v2.cs"}, - ] -} - diff --git a/src/mono/browser/debugger/tests/Directory.Build.props b/src/mono/browser/debugger/tests/Directory.Build.props deleted file mode 100644 index d8bf9c7e0719b0..00000000000000 --- a/src/mono/browser/debugger/tests/Directory.Build.props +++ /dev/null @@ -1,23 +0,0 @@ - - - browser-wasm - $(RuntimeConfiguration) - - - - - $(NetCoreAppCurrent) - Library - true - Debug - - true - 219 - false - - $(ArtifactsBinDir)debugger-test\$(Configuration)\AppBundle - $(ArtifactsBinDir)debugger-test\$(Configuration)\wasm - - $(ArtifactsBinDir)microsoft.netcore.app.runtime.browser-wasm\$(RuntimeConfiguration)\runtimes\browser-wasm\ - - diff --git a/src/mono/browser/debugger/tests/Directory.Build.targets b/src/mono/browser/debugger/tests/Directory.Build.targets deleted file mode 100644 index 48501c8f68e96e..00000000000000 --- a/src/mono/browser/debugger/tests/Directory.Build.targets +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git "a/src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/debugger-test-chinese-char-in-path-\343\204\250.csproj" "b/src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/debugger-test-chinese-char-in-path-\343\204\250.csproj" deleted file mode 100644 index 1463b4a398f1f7..00000000000000 --- "a/src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/debugger-test-chinese-char-in-path-\343\204\250.csproj" +++ /dev/null @@ -1,6 +0,0 @@ - - - - false - - diff --git "a/src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/test.cs" "b/src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/test.cs" deleted file mode 100644 index 6902b401317936..00000000000000 --- "a/src/mono/browser/debugger/tests/debugger-test-chinese-char-in-path-\343\204\250/test.cs" +++ /dev/null @@ -1,10 +0,0 @@ -namespace DebuggerTests -{ - public class CheckChineseCharacterInPath - { - public static void Evaluate() - { - var a = 123; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/debugger-test-special-char-in-path.csproj b/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/debugger-test-special-char-in-path.csproj deleted file mode 100644 index d75d7cd720ac04..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/debugger-test-special-char-in-path.csproj +++ /dev/null @@ -1,5 +0,0 @@ - - - false - - diff --git "a/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/non-ascii-test-\304\205\305\202\303\205.cs" "b/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/non-ascii-test-\304\205\305\202\303\205.cs" deleted file mode 100644 index db51e5895aba56..00000000000000 --- "a/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/non-ascii-test-\304\205\305\202\303\205.cs" +++ /dev/null @@ -1,10 +0,0 @@ -namespace DebuggerTests -{ - public class CheckSNonAsciiCharactersInPath - { - public static void Evaluate() - { - var a = 123; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/test#.cs b/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/test#.cs deleted file mode 100644 index 851c232e5ef2c8..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-special-char-in-path-#@/test#.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DebuggerTests -{ - public class CheckSpecialCharactersInPath - { - public static void Evaluate() - { - var a = 123; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vb b/src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vb deleted file mode 100644 index 4ca35c3281173e..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vb +++ /dev/null @@ -1,30 +0,0 @@ -Public Class TestVbScope - Public Shared Async Function Run() As Task - Await RunVBScope(10) - Await RunVBScope(1000) - End Function - - Public Shared Async Function RunVBScope(data As Integer) As Task(Of Integer) - Dim a As Integer - a = 10 - If data < 999 Then - Dim testVbScope As String - Dim onlyInFirstScope As String - testVbScope = "hello" - onlyInFirstScope = "only-in-first-scope" - System.Diagnostics.Debugger.Break() - Await Task.Delay(1) - Return data - Else - Dim testVbScope As String - Dim onlyInSecondScope As String - testVbScope = "hi" - onlyInSecondScope = "only-in-second-scope" - System.Diagnostics.Debugger.Break() - Await Task.Delay(1) - Return data - End If - - End Function - -End Class diff --git a/src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vbproj b/src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vbproj deleted file mode 100644 index c54512c75cdfcd..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-vb/debugger-test-vb.vbproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - DebuggerTestVB - net7.0 - - - diff --git a/src/mono/browser/debugger/tests/debugger-test-with-colon-in-source-name/debugger-test-with-colon-in-source-name.csproj b/src/mono/browser/debugger/tests/debugger-test-with-colon-in-source-name/debugger-test-with-colon-in-source-name.csproj deleted file mode 100644 index e6c35ecaf56ec7..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-colon-in-source-name/debugger-test-with-colon-in-source-name.csproj +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/debugger-test-with-full-debug-type.csproj b/src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/debugger-test-with-full-debug-type.csproj deleted file mode 100644 index 7746f400741700..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/debugger-test-with-full-debug-type.csproj +++ /dev/null @@ -1,5 +0,0 @@ - - - full - - diff --git a/src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/test.cs b/src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/test.cs deleted file mode 100644 index 3b9ab8aecbbd1a..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-full-debug-type/test.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace DebuggerTests -{ - public class ClassToInspectWithDebugTypeFull - { - int a; - int b; - int c; - public ClassToInspectWithDebugTypeFull() - { - a = 10; - b = 20; - c = 30; - Console.WriteLine(a); - Console.WriteLine(b); - Console.WriteLine(c); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj b/src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj deleted file mode 100644 index c0d42d7f25cde5..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/debugger-test-with-non-user-code-class.csproj +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/test.cs b/src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/test.cs deleted file mode 100644 index 1626d47d5d4e1f..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-non-user-code-class/test.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace DebuggerTests -{ - public class NormalClass - { - public int myField2; - } - - [System.Diagnostics.DebuggerNonUserCode] - public class ClassNonUserCodeToInheritThatInheritsFromNormalClass : NormalClass - { - private int propA {get;} - public int propB {get;} - protected int propC {get;} - private int d; - public int e; - protected int f; - private int G - { - get {return f + 1;} - } - private int H => f; - - public ClassNonUserCodeToInheritThatInheritsFromNormalClass() - { - propA = 10; - propB = 20; - propC = 30; - d = 40; - e = 50; - f = 60; - Console.WriteLine(propA); - Console.WriteLine(propB); - Console.WriteLine(propC); - Console.WriteLine(d); - Console.WriteLine(e); - Console.WriteLine(f); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/debugger-test-with-pdb-deleted.csproj b/src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/debugger-test-with-pdb-deleted.csproj deleted file mode 100644 index 15d8fcbfc2749f..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/debugger-test-with-pdb-deleted.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - portable - - - - - - diff --git a/src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/test.cs b/src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/test.cs deleted file mode 100644 index 489fd5c92b1e2a..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-pdb-deleted/test.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace DebuggerTests -{ - public class ClassWithPdbDeleted - { - private int propA {get;} - public int propB {get;} - protected int propC {get;} - public int d; - public ClassWithPdbDeleted() - { - propA = 10; - propB = 20; - propC = 30; - d = 40; - Console.WriteLine(propA); - Console.WriteLine(propB); - Console.WriteLine(propC); - Console.WriteLine(d); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-with-source-link/debugger-test-with-source-link.csproj b/src/mono/browser/debugger/tests/debugger-test-with-source-link/debugger-test-with-source-link.csproj deleted file mode 100644 index 879a6ee169ec7d..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-source-link/debugger-test-with-source-link.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - LibraryTest - 1.0.0 - true - https://github.com/dotnet/runtime.git - git - true - true - embedded - true - true - false - - diff --git a/src/mono/browser/debugger/tests/debugger-test-with-source-link/test.cs b/src/mono/browser/debugger/tests/debugger-test-with-source-link/test.cs deleted file mode 100644 index 93344258884c17..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-with-source-link/test.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace DebuggerTests -{ - public static class ClassToBreak - { - public static int TestBreakpoint() - { - return 50; - } - public static int valueToCheck = 10; - } - public class ClassToCheckFieldValue - { - public int valueToCheck; - public ClassToCheckFieldValue() - { - valueToCheck = 20; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj b/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj deleted file mode 100644 index 34367db0bff2da..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/debugger-test-without-debug-symbols-to-load.csproj +++ /dev/null @@ -1,6 +0,0 @@ - - - none - false - - diff --git a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs b/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs deleted file mode 100644 index 4899b8869ef402..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols-to-load/test.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace DebuggerTests -{ - public class ClassWithoutDebugSymbolsToInherit - { - private int propA {get;} - public int propB {get;} - protected int propC {get;} - private int d; - public int e; - protected int f; - private int G - { - get {return f + 1;} - } - private int H => f; - - public ClassWithoutDebugSymbolsToInherit() - { - propA = 10; - propB = 20; - propC = 30; - d = 40; - e = 50; - f = 60; - Console.WriteLine(propA); - Console.WriteLine(propB); - Console.WriteLine(propC); - Console.WriteLine(d); - Console.WriteLine(e); - Console.WriteLine(f); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/debugger-test-without-debug-symbols.csproj b/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/debugger-test-without-debug-symbols.csproj deleted file mode 100644 index 5c917c012921bc..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/debugger-test-without-debug-symbols.csproj +++ /dev/null @@ -1,6 +0,0 @@ - - - none - false - - diff --git a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/test.cs b/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/test.cs deleted file mode 100644 index a83d4852c0b588..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test-without-debug-symbols/test.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; - -namespace DebuggerTests -{ - public class ClassWithoutDebugSymbols - { - private int propA {get;} - public int propB {get;} - protected int propC {get;} - public int d; - public ClassWithoutDebugSymbols() - { - propA = 10; - propB = 20; - propC = 30; - d = 40; - Console.WriteLine(propA); - Console.WriteLine(propB); - Console.WriteLine(propC); - Console.WriteLine(d); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/BindStaticMethod.cs b/src/mono/browser/debugger/tests/debugger-test/BindStaticMethod.cs deleted file mode 100644 index b804c2b5cf22f3..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/BindStaticMethod.cs +++ /dev/null @@ -1,355 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices.JavaScript; -using System; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Threading; -using System.IO; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Collections.Generic; - -namespace DebuggerTests -{ - // this is fake implementation of legacy `bind_static_method` - // so that we don't have to rewrite all the tests which use it via `invoke_static_method` - public sealed partial class BindStaticMethod - { - - [JSExport] - [return: JSMarshalAs()] - public static object GetMethodInfo(string monoMethodName) - { - return GetMethodInfoImpl(monoMethodName); - } - - [JSExport] - public static unsafe IntPtr GetMonoMethodPtr(string monoMethodName) - { - var methodInfo = GetMethodInfoImpl(monoMethodName); - var temp = new IntPtrAndHandle { methodHandle = methodInfo.MethodHandle }; - return temp.ptr; - } - - public static MethodInfo GetMethodInfoImpl(string monoMethodName) - { - ArgumentNullException.ThrowIfNullOrEmpty(monoMethodName, nameof(monoMethodName)); - // [debugger-test] DebuggerTests.ArrayTestsClass:ObjectArrayMembers - var partsA = monoMethodName.Split(' '); - var assemblyName = partsA[0].Substring(1, partsA[0].Length - 2); - var partsN = partsA[1].Split(':'); - var className = partsN[0]; - var methodName = partsN[1]; - - var typeName = $"{className}, {assemblyName}"; - Type type = Type.GetType(typeName); - if (type == null) - { - throw new ArgumentException($"Type not found {typeName}"); - } - - var method = type.GetMethod(methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); - if (method == null) - { - throw new ArgumentException($"Method not found {className}.{methodName}"); - } - - return method; - } - - [JSExport] - public static string GetSignature([JSMarshalAs()] object methodInfo) - { - var method = (MethodInfo)methodInfo; - var sb = new StringBuilder("Invoke"); - foreach (var p in method.GetParameters()) - { - sb.Append("_"); - if (typeof(Task).IsAssignableFrom(p.ParameterType)) - { - sb.Append("Task"); - } - else if (p.ParameterType.GenericTypeArguments.Length > 0) - { - throw new NotImplementedException($"Parameter {p.Name} type {p.ParameterType.FullName}"); - } - else - { - sb.Append(p.ParameterType.Name); - } - } - - sb.Append("_"); - if (typeof(Task).IsAssignableFrom(method.ReturnType)) - { - sb.Append("Task"); - } - else if (method.ReturnType.GenericTypeArguments.Length > 0) - { - throw new NotImplementedException($"Method return type {method.ReturnType.FullName}"); - } - else - { - sb.Append(method.ReturnType.Name); - } - - return sb.ToString(); - } - - [JSExport] - public static void Invoke_Void([JSMarshalAs()] object methodInfo) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, null); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static Task Invoke_Task([JSMarshalAs()] object methodInfo) - { - try - { - var method = (MethodInfo)methodInfo; - return (Task)method.Invoke(null, null); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static string Invoke_String([JSMarshalAs()] object methodInfo) - { - try - { - var method = (MethodInfo)methodInfo; - return (string)method.Invoke(null, null); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_Boolean_Void([JSMarshalAs()] object methodInfo, bool p1) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static Task Invoke_Boolean_Task([JSMarshalAs()] object methodInfo, bool p1) - { - try - { - var method = (MethodInfo)methodInfo; - return (Task)method.Invoke(null, new object[] { p1 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_Int32_Void([JSMarshalAs()] object methodInfo, int p1) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_Int32_Int32_Void([JSMarshalAs()] object methodInfo, int p1, int p2) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1, p2 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_Int32_Int32_Int32_Void([JSMarshalAs()] object methodInfo, int p1, int p2, int p3) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1, p2, p3 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static int Invoke_Int32([JSMarshalAs()] object methodInfo) - { - try - { - var method = (MethodInfo)methodInfo; - return (int)method.Invoke(null, null); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static int Invoke_Int32_Int32([JSMarshalAs()] object methodInfo, int p1) - { - try - { - var method = (MethodInfo)methodInfo; - return (int)method.Invoke(null, new object[] { p1 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static int Invoke_Int32_Int32_Int32([JSMarshalAs()] object methodInfo, int p1, int p2) - { - try - { - var method = (MethodInfo)methodInfo; - return (int)method.Invoke(null, new object[] { p1, p2 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_String_Void([JSMarshalAs()] object methodInfo, string p1) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_String_String_Void([JSMarshalAs()] object methodInfo, string p1, string p2) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1, p2 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_String_String_String_String_Void([JSMarshalAs()] object methodInfo, string p1, string p2, string p3, string p4) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1, p2, p3, p4 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static string Invoke_String_String_String([JSMarshalAs()] object methodInfo, string p1, string p2) - { - try - { - var method = (MethodInfo)methodInfo; - return (string)method.Invoke(null, new object[] { p1, p2 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [JSExport] - public static void Invoke_String_String_String_String_String_String_String_String_Void([JSMarshalAs()] object methodInfo, string p1, string p2, string p3, string p4, string p5, string p6, string p7, string p8) - { - try - { - var method = (MethodInfo)methodInfo; - method.Invoke(null, new object[] { p1, p2, p3, p4, p5, p6, p7, p8 }); - } - catch (TargetInvocationException tie) - { - if (tie.InnerException != null) throw tie.InnerException; - throw; - } - } - - [StructLayout(LayoutKind.Explicit)] - private struct IntPtrAndHandle - { - [FieldOffset(0)] - internal IntPtr ptr; - - [FieldOffset(0)] - internal RuntimeMethodHandle methodHandle; - - [FieldOffset(0)] - internal RuntimeTypeHandle typeHandle; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-array-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-array-test.cs deleted file mode 100644 index 6192c60204da5d..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-array-test.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -namespace DebuggerTests -{ - public class ArrayTestsClass - { - public static void PrimitiveTypeLocals(bool call_other = false) - { - var int_arr = new int[] { 4, 70, 1 }; - var int_arr_empty = new int[0]; - int[] int_arr_null = null; - - if (call_other) - OtherMethod(); - - Console.WriteLine($"int_arr: {int_arr.Length}, {int_arr_empty.Length}, {int_arr_null?.Length}"); - } - - public static void ValueTypeLocals(bool call_other = false) - { - var point_arr = new Point[] - { - new Point { X = 5, Y = -2, Id = "point_arr#Id#0", Color = RGB.Green }, - new Point { X = 123, Y = 0, Id = "point_arr#Id#1", Color = RGB.Blue }, - }; - - var point_arr_empty = new Point[0]; - Point[] point_arr_null = null; - - if (call_other) - OtherMethod(); - - Console.WriteLine($"point_arr: {point_arr.Length}, {point_arr_empty.Length}, {point_arr_null?.Length}"); - } - - public static void ObjectTypeLocals(bool call_other = false) - { - var class_arr = new SimpleClass[] - { - new SimpleClass { X = 5, Y = -2, Id = "class_arr#Id#0", Color = RGB.Green }, - null, - new SimpleClass { X = 123, Y = 0, Id = "class_arr#Id#2", Color = RGB.Blue }, - }; - - var class_arr_empty = new SimpleClass[0]; - SimpleClass[] class_arr_null = null; - - if (call_other) - OtherMethod(); - - Console.WriteLine($"class_arr: {class_arr.Length}, {class_arr_empty.Length}, {class_arr_null?.Length}"); - } - - public static void GenericTypeLocals(bool call_other = false) - { - var gclass_arr = new GenericClass[] - { - null, - new GenericClass { Id = "gclass_arr#1#Id", Color = RGB.Red, Value = 5 }, - new GenericClass { Id = "gclass_arr#2#Id", Color = RGB.Blue, Value = -12 }, - }; - - var gclass_arr_empty = new GenericClass[0]; - GenericClass[] gclass_arr_null = null; - - if (call_other) - OtherMethod(); - - Console.WriteLine($"gclass_arr: {gclass_arr.Length}, {gclass_arr_empty.Length}, {gclass_arr_null?.Length}"); - } - - public static void GenericValueTypeLocals(bool call_other = false) - { - var gvclass_arr = new SimpleGenericStruct[] - { - new SimpleGenericStruct { Id = "gvclass_arr#1#Id", Color = RGB.Red, Value = new Point { X = 100, Y = 200, Id = "gvclass_arr#1#Value#Id", Color = RGB.Red } }, - new SimpleGenericStruct { Id = "gvclass_arr#2#Id", Color = RGB.Blue, Value = new Point { X = 10, Y = 20, Id = "gvclass_arr#2#Value#Id", Color = RGB.Green } } - }; - - var gvclass_arr_empty = new SimpleGenericStruct[0]; - SimpleGenericStruct[] gvclass_arr_null = null; - - if (call_other) - OtherMethod(); - - Console.WriteLine($"gvclass_arr: {gvclass_arr.Length}, {gvclass_arr_empty.Length}, {gvclass_arr_null?.Length}"); - } - - static void OtherMethod() - { - YetAnotherMethod(); - Console.WriteLine($"Just a placeholder for breakpoints"); - } - - static void YetAnotherMethod() - { - Console.WriteLine($"Just a placeholder for breakpoints"); - } - - public static void ObjectArrayMembers() - { - var c = new Container - { - id = "c#id", - ClassArrayProperty = new SimpleClass[] - { - new SimpleClass { X = 5, Y = -2, Id = "ClassArrayProperty#Id#0", Color = RGB.Green }, - new SimpleClass { X = 30, Y = 1293, Id = "ClassArrayProperty#Id#1", Color = RGB.Green }, - null - }, - ClassArrayField = new SimpleClass[] - { - null, - new SimpleClass { X = 5, Y = -2, Id = "ClassArrayField#Id#1", Color = RGB.Blue }, - new SimpleClass { X = 30, Y = 1293, Id = "ClassArrayField#Id#2", Color = RGB.Green }, - }, - PointsProperty = new Point[] - { - new Point { X = 5, Y = -2, Id = "PointsProperty#Id#0", Color = RGB.Green }, - new Point { X = 123, Y = 0, Id = "PointsProperty#Id#1", Color = RGB.Blue }, - }, - PointsField = new Point[] - { - new Point { X = 5, Y = -2, Id = "PointsField#Id#0", Color = RGB.Green }, - new Point { X = 123, Y = 0, Id = "PointsField#Id#1", Color = RGB.Blue }, - } - }; - - Console.WriteLine($"Back from PlaceholderMethod, {c.ClassArrayProperty?.Length}"); - c.PlaceholderMethod(); - Console.WriteLine($"Back from PlaceholderMethod, {c.id}"); - } - - public static async Task ValueTypeLocalsAsync(bool call_other = false) - { - var gvclass_arr = new SimpleGenericStruct[] - { - new SimpleGenericStruct { Id = "gvclass_arr#1#Id", Color = RGB.Red, Value = new Point { X = 100, Y = 200, Id = "gvclass_arr#1#Value#Id", Color = RGB.Red } }, - new SimpleGenericStruct { Id = "gvclass_arr#2#Id", Color = RGB.Blue, Value = new Point { X = 10, Y = 20, Id = "gvclass_arr#2#Value#Id", Color = RGB.Green } } - }; - - var gvclass_arr_empty = new SimpleGenericStruct[0]; - SimpleGenericStruct[] gvclass_arr_null = null; - Console.WriteLine($"ValueTypeLocalsAsync: call_other: {call_other}"); - SimpleGenericStruct gvclass; - Point[] points = null; - - if (call_other) - { - (gvclass, points) = await new ArrayTestsClass().InstanceMethodValueTypeLocalsAsync>(gvclass_arr[0]); - Console.WriteLine($"* gvclass: {gvclass}, points: {points.Length}"); - } - - Console.WriteLine($"gvclass_arr: {gvclass_arr.Length}, {gvclass_arr_empty.Length}, {gvclass_arr_null?.Length}"); - return true; - } - - public async Task<(T, Point[])> InstanceMethodValueTypeLocalsAsync(T t1) - { - var point_arr = new Point[] - { - new Point { X = 5, Y = -2, Id = "point_arr#Id#0", Color = RGB.Red }, - new Point { X = 123, Y = 0, Id = "point_arr#Id#1", Color = RGB.Blue } - }; - var point = new Point { X = 45, Y = 51, Id = "point#Id", Color = RGB.Green }; - - Console.WriteLine($"point_arr: {point_arr.Length}, T: {t1}, point: {point}"); - return await Task.FromResult((t1, new Point[] { point_arr[0], point_arr[1], point })); - } - - // A workaround for method invocations on structs not working right now - public static async Task EntryPointForStructMethod(bool call_other = false) - { - await Point.AsyncMethod(call_other); - } - - public static void GenericValueTypeLocals2(bool call_other = false) - { - var gvclass_arr = new SimpleGenericStruct[] - { - new SimpleGenericStruct - { - Id = "gvclass_arr#0#Id", - Color = RGB.Red, - Value = new Point[] - { - new Point { X = 100, Y = 200, Id = "gvclass_arr#0#0#Value#Id", Color = RGB.Red }, - new Point { X = 100, Y = 200, Id = "gvclass_arr#0#1#Value#Id", Color = RGB.Green } - } - }, - - new SimpleGenericStruct - { - Id = "gvclass_arr#1#Id", - Color = RGB.Blue, - Value = new Point[] - { - new Point { X = 100, Y = 200, Id = "gvclass_arr#1#0#Value#Id", Color = RGB.Green }, - new Point { X = 100, Y = 200, Id = "gvclass_arr#1#1#Value#Id", Color = RGB.Blue } - } - }, - }; - - var gvclass_arr_empty = new SimpleGenericStruct[0]; - SimpleGenericStruct[] gvclass_arr_null = null; - - if (call_other) - OtherMethod(); - - Console.WriteLine($"gvclass_arr: {gvclass_arr.Length}, {gvclass_arr_empty.Length}, {gvclass_arr_null?.Length}"); - } - } - - public class Container - { - public string id; - public SimpleClass[] ClassArrayProperty { get; set; } - public SimpleClass[] ClassArrayField; - - public Point[] PointsProperty { get; set; } - public Point[] PointsField; - - public void PlaceholderMethod() - { - Console.WriteLine($"Container.PlaceholderMethod"); - } - } - - public struct Point - { - public int X, Y; - public string Id { get; set; } - public RGB Color { get; set; } - - /* instance too */ - public static async Task AsyncMethod(bool call_other) - { - int local_i = 5; - var sc = new SimpleClass { X = 10, Y = 45, Id = "sc#Id", Color = RGB.Blue }; - if (call_other) - await new Point { X = 90, Y = -4, Id = "point#Id", Color = RGB.Green }.AsyncInstanceMethod(sc); - Console.WriteLine($"AsyncMethod local_i: {local_i}, sc: {sc.Id}"); - } - - public async Task AsyncInstanceMethod(SimpleClass sc_arg) - { - var local_gs = new SimpleGenericStruct { Id = "local_gs#Id", Color = RGB.Green, Value = 4 }; - sc_arg.Id = "sc_arg#Id"; - Console.WriteLine($"AsyncInstanceMethod sc_arg: {sc_arg.Id}, local_gs: {local_gs.Id}"); await Task.CompletedTask; - } - - public void GenericInstanceMethod(T sc_arg) where T : SimpleClass - { - var local_gs = new SimpleGenericStruct { Id = "local_gs#Id", Color = RGB.Green, Value = 4 }; - sc_arg.Id = "sc_arg#Id"; - Console.WriteLine($"AsyncInstanceMethod sc_arg: {sc_arg.Id}, local_gs: {local_gs.Id}"); - } - } - - public class SimpleClass - { - public int X, Y; - public string Id { get; set; } - public RGB Color { get; set; } - - public Point PointWithCustomGetter { get { return new Point { X = 100, Y = 400, Id = "SimpleClass#Point#gen#Id", Color = RGB.Green }; } } - } - - public class GenericClass - { - public string Id { get; set; } - public RGB Color { get; set; } - public T Value { get; set; } - } - - public struct SimpleGenericStruct - { - public string Id { get; set; } - public RGB Color { get; set; } - public T Value { get; set; } - } - - public class EntryClass - { - public static void run() - { - ArrayTestsClass.PrimitiveTypeLocals(true); - ArrayTestsClass.ValueTypeLocals(true); - ArrayTestsClass.ObjectTypeLocals(true); - - ArrayTestsClass.GenericTypeLocals(true); - ArrayTestsClass.GenericValueTypeLocals(true); - ArrayTestsClass.GenericValueTypeLocals2(true); - - ArrayTestsClass.ObjectArrayMembers(); - - ArrayTestsClass.ValueTypeLocalsAsync(true).Wait(); - - ArrayTestsClass.EntryPointForStructMethod(true).Wait(); - - var sc = new SimpleClass { X = 10, Y = 45, Id = "sc#Id", Color = RGB.Blue }; - new Point { X = 90, Y = -4, Id = "point#Id", Color = RGB.Green }.GenericInstanceMethod(sc); - } - } - public class MultiDimensionalArray - { - public static void run() - { - var int_arr_1 = new int[2]; - int_arr_1[0] = 0; - int_arr_1[1] = 1; - - var int_arr_2 = new int[2, 3]; - int_arr_2[0, 0] = 0; - int_arr_2[0, 1] = 1; - int_arr_2[0, 2] = 2; - int_arr_2[1, 0] = 10; - int_arr_2[1, 1] = 11; - int_arr_2[1, 2] = 12; - - var int_arr_3 = new int[2, 3, 3]; - int_arr_3[0, 0, 0] = 0; - int_arr_3[0, 0, 1] = 1; - int_arr_3[0, 0, 2] = 2; - int_arr_3[0, 1, 0] = 10; - int_arr_3[0, 1, 1] = 11; - int_arr_3[0, 1, 2] = 12; - int_arr_3[0, 2, 0] = 20; - int_arr_3[0, 2, 1] = 21; - int_arr_3[0, 2, 2] = 22; - int_arr_3[1, 0, 0] = 100; - int_arr_3[1, 0, 1] = 101; - int_arr_3[1, 0, 2] = 102; - int_arr_3[1, 1, 0] = 110; - int_arr_3[1, 1, 1] = 111; - int_arr_3[1, 1, 2] = 112; - int_arr_3[1, 2, 0] = 120; - int_arr_3[1, 2, 1] = 121; - int_arr_3[1, 2, 2] = 122; - - System.Diagnostics.Debugger.Break(); - Console.WriteLine($"int_arr: {int_arr_3.Length}"); - } - } - - public class InlineArray - { - struct StructWithInlineArray - { - public Arr1 myInlineArray; - } - class ClassWithInlineArrayField - { - public Arr1 myInlineArray; - public Arr1 InlineArrayProp => myInlineArray; - public StructWithInlineArray myStructWithInlineArray; - } - class One {} - class Two {} - class Three {} - class Four {} - public struct E - { - public int x; - public int y; - public object o; - } - - [System.Runtime.CompilerServices.InlineArray(Length)] - public struct Arr1 - { - public const int Length = 42; - public E e; - } - - [System.Runtime.CompilerServices.InlineArray(Length)] - struct Arr2 - { - public const int Length = 42; - public int e; - public int InlineMethod(int n) => n + 100; - } - - [System.Runtime.CompilerServices.InlineArray(1)] - struct Arr3 - { - public int e; - } - - [System.Runtime.CompilerServices.InlineArray(Length)] - struct Arr4 - { - public static int myStaticField = 50; - public const int Length = 42; - public E e; - } - - private static Arr1 Initialize(Arr1 s) - { - s[0].o = new One(); - s[0].x = 1; - s[0].y = 2; - s[1].o = new Two(); - s[1].x = 3; - s[1].y = 4; - s[2].o = new Three(); - s[2].x = 5; - s[2].y = 6; - s[3].o = new Four(); - s[3].x = 7; - s[3].y = 8; - return s; - } - public static void run() - { - int a = 0; - int b = 1; - Arr1 s = default; - s = Initialize(s); - ClassWithInlineArrayField classWithInlineArrayField = new (); - s = Initialize(classWithInlineArrayField.myInlineArray); - classWithInlineArrayField.myInlineArray[0].o = new One(); - classWithInlineArrayField.myInlineArray[0].x = 1; - classWithInlineArrayField.myInlineArray[0].y = 2; - classWithInlineArrayField.myInlineArray[1].o = new Two(); - classWithInlineArrayField.myInlineArray[1].x = 3; - classWithInlineArrayField.myInlineArray[1].y = 4; - //classWithInlineArrayField.InlineArrayProp[0].o = new One(); - //classWithInlineArrayField.InlineArrayProp[0].x = 1; - //classWithInlineArrayField.InlineArrayProp[0].y = 2; - //classWithInlineArrayField.InlineArrayProp[1].o = new Two(); - //classWithInlineArrayField.InlineArrayProp[1].x = 3; - //classWithInlineArrayField.InlineArrayProp[1].y = 4; - classWithInlineArrayField.myStructWithInlineArray.myInlineArray[0].o = new One(); - classWithInlineArrayField.myStructWithInlineArray.myInlineArray[0].x = 1; - classWithInlineArrayField.myStructWithInlineArray.myInlineArray[0].y = 2; - classWithInlineArrayField.myStructWithInlineArray.myInlineArray[1].o = new Two(); - classWithInlineArrayField.myStructWithInlineArray.myInlineArray[1].x = 3; - classWithInlineArrayField.myStructWithInlineArray.myInlineArray[1].y = 4; - System.Diagnostics.Debugger.Break(); - Console.WriteLine(s[0].o.GetType().Name); - } - - public static void run2() - { - Arr2 a2 = default; //test with primitive type - Arr3 a3 = default; //test with length==1 - Arr4 a4 = default; //test with static field - a2[0] = 1; - a3[0] = 2; - a4[0].o = new One(); - a4[0].x = 1; - a4[0].y = 2; - a4[1].o = new Two(); - a4[1].x = 3; - a4[1].y = 4; - Console.WriteLine($"olha thays - {Arr4.myStaticField}"); - System.Diagnostics.Debugger.Break(); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-assignment-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-assignment-test.cs deleted file mode 100644 index e316c2a658bf12..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-assignment-test.cs +++ /dev/null @@ -1,234 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace DebuggerTests -{ - public class StepInTest - { - public static int TestedMethod(T value) - { - // 1) break here and check un-assigned variables - T r; - r = value; - // 2) break here and check assigned variables - return 0; - } - } - - public class MONO_TYPE_OBJECT - { - public static int Prepare() - { - var value = new object(); - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_CLASS - { - public static int Prepare() - { - var value = new MONO_TYPE_CLASS(); - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_BOOLEAN - { - public static int Prepare() - { - var value = true; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_CHAR - { - public static int Prepare() - { - var value = 'a'; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_I1 - { - public static int Prepare() - { - sbyte value = -1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_I2 - { - public static int Prepare() - { - short value = -1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_I4 - { - public static int Prepare() - { - int value = -1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_I8 - { - public static int Prepare() - { - long value = -1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_U1 - { - public static int Prepare() - { - byte value = 1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_U2 - { - public static int Prepare() - { - ushort value = 1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_U4 - { - public static int Prepare() - { - uint value = 1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_U8 - { - public static int Prepare() - { - ulong value = 1; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_R4 - { - public static int Prepare() - { - float value = 3.1415F; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_R8 - { - public static int Prepare() - { - double value = 3.1415D; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_STRING - { - public static int Prepare() - { - string value = "hello"; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_ENUM - { - public static int Prepare() - { - RGB value = RGB.Blue; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_ARRAY - { - public static int Prepare() - { - byte[] value = new byte[2] { 1, 2 }; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_VALUETYPE - { - public static int Prepare() - { - Point value = new Point(); - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_VALUETYPE2 - { - public static int Prepare() - { - Decimal value = 1.1m; - return StepInTest.TestedMethod(value); - } - } - - public class MONO_TYPE_GENERICINST - { - public static int Prepare() - { - Func value = MONO_TYPE_GENERICINST.Prepare; - return StepInTest>.TestedMethod(value); - } - } - - public class MONO_TYPE_FNPTR - { - public unsafe static int Prepare() - { - delegate* value = &MONO_TYPE_FNPTR.Prepare; - return TestedMethod(value); - } - - public unsafe static int TestedMethod(delegate* value) - { - delegate* r; - r = value; - return 0; - } - } - - public class MONO_TYPE_PTR - { - public unsafe static int Prepare() - { - int a = 1; int* value = &a; - return TestedMethod(value); - } - - public unsafe static int TestedMethod(int* value) - { - int* r; - r = value; - return 0; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-async-step.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-async-step.cs deleted file mode 100644 index f94cf8d7edd10e..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-async-step.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using System.Net; -using System.Net.Http; - -namespace DebuggerTests -{ - public class AsyncStepClass - { - static HttpClient client = new HttpClient(); - public static async Task TestAsyncStepOut() - { - await TestAsyncStepOut2("foobar"); - } - - public static async Task TestAsyncStepOut2(string some) - { - var resp = await client.GetAsync("http://localhost:9400/debugger-driver.html"); - Console.WriteLine($"resp: {resp}"); /// BP at this line - - return 10; - } - - public static void SimpleMethod() - { - var dt = new DateTime(4512, 1, 3, 5, 7, 9); - OtherMethod0(dt.AddMinutes(10)); - Console.WriteLine ($"Back"); - } - - static void OtherMethod0(DateTime dt) - { - Console.WriteLine ($"dt: {dt}"); - OtherMethod1(); - } - - static void OtherMethod1() - { - Console.WriteLine ($"In OtherMethod1"); - } - - public static async Task StepOverTestAsync() - { - await MethodWithTwoAwaitsAsync(); - Console.WriteLine ($"StepOverTestAsync: done"); - } - - public static async Task MethodWithTwoAwaitsAsync() - { - Console.WriteLine ($"first await"); - await Task.Delay(50); - Console.WriteLine ($"second await"); - await Task.Delay(50); - Console.WriteLine ($"done"); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-async-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-async-test.cs deleted file mode 100644 index 3c103d3d6f489d..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-async-test.cs +++ /dev/null @@ -1,347 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using System.Runtime.CompilerServices; - -namespace DebuggerTests.AsyncTests -{ - public class ContinueWithTests - { - public DateTime Date => new DateTime(2510, 1, 2, 3, 4, 5); - - public static async Task RunAsync() - { - await ContinueWithStaticAsync("foobar"); - await new ContinueWithTests().ContinueWithInstanceAsync("foobar"); - - await NestedContinueWithStaticAsync("foobar"); - await new ContinueWithTests().NestedContinueWithInstanceAsync("foobar"); - await new ContinueWithTests().ContinueWithInstanceUsingThisAsync("foobar"); - - } - - public static async Task ContinueWithStaticAsync(string str) - { - await Task.Delay(1000).ContinueWith(t => - { - var code = t.Status; - var dt = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine ($"First continueWith: {code}, {dt}"); //t, code, dt - }); - Console.WriteLine ($"done with this method"); - } - - public static async Task NestedContinueWithStaticAsync(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - var code = t.Status; - var ncs_dt0 = new DateTime(3412, 4, 6, 8, 0, 2); - Console.WriteLine ($"First continueWith: {code}, {ncs_dt0}"); // t, code, str, dt0 - await Task.Delay(300).ContinueWith(t2 => - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine ($"t2: {t2.Status}, str: {str}, {ncs_dt1}, {ncs_dt0}");//t2, dt1, str, dt0 - }); - }); - Console.WriteLine ($"done with this method"); - } - - public async Task ContinueWithInstanceAsync(string str) - { - await Task.Delay(1000).ContinueWith(t => - { - var code = t.Status; - var dt = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine ($"First continueWith: {code}, {dt}");// t, code, dt - }); - Console.WriteLine ($"done with this method"); - } - - public async Task ContinueWithInstanceUsingThisAsync(string str) - { - await Task.Delay(1000).ContinueWith(t => - { - var code = t.Status; - var dt = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine ($"First continueWith: {code}, {dt}, {this.Date}"); - }); - Console.WriteLine ($"done with this method"); - } - - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public async Task NestedContinueWithInstanceAsync(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - var code = t.Status; - var dt0 = new DateTime(3412, 4, 6, 8, 0, 2); - if (str == "oi") - { - dt0 = new DateTime(3415, 4, 6, 8, 0, 2); - } - Console.WriteLine ($"First continueWith: {code}, {dt0}, {Date}");//this, t, code, str, dt0 - await Task.Delay(300).ContinueWith(t2 => - { - var dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine ($"t2: {t2.Status}, str: {str}, {dt1}, {dt0}");//this, t2, dt1, str, dt0 - }); - Console.WriteLine("done with this continueWith"); - await Task.Delay(300).ContinueWith(t2 => Console.WriteLine ($"t2: {t2.Status}, str: {str}, {dt0}")); - }); - Console.WriteLine ($"done with this method"); - } - - public static async Task RunAsyncWithLineHidden() - { - await HiddenLinesInAnAsyncBlock("foobar"); - await HiddenLinesJustBeforeANestedAsyncBlock("foobar"); - await HiddenLinesAtTheEndOfANestedAsyncBlockWithNoLinesAtEndOfTheMethod("foobar"); - await HiddenLinesAtTheEndOfANestedAsyncBlockWithBreakableLineAtEndOfTheMethod("foobar"); - await HiddenLinesContainingStartOfAnAsyncBlock("foobar"); - await HiddenLinesAtTheEndOfANestedAsyncBlockWithWithLineDefaultOutsideTheMethod("foobar"); - await HiddenLinesAtTheEndOfANestedAsyncBlockWithWithLineDefaultOutsideTheMethod2("foobar"); - System.Diagnostics.Debugger.Break(); - } - public static async Task HiddenLinesInAnAsyncBlock(string str) - { - await Task.Delay(500).ContinueWith(async t => - { -#line hidden - var code = t.Status; -#line default - var ncs_dt0 = new DateTime(3412, 4, 6, 8, 0, 2); - Console.WriteLine ($"First continueWith: {code}, {ncs_dt0}"); // t, code, str, dt0 - await Task.Delay(300).ContinueWith(t2 => - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine ($"t2: {t2.Status}, str: {str}, {ncs_dt1}, {ncs_dt0}");//t2, dt1, str, dt0 - }); - }); - Console.WriteLine ($"done with this method"); - } - static async Task HiddenLinesJustBeforeANestedAsyncBlock(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - Console.WriteLine($"First continueWith"); - #line hidden - var code = t.Status; // Next line will be in the next async block? hidden line just before async block - Console.WriteLine("another line of code"); - #line default - await Task.Delay(300).ContinueWith(t2 => - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine($"t2: {t2.Status}, str: {str}, {ncs_dt1}");//t2, dt1, str, dt0 - }); - }); - Console.WriteLine($"done with this method"); - } - - static async Task HiddenLinesAtTheEndOfANestedAsyncBlockWithNoLinesAtEndOfTheMethod(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - var code = t.Status; - Console.WriteLine($"First continueWith"); - await Task.Delay(300).ContinueWith(t2 => - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine($"t2: {t2.Status}, str: {str}, {ncs_dt1}");//t2, dt1, str, dt0 - #line hidden - Console.WriteLine("something else"); // Next line will be in the next async block? hidden line at end of async block - #line default - }); - }); - } - - static async Task HiddenLinesAtTheEndOfANestedAsyncBlockWithBreakableLineAtEndOfTheMethod(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - var code = t.Status; - Console.WriteLine($"First continueWith"); - await Task.Delay(300).ContinueWith(t2 => - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine($"t2: {t2.Status}, str: {str}, {ncs_dt1}");//t2, dt1, str, dt0 - #line hidden - Console.WriteLine("something else"); // Next line will be in the next async block? hidden line at end of async block - #line default - }); - }); - Console.WriteLine ($"Last line.."); - } - - static async Task HiddenLinesContainingStartOfAnAsyncBlock(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - var code = t.Status; - Console.WriteLine($"First continueWith"); - #line hidden - await Task.Delay(300).ContinueWith(t2 => - #line default - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine($"t2: {t2.Status}, str: {str}, {ncs_dt1}");//t2, dt1, str, dt0 - Console.WriteLine("something else"); // Next line will be in the next async block? hidden line at end of async block - }); - }); - Console.WriteLine($"done with this method"); - } - - static async Task HiddenLinesAtTheEndOfANestedAsyncBlockWithWithLineDefaultOutsideTheMethod(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - var code = t.Status; - Console.WriteLine($"First continueWith"); - await Task.Delay(300).ContinueWith(t2 => - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine($"t2: {t2.Status}, str: {str}, {ncs_dt1}");//t2, dt1, str, dt0 - #line hidden - Console.WriteLine("somethind else"); // Next line will be in the next async block? hidden line at end of async block - }); - }); - #line default - Console.WriteLine($"done with this method"); - } - - static async Task HiddenLinesAtTheEndOfANestedAsyncBlockWithWithLineDefaultOutsideTheMethod2(string str) - { - await Task.Delay(500).ContinueWith(async t => - { - var code = t.Status; - Console.WriteLine($"First continueWith"); - await Task.Delay(300).ContinueWith(t2 => - { - var ncs_dt1 = new DateTime(4513, 4, 5, 6, 7, 8); - Console.WriteLine($"t2: {t2.Status}, str: {str}, {ncs_dt1}");//t2, dt1, str, dt0 - #line hidden - Console.WriteLine("somethind else"); // Next line will be in the next async block? hidden line at end of async block - }); - #line default - }); - Console.WriteLine($"done with this method"); - } - } - - public class VariablesWithSameNameDifferentScopes - { - public static async Task Run() - { - await RunCSharpScope(10); - await RunCSharpScope(1000); - } - - public static async Task RunCSharpScope(int number) - { - await Task.Delay(1); - if (number < 999) - { - string testCSharpScope = "hello"; string onlyInFirstScope = "only-in-first-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - else - { - string testCSharpScope = "hi"; string onlyInSecondScope = "only-in-second-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - } - - public static async Task RunContinueWith() - { - await RunContinueWithSameVariableName(10); - await RunContinueWithSameVariableName(1000); - } - - public static async Task RunNestedContinueWith() - { - await RunNestedContinueWithSameVariableName(10); - await RunNestedContinueWithSameVariableName(1000); - } - - public static async Task RunContinueWithSameVariableName(int number) - { - await Task.Delay(500).ContinueWith(async t => - { - await Task.Delay(1); - if (number < 999) - { - var testCSharpScope = new String("hello"); string onlyInFirstScope = "only-in-first-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - else - { - var testCSharpScope = new String("hi"); string onlyInSecondScope = "only-in-second-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - }); - Console.WriteLine ($"done with this method"); - } - - public static async Task RunNestedContinueWithSameVariableName(int number) - { - await Task.Delay(500).ContinueWith(async t => - { - if (number < 999) - { - var testCSharpScope = new String("hello_out"); string onlyInFirstScope = "only-in-first-scope_out"; - Console.WriteLine(testCSharpScope); - } - else - { - var testCSharpScope = new String("hi_out"); string onlyInSecondScope = "only-in-second-scope_out"; - Console.WriteLine(testCSharpScope); - } - await Task.Delay(300).ContinueWith(t2 => - { - if (number < 999) - { - var testCSharpScope = new String("hello"); string onlyInFirstScope = "only-in-first-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - else - { - var testCSharpScope = new String("hi"); string onlyInSecondScope = "only-in-second-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - }); - }); - Console.WriteLine ($"done with this method"); - } - - public static void RunNonAsyncMethod() - { - RunNonAsyncMethodSameVariableName(10); - RunNonAsyncMethodSameVariableName(1000); - } - - public static string RunNonAsyncMethodSameVariableName(int number) - { - if (number < 999) - { - var testCSharpScope = new String("hello"); string onlyInFirstScope = "only-in-first-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - else - { - var testCSharpScope = new String("hi"); string onlyInSecondScope = "only-in-second-scope"; - System.Diagnostics.Debugger.Break(); - return testCSharpScope; - } - } - } - -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-cfo-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-cfo-test.cs deleted file mode 100644 index 612f76c739a83c..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-cfo-test.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace DebuggerTests -{ - public class CallFunctionOnTest - { - public static void LocalsTest(int len) - { - var big = new int[len]; - for (int i = 0; i < len; i++) - big[i] = i + 1000; - - var simple_struct = new Math.SimpleStruct() { dt = new DateTime(2020, 1, 2, 3, 4, 5), gs = new Math.GenericStruct { StringField = $"simple_struct # gs # StringField" } }; - - var ss_arr = new Math.SimpleStruct[len]; - for (int i = 0; i < len; i++) - ss_arr[i] = new Math.SimpleStruct() { dt = new DateTime(2020 + i, 1, 2, 3, 4, 5), gs = new Math.GenericStruct { StringField = $"ss_arr # {i} # gs # StringField" } }; - - var nim = new Math.NestedInMath { SimpleStructProperty = new Math.SimpleStruct() { dt = new DateTime(2010, 6, 7, 8, 9, 10) } }; - Action> action = Math.DelegateTargetWithVoidReturn; - Console.WriteLine("foo"); - } - - public static void PropertyGettersTest() - { - var ptd = new ClassWithProperties { DTAutoProperty = new DateTime(4, 5, 6, 7, 8, 9), V = 0xDEADBEEF }; - var swp = new StructWithProperties { DTAutoProperty = new DateTime(4, 5, 6, 7, 8, 9), V = 0xDEADBEEF }; - System.Console.WriteLine("break here"); - } - - public static async System.Threading.Tasks.Task PropertyGettersTestAsync() - { - var ptd = new ClassWithProperties { DTAutoProperty = new DateTime(4, 5, 6, 7, 8, 9), V = 0xDEADBEEF }; - var swp = new StructWithProperties { DTAutoProperty = new DateTime(4, 5, 6, 7, 8, 9), V = 0xDEADBEEF }; - System.Console.WriteLine("break here"); - await System.Threading.Tasks.Task.CompletedTask; - } - - public static void MethodForNegativeTests(string value = null) - { - var ptd = new ClassWithProperties { StringField = value }; - var swp = new StructWithProperties { StringField = value }; - Console.WriteLine("break here"); - } - } - - class ClassWithProperties - { - public uint V; - public uint Int { get { return V + (uint)DT.Month; } } - public string String { get { return $"String property, V: 0x{V:X}"; } } - public DateTime DT { get { return new DateTime(3, 4, 5, 6, 7, 8); } } - - public int[] IntArray { get { return new int[] { 10, 20 }; } } - public DateTime[] DTArray { get { return new DateTime[] { new DateTime(6, 7, 8, 9, 10, 11), new DateTime(1, 2, 3, 4, 5, 6) }; } } - public DateTime DTAutoProperty { get; set; } - public string StringField; - - private static DateTime PrivateStaticDTProp => new DateTime(6, 5, 4, 3, 2, 1); - public static DateTime PublicStaticDTProp => new DateTime(3, 6, 1, 7, 9, 4); - internal static DateTime InternalStaticDTProp => new DateTime(2, 3, 1, 5, 0, 3); - } - - struct StructWithProperties - { - public uint V; - public uint Int { get { return V + (uint)DT.Month; } } - public string String { get { return $"String property, V: 0x{V:X}"; } } - public DateTime DT { get { return new DateTime(3, 4, 5, 6, 7, 8); } } - - public int[] IntArray { get { return new int[] { 10, 20 }; } } - public DateTime[] DTArray { get { return new DateTime[] { new DateTime(6, 7, 8, 9, 10, 11), new DateTime(1, 2, 3, 4, 5, 6) }; } } - public DateTime DTAutoProperty { get; set; } - public string StringField; - - private static DateTime PrivateStaticDTProp => new DateTime(6, 5, 4, 3, 2, 1); - public static DateTime PublicStaticDTProp => new DateTime(3, 6, 1, 7, 9, 4); - internal static DateTime InternalStaticDTProp => new DateTime(2, 3, 1, 5, 0, 3); - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-custom-view-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-custom-view-test.cs deleted file mode 100644 index c273e4955c968c..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-custom-view-test.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using System.Diagnostics; -using System.Collections.Generic; - -namespace DebuggerTests -{ - [DebuggerDisplay("Some {Val1} Value {Val2} End")] - class WithDisplayString - { - internal string Val1 = "one"; - - public int Val2 { get { return 2; } } - } - - class WithToString - { - public override string ToString () - { - return "SomeString"; - } - } - - [DebuggerTypeProxy(typeof(TheProxy))] - class WithProxy - { - public string Val1 { - get { return "one"; } - } - } - - [DebuggerTypeProxy(typeof(TheProxy))] - struct WithProxyStruct - { - public string Val1 => "one struct"; - } - - class TheProxy - { - string message; - - public TheProxy () { } - - public TheProxy (string text, int num) - { - Console.WriteLine($"I'm an empty TheProxy constructor with two params: 1: {text}, 2: {num}"); - } - - public TheProxy(WithProxy wp) => message = wp.Val1; - - public TheProxy(WithProxyStruct wp) => message = wp.Val1; - - - public string Val2 { - get { return message; } - } - } - - [DebuggerDisplay("{GetDebuggerDisplay(), nq}")] - class DebuggerDisplayMethodTest - { - int someInt = 32; - int someInt2 = 43; - - string GetDebuggerDisplay () - { - return "First Int = " + someInt + ", Second Int = " + someInt2; - } - } - - [DebuggerDisplay("FirstName = {FirstName}, SurName = {SurName}, Age = {Age}")] - public class Person { - public string FirstName { get; set; } - public string SurName { get; set; } - public int Age { get; set; } - } - - class DebuggerCustomViewTest - { - public static void run() - { - var a = new WithDisplayString(); - var b = new WithProxy(); - var bs = new WithProxyStruct(); - var c = new DebuggerDisplayMethodTest(); - List myList = new List{ 1, 2, 3, 4 }; - var listToTestToList = System.Linq.Enumerable.Range(1, 11); - - Dictionary openWith = new Dictionary(); - - openWith.Add("txt", "notepad"); - openWith.Add("bmp", "paint"); - openWith.Add("dib", "paint"); - var person1 = new Person { FirstName = "Anton", SurName="Mueller", Age = 44}; - var person2 = new Person { FirstName = "Lisa", SurName="M\u00FCller", Age = 41}; - - Console.WriteLine("break here"); - - Console.WriteLine("break here"); - } - } - - class DebuggerCustomViewTest2 - { - public static void run() - { - List myList = new List (); - List myList2 = new List (); - - myList.Add(1); - myList.Add(2); - myList.Add(3); - myList.Add(4); - myList2.Add(1); - myList2.Add(1); - myList2.Add(1); - myList2.Add(1); - - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-datetime-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-datetime-test.cs deleted file mode 100644 index 063a71e8526a30..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-datetime-test.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -namespace DebuggerTests -{ - public class DateTimeTest - { - public static void LocaleTest(string locale) - { - CultureInfo.CurrentCulture = new CultureInfo(locale, false); - Console.WriteLine("CurrentCulture is {0}", CultureInfo.CurrentCulture.Name); - - DateTimeFormatInfo dtfi = CultureInfo.GetCultureInfo(locale).DateTimeFormat; - var fdtp = dtfi.FullDateTimePattern; - var ldp = dtfi.LongDatePattern; - var ltp = dtfi.LongTimePattern; - var sdp = dtfi.ShortDatePattern; - var stp = dtfi.ShortTimePattern; - - DateTime dt = new DateTime(2020, 1, 2, 3, 4, 5); - - Console.WriteLine("Current time is {0}", dt); - - return; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-driver.html b/src/mono/browser/debugger/tests/debugger-test/debugger-driver.html deleted file mode 100644 index e140e64e6ad4cd..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-driver.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - Stuff goes here - - diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-evaluate-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-evaluate-test.cs deleted file mode 100644 index 50fb3d0a860f19..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-evaluate-test.cs +++ /dev/null @@ -1,2317 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -namespace DebuggerTests -{ - public class EvaluateTestsClass - { - public class TestEvaluate - { - public int a; - public int b; - public int c; - public DateTime dt = new DateTime(2000, 5, 4, 3, 2, 1); - public TestEvaluate NullIfAIsNotZero => a != 0 ? null : this; - public void run(int g, int h, string a, string valString, int this_a) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - int i = d + e + f; - var local_dt = new DateTime(2010, 9, 8, 7, 6, 5); - this.a = 1; - b = 2; - c = 3; - this.a = this.a + 1; - b = b + 1; - c = c + 1; - } - } - - public static void EvaluateLocals() - { - TestEvaluate f = new TestEvaluate(); - f.run(100, 200, "9000", "test", 45); - var f_s = new EvaluateTestsStructWithProperties(); - f_s.InstanceMethod(100, 200, "test", f_s); - f_s.GenericInstanceMethod(100, 200, "test", f_s); - - var f_g_s = new EvaluateTestsGenericStruct(); - f_g_s.EvaluateTestsGenericStructInstanceMethod(100, 200, "test"); - } - - public static void EvaluateLocalsFromAnotherAssembly() - { - var asm = System.Reflection.Assembly.LoadFrom("lazy-debugger-test.dll"); - var myType = asm.GetType("DebuggerTests.ClassToCheckFieldValue"); - var myMethod = myType.GetConstructor(new Type[] { }); - var a = myMethod.Invoke(new object[]{}); - } - - } - - public struct EvaluateTestsGenericStruct - { - public int a; - public int b; - public int c; - DateTime dateTime; - public void EvaluateTestsGenericStructInstanceMethod(int g, int h, string valString) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - T t = default(T); - a = a + 1; - b = b + 2; - c = c + 3; - } - } - - public class EvaluateTestsClassWithProperties - { - public int a; - public int b; - public int c { get; set; } - - public DateTime dateTime; - public DateTime DTProp => dateTime.AddMinutes(10); - public int IntProp => a + 5; - public string PropertyThrowException => throw new Exception("error"); - public string SetOnlyProp { set { a = value.Length; } } - public EvaluateTestsClassWithProperties NullIfAIsNotZero => a != 1908712 ? null : new EvaluateTestsClassWithProperties(0); - public EvaluateTestsClassWithProperties NewInstance => new EvaluateTestsClassWithProperties(3); - - public EvaluateTestsClassWithProperties(int bias) - { - a = 4; - b = 0; - c = 0; - dateTime = new DateTime(2010, 9, 8, 7, 6, 5 + bias); - } - - public static async Task run() - { - var obj = new EvaluateTestsClassWithProperties(0); - var obj2 = new EvaluateTestsClassWithProperties(0); - obj.InstanceMethod(400, 123, "just a test", obj2); - new EvaluateTestsClassWithProperties(0).GenericInstanceMethod(400, 123, "just a test", obj2); - new EvaluateTestsClassWithProperties(0).EvaluateShadow(new DateTime(2020, 3, 4, 5, 6, 7), obj.NewInstance); - - await new EvaluateTestsClassWithProperties(0).InstanceMethodAsync(400, 123, "just a test", obj2); - await new EvaluateTestsClassWithProperties(0).GenericInstanceMethodAsync(400, 123, "just a test", obj2); - await new EvaluateTestsClassWithProperties(0).EvaluateShadowAsync(new DateTime(2020, 3, 4, 5, 6, 7), obj.NewInstance); - } - - public void EvaluateShadow(DateTime dateTime, EvaluateTestsClassWithProperties me) - { - string a = "hello"; - Console.WriteLine($"Evaluate - break here"); - SomeMethod(dateTime, me); - } - - public async Task EvaluateShadowAsync(DateTime dateTime, EvaluateTestsClassWithProperties me) - { - string a = "hello"; - Console.WriteLine($"EvaluateShadowAsync - break here"); - await Task.CompletedTask; - } - - public void SomeMethod(DateTime me, EvaluateTestsClassWithProperties dateTime) - { - Console.WriteLine($"break here"); - - var DTProp = "hello"; - Console.WriteLine($"dtProp: {DTProp}"); - } - - public async Task InstanceMethodAsync(int g, int h, string valString, EvaluateTestsClassWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - await Task.CompletedTask; - } - - public void InstanceMethod(int g, int h, string valString, EvaluateTestsClassWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - } - - public void GenericInstanceMethod(int g, int h, string valString, EvaluateTestsClassWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - T t = default(T); - } - - public async Task GenericInstanceMethodAsync(int g, int h, string valString, EvaluateTestsClassWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - T t = default(T); - return await Task.FromResult(default(T)); - } - } - - public struct EvaluateTestsStructWithProperties - { - public int a; - public int b; - public int c { get; set; } - - public DateTime dateTime; - public DateTime DTProp => dateTime.AddMinutes(10); - public int IntProp => a + 5; - public string SetOnlyProp { set { a = value.Length; } } - public EvaluateTestsClassWithProperties NullIfAIsNotZero => a != 1908712 ? null : new EvaluateTestsClassWithProperties(0); - public EvaluateTestsStructWithProperties NewInstance => new EvaluateTestsStructWithProperties(3); - - public EvaluateTestsStructWithProperties(int bias) - { - a = 4; - b = 0; - c = 0; - dateTime = new DateTime(2010, 9, 8, 7, 6, 5 + bias); - } - - public static async Task run() - { - var obj = new EvaluateTestsStructWithProperties(0); - var obj2 = new EvaluateTestsStructWithProperties(0); - obj.InstanceMethod(400, 123, "just a test", obj2); - new EvaluateTestsStructWithProperties(0).GenericInstanceMethod(400, 123, "just a test", obj2); - new EvaluateTestsStructWithProperties(0).EvaluateShadow(new DateTime(2020, 3, 4, 5, 6, 7), obj.NewInstance); - - await new EvaluateTestsStructWithProperties(0).InstanceMethodAsync(400, 123, "just a test", obj2); - await new EvaluateTestsStructWithProperties(0).GenericInstanceMethodAsync(400, 123, "just a test", obj2); - await new EvaluateTestsStructWithProperties(0).EvaluateShadowAsync(new DateTime(2020, 3, 4, 5, 6, 7), obj.NewInstance); - } - - public void EvaluateShadow(DateTime dateTime, EvaluateTestsStructWithProperties me) - { - string a = "hello"; - Console.WriteLine($"Evaluate - break here"); - SomeMethod(dateTime, me); - } - - public async Task EvaluateShadowAsync(DateTime dateTime, EvaluateTestsStructWithProperties me) - { - string a = "hello"; - Console.WriteLine($"EvaluateShadowAsync - break here"); - await Task.CompletedTask; - } - - public void SomeMethod(DateTime me, EvaluateTestsStructWithProperties dateTime) - { - Console.WriteLine($"break here"); - - var DTProp = "hello"; - Console.WriteLine($"dtProp: {DTProp}"); - } - - public async Task InstanceMethodAsync(int g, int h, string valString, EvaluateTestsStructWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - await Task.CompletedTask; - } - - public void InstanceMethod(int g, int h, string valString, EvaluateTestsStructWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - } - - public void GenericInstanceMethod(int g, int h, string valString, EvaluateTestsStructWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - T t = default(T); - } - - public async Task GenericInstanceMethodAsync(int g, int h, string valString, EvaluateTestsStructWithProperties me) - { - int d = g + 1; - int e = g + 2; - int f = g + 3; - var local_dt = new DateTime(2025, 3, 5, 7, 9, 11); - a = 1; - b = 2; - c = 3; - dateTime = new DateTime(2020, 1, 2, 3, 4, 5); - a = a + 1; - b = b + 1; - c = c + 1; - T t = default(T); - return await Task.FromResult(default(T)); - } - } - public class EvaluateMethodTestsClass - { - public class ParmToTest - { - public int a; - public int b; - public ParmToTest() - { - a = 10; - b = 10; - } - public string MyMethod() - { - return "methodOK"; - } - } - public class TestEvaluate - { - public int a; - public int b; - public int c; - public string str = "str_const_"; - public bool t = true; - public bool f = false; - public ParmToTest objToTest; - public ParmToTest ParmToTestObj => objToTest; - public ParmToTest ParmToTestObjNull => null; - public ParmToTest ParmToTestObjException => throw new Exception("error2"); - public void run(int g, int h, string a, string valString, int this_a) - { - objToTest = new ParmToTest(); - int d = g + 1; - int e = g + 2; - int f = g + 3; - int i = d + e + f; - this.a = 1; - b = 2; - c = 3; - this.a = this.a + 1; - b = b + 1; - c = c + 1; - } - - public int CallMethod() - { - return a; - } - - public char CallMethodReturningChar() - { - return 'A'; - } - - public int CallMethodWithParm(int parm) - { - return a + parm; - } - - public void CallMethodChangeValue() - { - a = a + 10; - } - - public int CallMethodWithMultipleParms(int parm, int parm2) - { - return a + parm + parm2; - } - - public string CallMethodWithParmString(string parm) - { - return str + parm; - } - - public string CallMethodWithParmString_\u03BB(string parm) - { - return "\u03BB_" + parm; - } - - public string CallMethodWithParmBool(bool parm) - { - if (parm) - return "TRUE"; - return "FALSE"; - } - - public int CallMethodWithObj(ParmToTest parm) - { - if (parm == null) - return -1; - return parm.a; - } - - - public string CallMethodWithChar(char parm) - { - return str + parm; - } - } - - public static void EvaluateMethods() - { - TestEvaluate f = new TestEvaluate(); - f.run(100, 200, "9000", "test", 45); - DebuggerTestsV2.EvaluateStaticFieldsInStaticClass.Run(); - DebuggerTests.EvaluateStaticFieldsInStaticClass.Run(); - DebuggerTests.EvaluateStaticFieldsInInstanceClass.RunStatic(); - var instanceWithStaticFields = new EvaluateStaticFieldsInInstanceClass(); - instanceWithStaticFields.Run(); - } - - public static async Task EvaluateMethodsAsync() - { - await DebuggerTests.EvaluateStaticFieldsInStaticClass.RunAsync(); - await DebuggerTests.EvaluateStaticFieldsInInstanceClass.RunStaticAsync(); - var instanceWithStaticFields = new EvaluateStaticFieldsInInstanceClass(); - await instanceWithStaticFields.RunAsync(); - } - } - - public static class EvaluateStaticFieldsInStaticClass - { - public static int StaticField = 10; - public static string StaticProperty => "StaticProperty1"; - public static string StaticPropertyWithError => throw new Exception("not implemented 1"); - - public static void Run() - { - bool stop = true; - } - - public async static Task RunAsync() - { - await Task.FromResult(0); - } - - public static class NestedClass1 - { - public static class NestedClass2 - { - public static class NestedClass3 - { - public static int StaticField = 3; - public static string StaticProperty => "StaticProperty3"; - public static string StaticPropertyWithError => throw new Exception("not implemented 3"); - } - } - } - } - - public class EvaluateStaticFieldsInInstanceClass - { - public static int StaticField = 70; - public static string StaticProperty => "StaticProperty7"; - public static string StaticPropertyWithError => throw new Exception("not implemented 7"); - - public void Run() - { - bool stop = true; - } - - public async Task RunAsync() - { - await Task.FromResult(0); - } - - public static void RunStatic() - { - bool stop = true; - } - - public static async Task RunStaticAsync() - { - await Task.FromResult(0); - } - - private int HelperMethod() - { - return 5; - } - - public async void run() - { - var makeAwaitable = await Task.Run(() => HelperMethod()); - } - } - - public class EvaluateLocalsWithIndexingTests - { - public record Indexer(int index); - - public class CommonCollections - { - public List numList = new List { 1, 2 }; - public List textList = new List { "1", "2" }; - public int[] numArray = new int[] { 1, 2, 0 }; - public string[] textArray = new string[] { "1", "2" }; - public int[][] numArrayOfArrays; - public List> numListOfLists; - public string[][] textArrayOfArrays; - public List> textListOfLists; - public Dictionary indexedByStr = new Dictionary() { { "1", true }, { "111", false }, { "true", true} }; - public Dictionary indexedByChar = new Dictionary() { { 'i', "I" }, { '5', "5" } }; - public Dictionary indexedByBool = new Dictionary() { { true, "TRUE" }, { false, "FALSE" } }; - public int idx0 = 0; - public int idx1 = 1; - - public CommonCollections() - { - numArrayOfArrays = new int[][] { numArray, numArray }; - numListOfLists = new List> { numList, numList }; - textArrayOfArrays = new string[][] { textArray, textArray }; - textListOfLists = new List> { textList, textList }; - } - } - - public class ClassWithIndexers - { - public string this[char keyChar] => "res_" + keyChar; - public string this[bool keyBool] => keyBool.ToString(); - public bool this[string keyStr] => keyStr.Length > 3; - public int this[double keyDouble] => (int)keyDouble; - public int this[float keyFloat] => (int)keyFloat; - public int this[decimal keyDecimal] => (int)keyDecimal; - public int this[Indexer indexer] => indexer.index; - public char this[char[] arr] => arr.Length == 0 ? '0' : arr[0]; - - public double this[int key1, double key2] => key1 + key2; - public string this[char key1, string key2, string key3] => $"{key1}-{key2}-{key3}"; - - public InlineArray.Arr1 inlineArr; - } - - public struct StructWithIndexers - { - public string this[char keyChar] => "res_" + keyChar; - public string this[bool keyBool] => keyBool.ToString(); - public bool this[string keyStr] => keyStr.Length > 3; - public int this[double keyDouble] => (int)keyDouble; - public int this[float keyFloat] => (int)keyFloat; - public int this[decimal keyDecimal] => (int)keyDecimal; - public int this[Indexer indexer] => indexer.index; - public char this[char[] arr] => arr.Length == 0 ? '0' : arr[0]; - - public double this[int key1, double key2] => key1 + key2; - public string this[char key1, string key2, string key3] => $"{key1}-{key2}-{key3}"; - - public InlineArray.Arr1 inlineArr; - } - - public static void EvaluateLocals() - { - int i = 0; - int j = 1; - ClassWithIndexers c = new(); - StructWithIndexers s = new(); - CommonCollections cc = new(); - string longString = "longString"; - string shortString = "9"; - char aChar = '9'; - bool aBool = true; - float aFloat = 1.23f; - double aDouble = 2.34; - decimal aDecimal = 3.34m; - Indexer objIdx = new(index: 123); - char[] arr = new char[] { 't', 'e', 's', 't' }; - } - } - - public class EvaluateLocalsWithMultidimensionalIndexingTests - { - public class TestEvaluate - { - public int[,] numArray2D; - public string[,] textArray2D; - public int[,,] numArray3D; - public int idx0; - public int idx1; - - public void run() - { - numArray2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; - textArray2D = new string[3, 2] { { "one", "two" }, { "three", "four" }, - { "five", "six" } }; - numArray3D = new int[,,] { { { 1, 2, 3 }, { 4, 5, 6 } }, - { { 7, 8, 9 }, { 10, 11, 12 } } }; - idx0 = 0; - idx1 = 1; - } - } - - public static void EvaluateLocals() - { - int i = 0; - int j = 1; - TestEvaluate f = new TestEvaluate(); - f.run(); - } - } - - public struct SampleStructure - { - public SampleStructure() { } - - public int Id = 100; - - internal bool IsStruct = true; - } - - public enum SampleEnum - { - yes = 0, - no = 1 - } - - public class SampleClass - { - public int ClassId = 200; - public List Items = new List { "should not be expanded" }; - } - - public static class EvaluateBrowsableClass - { - public class TestEvaluateFieldsNone - { - public List list = new List() { 1, 2 }; - public int[] array = new int[] { 11, 22 }; - public string text = "text"; - public bool[] nullNone = null; - public SampleEnum valueTypeEnum = new(); - public SampleStructure sampleStruct = new(); - public SampleClass sampleClass = new(); - } - - public class TestEvaluatePropertiesNone - { - public List list { get; set; } - public int[] array { get; set; } - public string text { get; set; } - public bool[] nullNone { get; set; } - public SampleEnum valueTypeEnum { get; set; } - public SampleStructure sampleStruct { get; set; } - public SampleClass sampleClass { get; set; } - - public TestEvaluatePropertiesNone() - { - list = new List() { 1, 2 }; - array = new int[] { 11, 22 }; - text = "text"; - nullNone = null; - valueTypeEnum = new(); - sampleStruct = new(); - sampleClass = new(); - } - } - - public class TestEvaluateFieldsNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public List listNever = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public int[] arrayNever = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public string textNever = "textNever"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public bool[] nullNever = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleEnum valueTypeEnumNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleStructure sampleStructNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleClass sampleClassNever = new(); - } - - public class TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public List listNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public int[] arrayNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public string textNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public bool[] nullNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleEnum valueTypeEnumNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleStructure sampleStructNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleClass sampleClassNever { get; set; } - - public TestEvaluatePropertiesNever() - { - listNever = new List() { 1, 2 }; - arrayNever = new int[] { 11, 22 }; - textNever = "textNever"; - nullNever = null; - valueTypeEnumNever = new(); - sampleStructNever = new(); - sampleClassNever = new(); - } - } - - public class TestEvaluateFieldsCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public List listCollapsed = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public int[] arrayCollapsed = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public string textCollapsed = "textCollapsed"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public bool[] nullCollapsed = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleEnum valueTypeEnumCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleStructure sampleStructCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleClass sampleClassCollapsed = new(); - } - - public class TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public List listCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public int[] arrayCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public string textCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public bool[] nullCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleEnum valueTypeEnumCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleStructure sampleStructCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleClass sampleClassCollapsed { get; set; } - - public TestEvaluatePropertiesCollapsed() - { - listCollapsed = new List() { 1, 2 }; - arrayCollapsed = new int[] { 11, 22 }; - textCollapsed = "textCollapsed"; - nullCollapsed = null; - valueTypeEnumCollapsed = new(); - sampleStructCollapsed = new(); - sampleClassCollapsed = new(); - } - } - - public class TestEvaluateFieldsRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public List listRootHidden = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public int[] arrayRootHidden = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public string textRootHidden = "textRootHidden"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public bool[] nullRootHidden = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleEnum valueTypeEnumRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleStructure sampleStructRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleClass sampleClassRootHidden = new(); - } - - public class TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public List listRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public int[] arrayRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public string textRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public bool[] nullRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleEnum valueTypeEnumRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleStructure sampleStructRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleClass sampleClassRootHidden { get; set; } - - public TestEvaluatePropertiesRootHidden() - { - listRootHidden = new List() { 1, 2 }; - arrayRootHidden = new int[] { 11, 22 }; - textRootHidden = "textRootHidden"; - nullRootHidden = null; - valueTypeEnumRootHidden = new(); - sampleStructRootHidden = new(); - sampleClassRootHidden = new(); - } - } - - public static void Evaluate() - { - var testFieldsNone = new TestEvaluateFieldsNone(); - var testFieldsNever = new TestEvaluateFieldsNever(); - var testFieldsCollapsed = new TestEvaluateFieldsCollapsed(); - var testFieldsRootHidden = new TestEvaluateFieldsRootHidden(); - - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class EvaluateBrowsableStruct - { - public struct TestEvaluateFieldsNone - { - public TestEvaluateFieldsNone() {} - public List list = new List() { 1, 2 }; - public int[] array = new int[] { 11, 22 }; - public string text = "text"; - public bool[] nullNone = null; - public SampleEnum valueTypeEnum = new(); - public SampleStructure sampleStruct = new(); - public SampleClass sampleClass = new(); - } - - public struct TestEvaluatePropertiesNone - { - public List list { get; set; } - public int[] array { get; set; } - public string text { get; set; } - public bool[] nullNone { get; set; } - public SampleEnum valueTypeEnum { get; set; } - public SampleStructure sampleStruct { get; set; } - public SampleClass sampleClass { get; set; } - - public TestEvaluatePropertiesNone() - { - list = new List() { 1, 2 }; - array = new int[] { 11, 22 }; - text = "text"; - nullNone = null; - valueTypeEnum = new(); - sampleStruct = new(); - sampleClass = new(); - } - } - - public struct TestEvaluateFieldsNever - { - public TestEvaluateFieldsNever() {} - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public List listNever = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public int[] arrayNever = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public string textNever = "textNever"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public bool[] nullNever = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleEnum valueTypeEnumNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleStructure sampleStructNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleClass sampleClassNever = new(); - } - - public struct TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public List listNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public int[] arrayNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public string textNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public bool[] nullNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleEnum valueTypeEnumNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleStructure sampleStructNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleClass sampleClassNever { get; set; } - - public TestEvaluatePropertiesNever() - { - listNever = new List() { 1, 2 }; - arrayNever = new int[] { 11, 22 }; - textNever = "textNever"; - nullNever = null; - valueTypeEnumNever = new(); - sampleStructNever = new(); - sampleClassNever = new(); - } - } - - public struct TestEvaluateFieldsCollapsed - { - public TestEvaluateFieldsCollapsed() {} - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public List listCollapsed = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public int[] arrayCollapsed = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public string textCollapsed = "textCollapsed"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public bool[] nullCollapsed = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleEnum valueTypeEnumCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleStructure sampleStructCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleClass sampleClassCollapsed = new(); - } - - public struct TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public List listCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public int[] arrayCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public string textCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public bool[] nullCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleEnum valueTypeEnumCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleStructure sampleStructCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleClass sampleClassCollapsed { get; set; } - - public TestEvaluatePropertiesCollapsed() - { - listCollapsed = new List() { 1, 2 }; - arrayCollapsed = new int[] { 11, 22 }; - textCollapsed = "textCollapsed"; - nullCollapsed = null; - valueTypeEnumCollapsed = new(); - sampleStructCollapsed = new(); - sampleClassCollapsed = new(); - } - } - - public struct TestEvaluateFieldsRootHidden - { - public TestEvaluateFieldsRootHidden() {} - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public List listRootHidden = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public int[] arrayRootHidden = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public string textRootHidden = "textRootHidden"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public bool[] nullRootHidden = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleEnum valueTypeEnumRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleStructure sampleStructRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleClass sampleClassRootHidden = new(); - } - - public struct TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public List listRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public int[] arrayRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public string textRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public bool[] nullRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleEnum valueTypeEnumRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleStructure sampleStructRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleClass sampleClassRootHidden { get; set; } - - public TestEvaluatePropertiesRootHidden() - { - listRootHidden = new List() { 1, 2 }; - arrayRootHidden = new int[] { 11, 22 }; - textRootHidden = "textRootHidden"; - nullRootHidden = null; - valueTypeEnumRootHidden = new(); - sampleStructRootHidden = new(); - sampleClassRootHidden = new(); - } - } - - public static void Evaluate() - { - var testFieldsNone = new TestEvaluateFieldsNone(); - var testFieldsNever = new TestEvaluateFieldsNever(); - var testFieldsCollapsed = new TestEvaluateFieldsCollapsed(); - var testFieldsRootHidden = new TestEvaluateFieldsRootHidden(); - - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class EvaluateBrowsableClassStatic - { - public class TestEvaluateFieldsNone - { - public static List list = new List() { 1, 2 }; - public static int[] array = new int[] { 11, 22 }; - public static string text = "text"; - - public static bool[] nullNone = null; - public static SampleEnum valueTypeEnum = new(); - public static SampleStructure sampleStruct = new(); - public static SampleClass sampleClass = new(); - } - - public class TestEvaluatePropertiesNone - { - public static List list { get; set; } - public static int[] array { get; set; } - public static string text { get; set; } - public static bool[] nullNone { get; set; } - public static SampleEnum valueTypeEnum { get; set; } - public static SampleStructure sampleStruct { get; set; } - public static SampleClass sampleClass { get; set; } - - public TestEvaluatePropertiesNone() - { - list = new List() { 1, 2 }; - array = new int[] { 11, 22 }; - text = "text"; - nullNone = null; - valueTypeEnum = new(); - sampleStruct = new(); - sampleClass = new(); - } - } - - public class TestEvaluateFieldsNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static List listNever = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static int[] arrayNever = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static string textNever = "textNever"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static bool[] nullNever = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleEnum valueTypeEnumNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleStructure sampleStructNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleClass sampleClassNever = new(); - } - - public class TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static List listNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static int[] arrayNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static string textNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static bool[] nullNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleEnum valueTypeEnumNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleStructure sampleStructNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleClass sampleClassNever { get; set; } - - public TestEvaluatePropertiesNever() - { - listNever = new List() { 1, 2 }; - arrayNever = new int[] { 11, 22 }; - textNever = "textNever"; - nullNever = null; - valueTypeEnumNever = new(); - sampleStructNever = new(); - sampleClassNever = new(); - } - } - - public class TestEvaluateFieldsCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static List listCollapsed = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static int[] arrayCollapsed = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static string textCollapsed = "textCollapsed"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static bool[] nullCollapsed = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleEnum valueTypeEnumCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleStructure sampleStructCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleClass sampleClassCollapsed = new(); - } - - public class TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static List listCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static int[] arrayCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static string textCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static bool[] nullCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleEnum valueTypeEnumCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleStructure sampleStructCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleClass sampleClassCollapsed { get; set; } - - public TestEvaluatePropertiesCollapsed() - { - listCollapsed = new List() { 1, 2 }; - arrayCollapsed = new int[] { 11, 22 }; - textCollapsed = "textCollapsed"; - nullCollapsed = null; - valueTypeEnumCollapsed = new(); - sampleStructCollapsed = new(); - sampleClassCollapsed = new(); - } - } - - public class TestEvaluateFieldsRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static List listRootHidden = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static int[] arrayRootHidden = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static string textRootHidden = "textRootHidden"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static bool[] nullRootHidden = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleEnum valueTypeEnumRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleStructure sampleStructRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleClass sampleClassRootHidden = new(); - } - - public class TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static List listRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static int[] arrayRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static string textRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static bool[] nullRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleEnum valueTypeEnumRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleStructure sampleStructRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleClass sampleClassRootHidden { get; set; } - - public TestEvaluatePropertiesRootHidden() - { - listRootHidden = new List() { 1, 2 }; - arrayRootHidden = new int[] { 11, 22 }; - textRootHidden = "textRootHidden"; - nullRootHidden = null; - valueTypeEnumRootHidden = new(); - sampleStructRootHidden = new(); - sampleClassRootHidden = new(); - } - } - - public static void Evaluate() - { - var testFieldsNone = new TestEvaluateFieldsNone(); - var testFieldsNever = new TestEvaluateFieldsNever(); - var testFieldsCollapsed = new TestEvaluateFieldsCollapsed(); - var testFieldsRootHidden = new TestEvaluateFieldsRootHidden(); - - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class EvaluateBrowsableStructStatic - { - public struct TestEvaluateFieldsNone - { - - public static List list = new List() { 1, 2 }; - public static int[] array = new int[] { 11, 22 }; - public static string text = "text"; - - public static bool[] nullNone = null; - public static SampleEnum valueTypeEnum = new(); - public static SampleStructure sampleStruct = new(); - public static SampleClass sampleClass = new(); - - public TestEvaluateFieldsNone() { } - } - - public struct TestEvaluatePropertiesNone - { - public static List list { get; set; } - public static int[] array { get; set; } - public static string text { get; set; } - public static bool[] nullNone { get; set; } - public static SampleEnum valueTypeEnum { get; set; } - public static SampleStructure sampleStruct { get; set; } - public static SampleClass sampleClass { get; set; } - - public TestEvaluatePropertiesNone() - { - list = new List() { 1, 2 }; - array = new int[] { 11, 22 }; - text = "text"; - nullNone = null; - valueTypeEnum = new(); - sampleStruct = new(); - sampleClass = new(); - } - } - - public struct TestEvaluateFieldsNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static List listNever = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static int[] arrayNever = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static string textNever = "textNever"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static bool[] nullNever = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleEnum valueTypeEnumNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleStructure sampleStructNever = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleClass sampleClassNever = new(); - public TestEvaluateFieldsNever() { } - } - - public struct TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static List listNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static int[] arrayNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static string textNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static bool[] nullNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleEnum valueTypeEnumNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleStructure sampleStructNever { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleClass sampleClassNever { get; set; } - - public TestEvaluatePropertiesNever() - { - listNever = new List() { 1, 2 }; - arrayNever = new int[] { 11, 22 }; - textNever = "textNever"; - nullNever = null; - valueTypeEnumNever = new(); - sampleStructNever = new(); - sampleClassNever = new(); - } - } - - public struct TestEvaluateFieldsCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static List listCollapsed = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static int[] arrayCollapsed = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static string textCollapsed = "textCollapsed"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static bool[] nullCollapsed = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleEnum valueTypeEnumCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleStructure sampleStructCollapsed = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleClass sampleClassCollapsed = new(); - public TestEvaluateFieldsCollapsed() { } - } - - public struct TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static List listCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static int[] arrayCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static string textCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static bool[] nullCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleEnum valueTypeEnumCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleStructure sampleStructCollapsed { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleClass sampleClassCollapsed { get; set; } - - public TestEvaluatePropertiesCollapsed() - { - listCollapsed = new List() { 1, 2 }; - arrayCollapsed = new int[] { 11, 22 }; - textCollapsed = "textCollapsed"; - nullCollapsed = null; - valueTypeEnumCollapsed = new(); - sampleStructCollapsed = new(); - sampleClassCollapsed = new(); - } - } - - public struct TestEvaluateFieldsRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static List listRootHidden = new List() { 1, 2 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static int[] arrayRootHidden = new int[] { 11, 22 }; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static string textRootHidden = "textRootHidden"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static bool[] nullRootHidden = null; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleEnum valueTypeEnumRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleStructure sampleStructRootHidden = new(); - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleClass sampleClassRootHidden = new(); - - public TestEvaluateFieldsRootHidden() { } - } - - public struct TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static List listRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static int[] arrayRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static string textRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static bool[] nullRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleEnum valueTypeEnumRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleStructure sampleStructRootHidden { get; set; } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleClass sampleClassRootHidden { get; set; } - - public TestEvaluatePropertiesRootHidden() - { - listRootHidden = new List() { 1, 2 }; - arrayRootHidden = new int[] { 11, 22 }; - textRootHidden = "textRootHidden"; - nullRootHidden = null; - valueTypeEnumRootHidden = new(); - sampleStructRootHidden = new(); - sampleClassRootHidden = new(); - } - } - - public static void Evaluate() - { - var testFieldsNone = new TestEvaluateFieldsNone(); - var testFieldsNever = new TestEvaluateFieldsNever(); - var testFieldsCollapsed = new TestEvaluateFieldsCollapsed(); - var testFieldsRootHidden = new TestEvaluateFieldsRootHidden(); - - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class EvaluateBrowsableNonAutoPropertiesClass - { - public class TestEvaluatePropertiesNone - { - public List list { get { return new List() { 1, 2 }; } } - public int[] array { get { return new int[] { 11, 22 }; } } - public string text { get { return "text"; } } - public bool[] nullNone { get { return null; } } - public SampleEnum valueTypeEnum { get { return new(); } } - public SampleStructure sampleStruct { get { return new(); } } - public SampleClass sampleClass { get { return new(); } } - } - - public class TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public List listNever { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public int[] arrayNever { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public string textNever { get { return "textNever"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public bool[] nullNever { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleEnum valueTypeEnumNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleStructure sampleStructNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleClass sampleClassNever { get { return new(); } } - } - - public class TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public List listCollapsed { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public int[] arrayCollapsed { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public string textCollapsed { get { return "textCollapsed"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public bool[] nullCollapsed { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleEnum valueTypeEnumCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleStructure sampleStructCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleClass sampleClassCollapsed { get { return new(); } } - } - - public class TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public List listRootHidden { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public int[] arrayRootHidden { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public string textRootHidden { get { return "textRootHidden"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public bool[] nullRootHidden { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleEnum valueTypeEnumRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleStructure sampleStructRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleClass sampleClassRootHidden { get { return new(); } } - } - - public static void Evaluate() - { - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class EvaluateBrowsableNonAutoPropertiesStruct - { - public struct TestEvaluatePropertiesNone - { - public List list { get { return new List() { 1, 2 }; } } - public int[] array { get { return new int[] { 11, 22 }; } } - public string text { get { return "text"; } } - public bool[] nullNone { get { return null; } } - public SampleEnum valueTypeEnum { get { return new(); } } - public SampleStructure sampleStruct { get { return new(); } } - public SampleClass sampleClass { get { return new(); } } - } - - public struct TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public List listNever { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public int[] arrayNever { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public string textNever { get { return "textNever"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public bool[] nullNever { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleEnum valueTypeEnumNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleStructure sampleStructNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public SampleClass sampleClassNever { get { return new(); } } - } - - public struct TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public List listCollapsed { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public int[] arrayCollapsed { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public string textCollapsed { get { return "textCollapsed"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public bool[] nullCollapsed { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleEnum valueTypeEnumCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleStructure sampleStructCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleClass sampleClassCollapsed { get { return new(); } } - } - - public struct TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public List listRootHidden { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public int[] arrayRootHidden { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public string textRootHidden { get { return "textRootHidden"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public bool[] nullRootHidden { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleEnum valueTypeEnumRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleStructure sampleStructRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public SampleClass sampleClassRootHidden { get { return new(); } } - } - - public static void Evaluate() - { - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class EvaluateBrowsableNonAutoPropertiesClassStatic - { - public class TestEvaluatePropertiesNone - { - public static List list { get { return new List() { 1, 2 }; } } - public static int[] array { get { return new int[] { 11, 22 }; } } - public static string text { get { return "text"; } } - public static bool[] nullNone { get { return null; } } - public static SampleEnum valueTypeEnum { get { return new(); } } - public static SampleStructure sampleStruct { get { return new(); } } - public static SampleClass sampleClass { get { return new(); } } - } - - public class TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static List listNever { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static int[] arrayNever { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static string textNever { get { return "textNever"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static bool[] nullNever { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleEnum valueTypeEnumNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleStructure sampleStructNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleClass sampleClassNever { get { return new(); } } - } - - public class TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static List listCollapsed { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static int[] arrayCollapsed { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static string textCollapsed { get { return "textCollapsed"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static bool[] nullCollapsed { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleEnum valueTypeEnumCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleStructure sampleStructCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleClass sampleClassCollapsed { get { return new(); } } - } - - public class TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static List listRootHidden { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static int[] arrayRootHidden { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static string textRootHidden { get { return "textRootHidden"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static bool[] nullRootHidden { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleEnum valueTypeEnumRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleStructure sampleStructRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleClass sampleClassRootHidden { get { return new(); } } - } - - public static void Evaluate() - { - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class EvaluateBrowsableNonAutoPropertiesStructStatic - { - public struct TestEvaluatePropertiesNone - { - public static List list { get { return new List() { 1, 2 }; } } - public static int[] array { get { return new int[] { 11, 22 }; } } - public static string text { get { return "text"; } } - public static bool[] nullNone { get { return null; } } - public static SampleEnum valueTypeEnum { get { return new(); } } - public static SampleStructure sampleStruct { get { return new(); } } - public static SampleClass sampleClass { get { return new(); } } - } - - public struct TestEvaluatePropertiesNever - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static List listNever { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static int[] arrayNever { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static string textNever { get { return "textNever"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static bool[] nullNever { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleEnum valueTypeEnumNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleStructure sampleStructNever { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - public static SampleClass sampleClassNever { get { return new(); } } - } - - public struct TestEvaluatePropertiesCollapsed - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static List listCollapsed { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static int[] arrayCollapsed { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static string textCollapsed { get { return "textCollapsed"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static bool[] nullCollapsed { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleEnum valueTypeEnumCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public SampleStructure sampleStructCollapsed { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Collapsed)] - public static SampleClass sampleClassCollapsed { get { return new(); } } - } - - public struct TestEvaluatePropertiesRootHidden - { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static List listRootHidden { get { return new List() { 1, 2 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static int[] arrayRootHidden { get { return new int[] { 11, 22 }; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static string textRootHidden { get { return "textRootHidden"; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static bool[] nullRootHidden { get { return null; } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleEnum valueTypeEnumRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleStructure sampleStructRootHidden { get { return new(); } } - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)] - public static SampleClass sampleClassRootHidden { get { return new(); } } - } - - public static void Evaluate() - { - var testPropertiesNone = new TestEvaluatePropertiesNone(); - var testPropertiesNever = new TestEvaluatePropertiesNever(); - var testPropertiesCollapsed = new TestEvaluatePropertiesCollapsed(); - var testPropertiesRootHidden = new TestEvaluatePropertiesRootHidden(); - } - } - - public static class StructureGetters - { - public struct Point - { - public int Id { get { return 123; } } - } - - public static void Evaluate() - { - var s = new Point(); - } - } - - public static class FastCheck - { - public class InstanceClass - { - public int number = 123; - } - - public class MemberClass - { - public int Method(InstanceClass ic) => ic.number; - public int Method(int num) => num; - } - - public static void run() - { - int number = -123; - InstanceClass ic = new(); - MemberClass mc = new(); - EvaluateStaticFieldsInInstanceClass instance = new(); - PrimitiveTypeMethods.TestClass instance2 = new(); - } - } - - public static class DefaultParamMethods - { - public class TestClass - { - public IEnumerable listToLinq = System.Linq.Enumerable.Range(1, 11); - - public bool GetBool(bool param = true) => param; - public char GetChar(char param = 'T') => param; - public char GetUnicodeChar(char param = '\u0105') => param; - public byte GetByte(byte param = 1) => param; - public sbyte GetSByte(sbyte param = 1) => param; - public short GetInt16(short param = 1) => param; - public ushort GetUInt16(ushort param = 1) => param; - public int GetInt32(int param = 1) => param; - public uint GetUInt32(uint param = 1) => param; - public long GetInt64(long param = 1) => param; - public ulong GetUInt64(ulong param = 1) => param; - public float GetSingle(float param = 1.23f) => param; - public double GetDouble(double param = 1.23) => param; - public string GetString(string param = "1.23") => param; - public string GetUnicodeString(string param = "\u017C\u00F3\u0142\u0107") => param; - -#nullable enable - public bool? GetBoolNullable(bool? param = true) => param; - public char? GetCharNullable(char? param = 'T') => param; - public byte? GetByteNullable(byte? param = 1) => param; - public sbyte? GetSByteNullable(sbyte? param = 1) => param; - public short? GetInt16Nullable(short? param = 1) => param; - public ushort? GetUInt16Nullable(ushort? param = 1) => param; - public int? GetInt32Nullable(int? param = 1) => param; - public uint? GetUInt32Nullable(uint? param = 1) => param; - public long? GetInt64Nullable(long? param = 1) => param; - public ulong? GetUInt64Nullable(ulong? param = 1) => param; - public float? GetSingleNullable(float? param = 1.23f) => param; - public double? GetDoubleNullable(double? param = 1.23) => param; - public string? GetStringNullable(string? param = "1.23") => param; -#nullable disable - - public bool GetNull(object param = null) => param == null ? true : false; - public int SumDefaultAndRequiredParam(int requiredParam, int optionalParam = 3) => requiredParam + optionalParam; - public int SumDefaultNegativeAndRequiredParamInts(int requiredParam, int optionalParam = -3) => requiredParam + optionalParam; - public long SumDefaultNegativeAndRequiredParamLongInts(long requiredParam, long optionalParam = -123) => requiredParam + optionalParam; - public float SumDefaultNegativeAndRequiredParamFloats(float requiredParam, float optionalParam = -3.3f) => requiredParam + optionalParam; - public double SumDefaultNegativeAndRequiredParamDoubles(double requiredParam, double optionalParam = -3.2) => requiredParam + optionalParam; - public short SumDefaultNegativeAndRequiredParamShortInts(short requiredParam, short optionalParam = -123) => (short)(requiredParam + optionalParam); - public short GetDefaultNegativeShortInt(short optionalParam = -123) => optionalParam; - public string GetDefaultAndRequiredParamMixedTypes(string requiredParam, int optionalParamFirst = -1, bool optionalParamSecond = false) => $"{requiredParam}; {optionalParamFirst}; {optionalParamSecond}"; - } - - public static void Evaluate() - { - var test = new TestClass(); - } - } - - public static class PrimitiveTypeMethods - { - public class TestClass - { - public int propInt = 12; - public uint propUint = 12; - public long propLong = 12; - public ulong propUlong = 12; - public float propFloat = 1.2345678f; - public double propDouble = 1.2345678910111213; - public bool propBool = true; - public char propChar = 'X'; - public string propString = "s_t_r"; - } - - public static void Evaluate() - { - var test = new TestClass(); - int localInt = 2; - uint localUint = 2; - long localLong = 2; - ulong localUlong = 2; - float localFloat = 0.2345678f; - double localDouble = 0.2345678910111213; - bool localBool = false; - char localChar = 'Y'; - string localString = "S*T*R"; - } - } - - public static class EvaluateNullableProperties - { - class TestClass - { - public List MemberListNull = null; - public List MemberList = new List() {1, 2}; - public TestClass Sibling { get; set; } - } - static void Evaluate() - { - #nullable enable - List? listNull = null; - #nullable disable - List list = new List() {1}; - TestClass tc = new TestClass(); - TestClass tcNull = null; - string str = "str#value"; - string str_null = null; - int x = 5; - int? x_null = null; - int? x_val = x; - } - } - - public static class TypeProperties - { - public class InstanceProperties - { - public string str = "aB.c["; - } - - public static void Run() - { - var instance = new InstanceProperties(); - var localString = "aB.c["; - } - } - - public static class EvaluateMethodsOnEnum - { - public static SampleEnum s_valueTypeEnum = SampleEnum.no; - public class MemberClass - { - public SampleEnum valueTypeEnum = SampleEnum.yes; - } - public static void run() - { - MemberClass mc = new(); - Console.WriteLine("Break here"); - } - } -} - -namespace DebuggerTestsV2 -{ - public static class EvaluateStaticFieldsInStaticClass - { - public static int StaticField = 20; - public static string StaticProperty => "StaticProperty2"; - public static string StaticPropertyWithError => throw new Exception("not implemented 2"); - - public static void Run() - { - var a = 0; - } - } -} - -public static class NestedWithSameNames -{ - public static int StaticField = 30; - public static string StaticProperty => "StaticProperty3"; - public static string StaticPropertyWithError => throw new Exception("not implemented V3"); - - public static class B - { - public static int StaticField = 60; - public static string StaticProperty => "StaticProperty6"; - public static string StaticPropertyWithError => throw new Exception("not implemented V6"); - - public static class NestedWithSameNames - { - public static class B - { - public static int NestedWithSameNames = 90; - public static int StaticField = 40; - public static string StaticProperty => "StaticProperty4"; - public static string StaticPropertyWithError => throw new Exception("not implemented V4"); - - public static void Run() - { - var a = 0; - } - } - } - public static class NestedWithDifferentName - { - public static class B - { - public static int StaticField = 70; - public static string StaticProperty => "StaticProperty7"; - public static string StaticPropertyWithError => throw new Exception("not implemented V7"); - } - } - } - - public static void Evaluate() - { - B.NestedWithSameNames.B.Run(); - } -} - - -public static class NoNamespaceClass -{ - public static void EvaluateMethods() - { - var stopHere = true; - } - - public static class NestedClass1 - { - public static class NestedClass2 - { - public static class NestedClass3 - { - public static int StaticField = 30; - public static string StaticProperty => "StaticProperty30"; - public static string StaticPropertyWithError => throw new Exception("not implemented 30"); - } - } - } -} -[System.Diagnostics.DebuggerDisplay("{MyMethod2(),nq}")] -public class TestEvaluateDontPauseOnBreakpoint -{ - public int count; - public static void run() - { - var myVar = new TestEvaluateDontPauseOnBreakpoint(); - myVar.count = 10; - myVar.MyMethod2(); - myVar.MyMethod(); - } - public string MyMethod() { - System.Diagnostics.Debugger.Break(); - return string.Format("Object {0}", count); - } - public string MyMethod2() { - return string.Format("Object {0}", count + 1); - } - public string MyMethod3() { - return MyMethod2(); - } - public string MyCount - { - get - { - return MyMethod2(); - } - } -} -public struct EvaluateStaticGetterInValueType -{ - public static int A => 5; -} - -namespace DebuggerTests -{ - public class SumObjectAndString - { - public class MyClass - { - public override string ToString() - { - return "OverriddenToString"; - } - } - public static void run() - { - DateTime dt = new DateTime(); - List myList = new(); - List listNull = null; - object o = new(); - MyClass myClass = new(); - myList.Add(1); - Console.WriteLine(myList); - Console.WriteLine(dt); - } - } - public unsafe struct EvaluateValueTypeWithFixedArray - { - private fixed int myIntArray[4]; - private fixed char myCharArray[3]; - double myDouble; - public EvaluateValueTypeWithFixedArray() - { - myDouble = 10; - myIntArray[0] = 1; - myIntArray[1] = 2; - myCharArray[2] = 'a'; - } - public int MyMethod() - { - Console.WriteLine(myDouble); - return myIntArray[0] + myIntArray[1] + (int)myDouble; - } - public static void run() - { - var myVar = new EvaluateValueTypeWithFixedArray(); - Console.WriteLine("pause here"); - myVar.MyMethod(); - } - } - - public struct EvaluateValueTypeWithObjectValueType - { - private object myObject; - double myDouble; - public EvaluateValueTypeWithObjectValueType() - { - myObject = new int(); - myDouble = 10; - } - public int MyMethod() - { - Console.WriteLine(myDouble); - return (int)myObject + (int)myDouble; - } - public static void run() - { - var myVar = new EvaluateValueTypeWithObjectValueType(); - Console.WriteLine("pause here"); - myVar.MyMethod(); - } - } - - public struct EvaluateOnValueTypeWithoutExtraSpace - { - public double X; - public double Y; - public double Z; - public EvaluateOnValueTypeWithoutExtraSpace(float InX, float InY, float InZ) - { - X = InX; Y = InY; Z = InZ; - } - public double DistSquaredXY(in EvaluateOnValueTypeWithoutExtraSpace B) // the keyword "in" here is crucial, with it the crash produced - { - double DX = X - B.X; - double DY = Y - B.Y; - return DX * DX + DY * DY; - } - public static void run() - { - EvaluateOnValueTypeWithoutExtraSpace f1 = new EvaluateOnValueTypeWithoutExtraSpace(1, 1, 1); - EvaluateOnValueTypeWithoutExtraSpace f2 = new EvaluateOnValueTypeWithoutExtraSpace(2, 2, 2); - Console.WriteLine("pause here"); - } - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-exception-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-exception-test.cs deleted file mode 100644 index ebf82dc4909200..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-exception-test.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -namespace DebuggerTests -{ - public class ExceptionTestsClass - { - public class TestCaughtException - { - public void run() - { - try - { - throw new CustomException("not implemented caught"); - } - catch - { - Console.WriteLine("caught exception"); - } - } - } - - public class TestUncaughtException - { - public void run() - { - throw new CustomException("not implemented uncaught"); - } - } - - public static void TestExceptions() - { - TestCaughtException f = new TestCaughtException(); - f.run(); - - TestUncaughtException g = new TestUncaughtException(); - g.run(); - } - - } - - public class CustomException : Exception - { - // Using this name to match with what js has. - // helps with the tests - public string message; - public CustomException(string message) - : base(message) - { - this.message = message; - } - } - - public class ExceptionTestsClassDefault - { - public class TestCaughtException - { - public void run() - { - try - { - throw new Exception("not implemented caught"); - } - catch - { - Console.WriteLine("caught exception"); - } - } - } - - public class TestUncaughtException - { - public void run() - { - throw new Exception("not implemented uncaught"); - } - } - - public static void TestExceptions() - { - TestCaughtException f = new TestCaughtException(); - f.run(); - - TestUncaughtException g = new TestUncaughtException(); - g.run(); - } - - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-get-properties-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-get-properties-test.cs deleted file mode 100644 index dc02bbdfb79cd0..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-get-properties-test.cs +++ /dev/null @@ -1,424 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Reflection; -using System.Threading.Tasks; - -namespace DebuggerTests.GetPropertiesTests -{ - - public interface IFirstName - { - string FirstName { get; } - } - - public interface ILastName - { - string LastName { get; } - } - - public interface IName : IFirstName, ILastName - { } - - public class BaseBaseClass - { - public string BaseBase_MemberForOverride { get; set; } - } - - public class BaseClass : BaseBaseClass, IName - { - private string _base_name; - private DateTime _base_dateTime => new DateTime(2134, 5, 7, 1, 9, 2); - private string _base_autoProperty { get; set; } - protected int base_num; - - public string Base_AutoStringProperty { get; set; } - public virtual DateTime DateTimeForOverride { get; set; } - public string Base_AutoStringPropertyForOverrideWithField { get; set; } - - public virtual string StringPropertyForOverrideWithAutoProperty => "base#StringPropertyForOverrideWithAutoProperty"; - public virtual string Base_GetterForOverrideWithField => "base#Base_GetterForOverrideWithField"; - public new string BaseBase_MemberForOverride => "Base#BaseBase_MemberForOverride"; - - public string this[string s] => s + "_hello"; - - public BaseClass() - { - _base_name = "private_name"; - _base_autoProperty = "private_autoproperty"; - base_num = 5; - Base_AutoStringProperty = "base#Base_AutoStringProperty"; - DateTimeForOverride = new DateTime(2250, 4, 5, 6, 7, 8); - //AutoStringPropertyForOverride = "base#AutoStringPropertyForOverride"; - } - - public string GetBaseName() => _base_name; - - public virtual string FirstName => "BaseClass#FirstName"; - public virtual string LastName => "BaseClass#LastName"; - } - - public class DerivedClass : BaseClass, ICloneable - { - // public string _base_name = "DerivedClass#_base_name"; - private string _stringField = "DerivedClass#_stringField"; - private DateTime _dateTime = new DateTime(2020, 7, 6, 5, 4, 3); - private DateTime _DTProp => new DateTime(2200, 5, 6, 7, 8, 9); - - internal bool b = true; - - public int a; - public DateTime DateTime => _DTProp.AddMinutes(10); - public string AutoStringProperty { get; set; } - public override string FirstName => "DerivedClass#FirstName"; - - // Overrides an auto-property with a getter - public override DateTime DateTimeForOverride => new DateTime(2190, 9, 7, 5, 3, 2); - public override string StringPropertyForOverrideWithAutoProperty { get; } - public new string Base_AutoStringPropertyForOverrideWithField = "DerivedClass#Base_AutoStringPropertyForOverrideWithField"; - public new string Base_GetterForOverrideWithField = "DerivedClass#Base_GetterForOverrideWithField"; - public new string BaseBase_MemberForOverride = "DerivedClass#BaseBase_MemberForOverride"; - - public int this[int i, string s] => i + 1 + s.Length; - - object ICloneable.Clone() - { - // not meant to be used! - return new DerivedClass(); - } - - public DerivedClass() - { - a = 4; - AutoStringProperty = "DerivedClass#AutoStringProperty"; - StringPropertyForOverrideWithAutoProperty = "DerivedClass#StringPropertyForOverrideWithAutoProperty"; - } - - public static void run() - { - new DerivedClass().InstanceMethod(); - new DerivedClass().InstanceMethodAsync().Wait(); - } - - public string GetStringField() => _stringField; - - public void InstanceMethod() - { - Console.WriteLine($"break here"); - } - - public async Task InstanceMethodAsync() - { - Console.WriteLine($"break here"); - await Task.CompletedTask; - } - } - - public class BaseBaseClass2 - { - // for new-hidding with a field: - public int BaseBase_FieldForHidingWithField = 5; - public int BaseBase_PropertyForHidingWithField => 10; - public int BaseBase_AutoPropertyForHidingWithField { get; set; } - - // for new-hidding with a property: - public string BaseBase_FieldForHidingWithProperty = "BaseBase#BaseBase_FieldForHidingWithProperty"; - public string BaseBase_PropertyForHidingWithProperty => "BaseBase#BaseBase_PropertyForHidingWithProperty"; - public string BaseBase_AutoPropertyForHidingWithProperty { get; set; } - - // for new-hidding with an auto-property: - public string BaseBase_FieldForHidingWithAutoProperty = "BaseBase#BaseBase_FieldForHidingWithAutoProperty"; - public string BaseBase_PropertyForHidingWithAutoProperty => "BaseBase#BaseBase_PropertyForHidingWithAutoProperty"; - public string BaseBase_AutoPropertyForHidingWithAutoProperty { get; set; } - - // for virtual->override->new-hidden (VOH), virtual->new-hidden->override (VHO) and virtual->override->override (VOO) - public virtual string BaseBase_PropertyForVOH => "BaseBase#BaseBase_PropertyForVOH"; - public virtual string BaseBase_PropertyForVHO => "BaseBase#BaseBase_PropertyForVHO"; - // public virtual string BaseBase_PropertyForVOO => "BaseBase#BaseBase_PropertyForVOO"; // FixMe: Issue #69788 - public virtual string BaseBase_AutoPropertyForVOH { get; set; } - public virtual string BaseBase_AutoPropertyForVHO { get; set; } - // public virtual string BaseBase_AutoPropertyForVOO { get; set; } // FixMe: Issue #69788 - - // -----------------static members-------------- - // for new-hidding with a field: - public static int S_BaseBase_FieldForHidingWithField = 5; - public static int S_BaseBase_PropertyForHidingWithField => 10; - public static int S_BaseBase_AutoPropertyForHidingWithField { get; set; } - - // for new-hidding with a property: - public static string S_BaseBase_FieldForHidingWithProperty = "BaseBase#BaseBase_FieldForHidingWithProperty"; - public static string S_BaseBase_PropertyForHidingWithProperty => "BaseBase#BaseBase_PropertyForHidingWithProperty"; - public static string S_BaseBase_AutoPropertyForHidingWithProperty { get; set; } - - // for new-hidding with an auto-property: - public static string S_BaseBase_FieldForHidingWithAutoProperty = "BaseBase#BaseBase_FieldForHidingWithAutoProperty"; - public static string S_BaseBase_PropertyForHidingWithAutoProperty => "BaseBase#BaseBase_PropertyForHidingWithAutoProperty"; - public static string S_BaseBase_AutoPropertyForHidingWithAutoProperty { get; set; } - - public BaseBaseClass2() - { - BaseBase_AutoPropertyForHidingWithField = 10 + S_BaseBase_FieldForHidingWithField; // = 15; suppressing non-used variable warnings - BaseBase_AutoPropertyForHidingWithProperty = "BaseBase#BaseBase_AutoPropertyForHidingWithProperty"; - BaseBase_AutoPropertyForHidingWithAutoProperty = "BaseBase#BaseBase_AutoPropertyForHidingWithAutoProperty"; - - BaseBase_AutoPropertyForVOH = "BaseBase#BaseBase_AutoPropertyForVOH"; - BaseBase_AutoPropertyForVHO = "BaseBase#BaseBase_AutoPropertyForVHO"; - // BaseBase_AutoPropertyForVOO = "BaseBase#BaseBase_AutoPropertyForVOO"; // FixMe: Issue #69788 - } - } - - public class BaseClass2 : BaseBaseClass2, IName - { - // hiding with a field: - private new int BaseBase_FieldForHidingWithField = 105; - protected new int BaseBase_PropertyForHidingWithField = 110; - public new int BaseBase_AutoPropertyForHidingWithField = 115; - - // hiding with a property: - protected new string BaseBase_FieldForHidingWithProperty => "Base#BaseBase_FieldForHidingWithProperty"; - public new string BaseBase_PropertyForHidingWithProperty => "Base#BaseBase_PropertyForHidingWithProperty"; - private new string BaseBase_AutoPropertyForHidingWithProperty => "Base#BaseBase_AutoPropertyForHidingWithProperty"; - - // hiding with an auto-property: - public new string BaseBase_FieldForHidingWithAutoProperty { get; set; } - private new string BaseBase_PropertyForHidingWithAutoProperty { get; set; } - protected new string BaseBase_AutoPropertyForHidingWithAutoProperty { get; set; } - - // cannot override field and cannot override with a field: skipping - - // for overriding with a property: - public virtual DateTime Base_PropertyForOverridingWithProperty => new (2104, 5, 7, 1, 9, 2); - protected virtual DateTime Base_AutoPropertyForOverridingWithProperty { get; set; } - - // for overriding with a auto-property: - internal virtual DateTime Base_PropertyForOverridingWithAutoProperty => new (2114, 5, 7, 1, 9, 2); - protected virtual DateTime Base_AutoPropertyForOverridingWithAutoProperty { get; set; } - - // for not being overridden nor hidden: - public virtual DateTime Base_VirtualPropertyNotOverriddenOrHidden => new (2124, 5, 7, 1, 9, 2); - public virtual string FirstName => "BaseClass#FirstName"; - public virtual string LastName => "BaseClass#LastName"; - - // for virtual->override->new-hidden (VOH), virtual->new-hidden->override (VHO) and virtual->override->override (VOO) - public override string BaseBase_PropertyForVOH => "Base#BaseBase_PropertyForVOH"; - public new virtual string BaseBase_PropertyForVHO => "Base#BaseBase_PropertyForVHO"; - // public override string BaseBase_PropertyForVOO => "BaseBase#BaseBase_PropertyForVOO"; // FixMe: Issue #69788 - public override string BaseBase_AutoPropertyForVOH { get; set; } - public new virtual string BaseBase_AutoPropertyForVHO { get; set; } - // public override string BaseBase_AutoPropertyForVOO { get; set; }// FixMe: Issue #69788 - - // -----------------static members-------------- - // hiding with a field: - private static new int S_BaseBase_FieldForHidingWithField = 105; - protected static new int S_BaseBase_PropertyForHidingWithField = 110; - public static new int S_BaseBase_AutoPropertyForHidingWithField = 115; - - // hiding with a property: - protected static new string S_BaseBase_FieldForHidingWithProperty => "Base#BaseBase_FieldForHidingWithProperty"; - public static new string S_BaseBase_PropertyForHidingWithProperty => "Base#BaseBase_PropertyForHidingWithProperty"; - private static new string S_BaseBase_AutoPropertyForHidingWithProperty => "Base#BaseBase_AutoPropertyForHidingWithProperty"; - - // hiding with an auto-property: - public static new string S_BaseBase_FieldForHidingWithAutoProperty { get; set; } - private static new string S_BaseBase_PropertyForHidingWithAutoProperty { get; set; } - protected static new string S_BaseBase_AutoPropertyForHidingWithAutoProperty { get; set; } - - public BaseClass2() - { - S_BaseBase_PropertyForHidingWithField = S_BaseBase_FieldForHidingWithField + 5; // suppressing non-used variable warning - BaseBase_PropertyForHidingWithField = BaseBase_FieldForHidingWithField + 5; // suppressing non-used variable warning - BaseBase_FieldForHidingWithAutoProperty = "Base#BaseBase_FieldForHidingWithAutoProperty"; - BaseBase_PropertyForHidingWithAutoProperty = "Base#BaseBase_PropertyForHidingWithAutoProperty"; - BaseBase_AutoPropertyForHidingWithAutoProperty = "Base#BaseBase_AutoPropertyForHidingWithAutoProperty"; - Base_AutoPropertyForOverridingWithProperty = new (2134, 5, 7, 1, 9, 2); - Base_AutoPropertyForOverridingWithAutoProperty = new (2144, 5, 7, 1, 9, 2); - - BaseBase_AutoPropertyForVOH = "Base#BaseBase_AutoPropertyForVOH"; - BaseBase_AutoPropertyForVHO = "Base#BaseBase_AutoPropertyForVHO"; - // BaseBase_AutoPropertyForVOO = "Base#BaseBase_AutoPropertyForVOO"; // FixMe: Issue #69788 - } - } - - public class DerivedClass2 : BaseClass2 - { - // overriding with a property: - public override DateTime Base_PropertyForOverridingWithProperty => new(2020, 7, 6, 5, 4, 3); - protected override DateTime Base_AutoPropertyForOverridingWithProperty => new(2021, 7, 6, 5, 4, 3); - - // overriding with a auto-property: - internal override DateTime Base_PropertyForOverridingWithAutoProperty { get; } - protected override DateTime Base_AutoPropertyForOverridingWithAutoProperty { get; set; } - - // hiding sample members from BaseBase: - public new int BaseBase_PropertyForHidingWithField = 210; - protected new string BaseBase_AutoPropertyForHidingWithProperty => "Derived#BaseBase_AutoPropertyForHidingWithProperty"; - private new string BaseBase_FieldForHidingWithAutoProperty { get; set; } - - // for virtual->override->new-hidden (VOH), virtual->new-hidden->override (VHO) and virtual->override->override (VOO) - public new string BaseBase_PropertyForVOH => "Derived#BaseBase_PropertyForVOH"; - public override string BaseBase_PropertyForVHO => "Derived#BaseBase_PropertyForVHO"; - // public override string BaseBase_PropertyForVOO => "Derived#BaseBase_PropertyForVOO"; // FixMe: Issue #69788 - public new string BaseBase_AutoPropertyForVOH { get; set; } - public override string BaseBase_AutoPropertyForVHO { get; set; } - // public override string BaseBase_AutoPropertyForVOO { get; set; } // FixMe: Issue #69788 - - // -----------------static members-------------- - // hiding sample members from BaseBase: - public static new int S_BaseBase_PropertyForHidingWithField = 210; - protected static new string S_BaseBase_AutoPropertyForHidingWithProperty => "Derived#BaseBase_AutoPropertyForHidingWithProperty"; - private static new string S_BaseBase_FieldForHidingWithAutoProperty { get; set; } - - public DerivedClass2() - { - Base_PropertyForOverridingWithAutoProperty = new (2022, 7, 6, 5, 4, 3); - Base_AutoPropertyForOverridingWithAutoProperty = new (2023, 7, 6, 5, 4, 3); - BaseBase_FieldForHidingWithAutoProperty = "Derived#BaseBase_FieldForHidingWithAutoProperty"; - - BaseBase_AutoPropertyForVOH = "Derived#BaseBase_AutoPropertyForVOH"; - BaseBase_AutoPropertyForVHO = "Derived#BaseBase_AutoPropertyForVHO"; - // BaseBase_AutoPropertyForVOO = "Derived#BaseBase_AutoPropertyForVOO"; // FixMe: Issue #69788 - } - - public static void run() - { - new DerivedClass2().InstanceMethod(); - new DerivedClass2().InstanceMethodAsync().Wait(); - } - - public void InstanceMethod() - { - Console.WriteLine($"break here"); - } - - public async Task InstanceMethodAsync() - { - Console.WriteLine($"break here"); - await Task.CompletedTask; - } - } - - public struct CloneableStruct : ICloneable, IName - { - private string _stringField; - private DateTime _dateTime; - private DateTime _DTProp => new DateTime(2200, 5, 6, 7, 8, 9); - - internal bool b = true; - - public int a; - public DateTime DateTime => _DTProp.AddMinutes(10); - public string AutoStringProperty { get; set; } - public string FirstName => "CloneableStruct#FirstName"; - public string LastName => "CloneableStruct#LastName"; - public int this[int i] => i + 1; - - object ICloneable.Clone() - { - // not meant to be used! - return new CloneableStruct(0); - } - - public CloneableStruct(int bias) - { - a = 4; - _stringField = "CloneableStruct#_stringField"; - _dateTime = new DateTime(2020, 7, 6, 5, 4, 3 + bias); - AutoStringProperty = "CloneableStruct#AutoStringProperty"; - } - - public static void run() - { - new CloneableStruct(3).InstanceMethod(); - new CloneableStruct(3).InstanceMethodAsync().Wait(); - } - - public string GetStringField() => _stringField; - - public void InstanceMethod() - { - Console.WriteLine($"break here"); - } - - public async Task InstanceMethodAsync() - { - Console.WriteLine($"break here"); - await Task.CompletedTask; - } - - public static void SimpleStaticMethod(DateTime dateTimeArg, string stringArg) - { - Console.WriteLine($"break here"); - } - - } - - public struct NestedStruct - { - public CloneableStruct cloneableStruct; - - public NestedStruct(int bias) - { - cloneableStruct = new CloneableStruct(bias); - } - - public static void run() - { - TestNestedStructStatic(); - TestNestedStructStaticAsync().Wait(); - } - - public static void TestNestedStructStatic() - { - var ns = new NestedStruct(3); - Console.WriteLine($"break here"); - } - - public static async Task TestNestedStructStaticAsync() - { - var ns = new NestedStruct(3); - Console.WriteLine($"break here"); - await Task.CompletedTask; - } - } - - class BaseClassForJSTest - { - public string kind = "car"; - public string make = "mini"; - public bool available => true; - } - - class DerivedClassForJSTest : BaseClassForJSTest - { - public string owner_name = "foo"; - public string owner_last_name => "bar"; - - public static void run() - { - var obj = new DerivedClassForJSTest(); - Console.WriteLine($"break here"); - } - } - - public class TestWithReflection - { - public static void run() - { - InvokeReflectedStaticMethod(10, "foobar", new DateTime(1234, 6, 7, 8, 9, 10), 100, "xyz", 345, "abc"); - } - - public static void InvokeReflectedStaticMethod(int num, string name, DateTime some_date, int num1, string str2, int num3, string str3) - { - var mi = typeof(CloneableStruct).GetMethod("SimpleStaticMethod"); - var dt = new DateTime(4210, 3, 4, 5, 6, 7); - int i = 4; - - string[] strings = new[] { "abc" }; - CloneableStruct cs = new CloneableStruct(); - - // var cs = new CloneableStruct(); - mi.Invoke(null, new object[] { dt, "called from run" }); - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-main.js b/src/mono/browser/debugger/tests/debugger-test/debugger-main.js deleted file mode 100644 index fcac7508184364..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-main.js +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -"use strict"; - -import { dotnet, exit } from './_framework/dotnet.js' - -try { - const runtime = await dotnet - .withEnvironmentVariable("DOTNET_MODIFIABLE_ASSEMBLIES", "debug") - .withConfig({ maxParallelDownloads: 10 }) - // For custom logging patch the functions below - //.withDiagnosticTracing(true) - //.withEnvironmentVariable("MONO_LOG_LEVEL", "debug") - //.withEnvironmentVariable("MONO_LOG_MASK", "all") - .create(); - /*runtime.INTERNAL.logging = { - trace: (domain, log_level, message, isFatal, dataPtr) => console.log({ domain, log_level, message, isFatal, dataPtr }), - debugger: (level, message) => console.log({ level, message }), - };*/ - App.runtime = runtime; - - // this is fake implementation of legacy `bind_static_method` - // so that we don't have to rewrite all the tests which use it via `invoke_static_method` - App.bind_static_method = (method_name) => { - const methodInfo = App.exports.DebuggerTests.BindStaticMethod.GetMethodInfo(method_name); - const signature = App.exports.DebuggerTests.BindStaticMethod.GetSignature(methodInfo); - const invoker = App.exports.DebuggerTests.BindStaticMethod[signature]; - if (!invoker) { - const message = `bind_static_method: Could not find invoker for ${method_name} with signature ${signature}`; - console.error(message); - throw new Error(message); - } - return function () { - return invoker(methodInfo, ...arguments); - } - } - - // this is fake implementation of legacy `bind_static_method` which uses `mono_wasm_invoke_jsexport` - // We have unit tests that stop on unhandled managed exceptions. - // as opposed to [JSExport], the `mono_wasm_invoke_jsexport` doesn't handle managed exceptions. - // Same way as old `bind_static_method` didn't - App.bind_static_method_native = (method_name) => { - try { - const monoMethodPtr = App.exports.DebuggerTests.BindStaticMethod.GetMonoMethodPtr(method_name); - // this is only implemented for void methods with no arguments - const invoker = runtime.Module.cwrap("mono_wasm_invoke_jsexport", "void", ["number", "number"]); - return function () { - try { - return invoker(monoMethodPtr, 0, 0); - } - catch (err) { - console.error(err); - throw err; - } - } - } - catch (err) { - console.error(err); - throw err; - } - } - - await App.init(); -} -catch (err) { - exit(2, err); -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-nullable-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-nullable-test.cs deleted file mode 100644 index 9ef65e0e903549..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-nullable-test.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -#nullable enable - -namespace DebuggerTests -{ - public class NullableTests - { - public static void TestNullableLocal() - { - int? n_int = 5; - int? n_int_null = null; - - DateTime? n_dt = new DateTime(2310, 1, 2, 3, 4, 5); - DateTime? n_dt_null = null; - - ValueTypesTest.GenericStruct? n_gs = new ValueTypesTest.GenericStruct { StringField = "n_gs#StringField" }; - ValueTypesTest.GenericStruct? n_gs_null = null; - - Console.WriteLine($"break here"); - } - - public static async Task TestNullableLocalAsync() - { - int? n_int = 5; - int? n_int_null = null; - - DateTime? n_dt = new DateTime(2310, 1, 2, 3, 4, 5); - DateTime? n_dt_null = null; - - ValueTypesTest.GenericStruct? n_gs = new ValueTypesTest.GenericStruct { StringField = "n_gs#StringField" }; - ValueTypesTest.GenericStruct? n_gs_null = null; - - Console.WriteLine($"break here"); - await Task.CompletedTask; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-pointers-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-pointers-test.cs deleted file mode 100644 index e5ed9d65f9c004..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-pointers-test.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; - -namespace DebuggerTests -{ - public class PointerTests - { - - public static unsafe void LocalPointers() - { - int ivalue0 = 5; - int ivalue1 = 10; - - int* ip = &ivalue0; - int* ip_null = null; - int** ipp = &ip; - int** ipp_null = &ip_null; - int*[] ipa = new int*[] { &ivalue0, &ivalue1, null }; - int**[] ippa = new int**[] { &ip, &ip_null, ipp, ipp_null, null }; - char cvalue0 = 'q'; - char* cp = &cvalue0; - - DateTime dt = new DateTime(5, 6, 7, 8, 9, 10); - void* vp = &dt; - void* vp_null = null; - void** vpp = &vp; - void** vpp_null = &vp_null; - - DateTime* dtp = &dt; - DateTime* dtp_null = null; - DateTime*[] dtpa = new DateTime*[] { dtp, dtp_null }; - DateTime**[] dtppa = new DateTime**[] { &dtp, &dtp_null, null }; - Console.WriteLine($"-- break here: ip_null==null: {ip_null == null}, ipp_null: {ipp_null == null}, *ipp_null==ip_null: {*ipp_null == ip_null}, *ipp_null==null: {*ipp_null == null}"); - - var gs = new GenericStructWithUnmanagedT { Value = new DateTime(1, 2, 3, 4, 5, 6), IntField = 4, DTPP = &dtp }; - var gs_null = new GenericStructWithUnmanagedT { Value = new DateTime(1, 2, 3, 4, 5, 6), IntField = 4, DTPP = &dtp_null }; - var gsp = &gs; - var gsp_null = &gs_null; - var gspa = new GenericStructWithUnmanagedT*[] { null, gsp, gsp_null }; - - var cwp = new GenericClassWithPointers { Ptr = dtp }; - var cwp_null = new GenericClassWithPointers(); - Console.WriteLine($"{(int)*ip}, {(int)**ipp}, {ipp_null == null}, {ip_null == null}, {ippa == null}, {ipa}, {(char)*cp}, {(vp == null ? "null" : "not null")}, {dtp->Second}, {gsp->IntField}, {cwp}, {cwp_null}, {gs_null}"); - - PointersAsArgsTest(ip, ipp, ipa, ippa, &dt, &dtp, dtpa, dtppa); - } - - static unsafe void PointersAsArgsTest(int* ip, int** ipp, int*[] ipa, int**[] ippa, - DateTime* dtp, DateTime** dtpp, DateTime*[] dtpa, DateTime**[] dtppa) - { - Console.WriteLine($"break here!"); - if (ip == null) - Console.WriteLine($"ip is null"); - Console.WriteLine($"done!"); - } - - public static unsafe Task LocalPointersAsync() - { - int ivalue0 = 5; - int ivalue1 = 10; - - int* ip = &ivalue0; - int* ip_null = null; - int** ipp = &ip; - int** ipp_null = &ip_null; - int*[] ipa = new int*[] { &ivalue0, &ivalue1, null }; - int**[] ippa = new int**[] { &ip, &ip_null, ipp, ipp_null, null }; - char cvalue0 = 'q'; - char* cp = &cvalue0; - - DateTime dt = new DateTime(5, 6, 7, 8, 9, 10); - void* vp = &dt; - void* vp_null = null; - void** vpp = &vp; - void** vpp_null = &vp_null; - - DateTime* dtp = &dt; - DateTime* dtp_null = null; - DateTime*[] dtpa = new DateTime*[] { dtp, dtp_null }; - DateTime**[] dtppa = new DateTime**[] { &dtp, &dtp_null, null }; - Console.WriteLine($"-- break here: ip_null==null: {ip_null == null}, ipp_null: {ipp_null == null}, *ipp_null==ip_null: {*ipp_null == ip_null}, *ipp_null==null: {*ipp_null == null}"); - - var gs = new GenericStructWithUnmanagedT { Value = new DateTime(1, 2, 3, 4, 5, 6), IntField = 4, DTPP = &dtp }; - var gs_null = new GenericStructWithUnmanagedT { Value = new DateTime(1, 2, 3, 4, 5, 6), IntField = 4, DTPP = &dtp_null }; - var gsp = &gs; - var gsp_null = &gs_null; - var gspa = new GenericStructWithUnmanagedT*[] { null, gsp, gsp_null }; - - var cwp = new GenericClassWithPointers { Ptr = dtp }; - var cwp_null = new GenericClassWithPointers(); - Console.WriteLine($"{(int)*ip}, {(int)**ipp}, {ipp_null == null}, {ip_null == null}, {ippa == null}, {ipa}, {(char)*cp}, {(vp == null ? "null" : "not null")}, {dtp->Second}, {gsp->IntField}, {cwp}, {cwp_null}, {gs_null}"); return Task.CompletedTask; - } - - // async methods cannot have unsafe params, so no test for that - } - - public unsafe struct GenericStructWithUnmanagedT where T : unmanaged - { - public T Value; - public int IntField; - - public DateTime** DTPP; - } - - public unsafe class GenericClassWithPointers where T : unmanaged - { - public unsafe T* Ptr; - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-set-variable-value-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-set-variable-value-test.cs deleted file mode 100644 index 1d4a8af435ed89..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-set-variable-value-test.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -namespace DebuggerTests -{ - public class SetVariableLocals - { - public static void run() - { - sbyte a = 1; - byte a1 = 1; - short b = 2; - ushort b2 = 3; - int d = 5; - uint d2 = 6; - long e = 7; - ulong e2 = 8; - float f = 9; - double g = 10; - System.Console.WriteLine(g); - System.Console.WriteLine(f); - System.Console.WriteLine(e2); - } - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-test.cs deleted file mode 100644 index a0a0cc0aa2827a..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-test.cs +++ /dev/null @@ -1,1687 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -public partial class Math -{ //Only append content to this class as the test suite depends on line info - [System.Runtime.InteropServices.JavaScript.JSExport] public static int IntAdd(int a, int b) - { - int c = a + b; - int d = c + b; - int e = d + a; - bool f = true; - return e; - } - - [System.Runtime.InteropServices.JavaScript.JSExport] public static int UseComplex(int a, int b) - { - var complex = new Simple.Complex(10, "xx"); - int c = a + b; - int d = c + b; - int e = d + a; - int f = 0; - e += complex.DoStuff(); - return e; - } - - delegate bool IsMathNull(Math m); - - [System.Runtime.InteropServices.JavaScript.JSExport] public static int DelegatesTest() - { - Func fn_func = (Math m) => m == null; - Func fn_func_null = null; - Func[] fn_func_arr = new Func[] { - (Math m) => m == null }; - - Math.IsMathNull fn_del = Math.IsMathNullDelegateTarget; - var fn_del_arr = new Math.IsMathNull[] { Math.IsMathNullDelegateTarget }; - var m_obj = new Math(); - Math.IsMathNull fn_del_null = null; - bool res = fn_func(m_obj) && fn_del(m_obj) && fn_del_arr[0](m_obj) && fn_del_null == null && fn_func_null == null && fn_func_arr[0] != null; - - // Unused locals - - Func fn_func_unused = (Math m) => m == null; - Func fn_func_null_unused = null; - Func[] fn_func_arr_unused = new Func[] { (Math m) => m == null }; - - Math.IsMathNull fn_del_unused = Math.IsMathNullDelegateTarget; - Math.IsMathNull fn_del_null_unused = null; - var fn_del_arr_unused = new Math.IsMathNull[] { Math.IsMathNullDelegateTarget }; - OuterMethod(); - Console.WriteLine("Just a test message, ignore"); - return res ? 0 : 1; - } - - [System.Runtime.InteropServices.JavaScript.JSExport] public static int GenericTypesTest() - { - var list = new System.Collections.Generic.Dictionary(); - System.Collections.Generic.Dictionary list_null = null; - - var list_arr = new System.Collections.Generic.Dictionary[] { new System.Collections.Generic.Dictionary() }; - System.Collections.Generic.Dictionary[] list_arr_null = null; - - Console.WriteLine($"list_arr.Length: {list_arr.Length}, list.Count: {list.Count}"); - - // Unused locals - - var list_unused = new System.Collections.Generic.Dictionary(); - System.Collections.Generic.Dictionary list_null_unused = null; - - var list_arr_unused = new System.Collections.Generic.Dictionary[] { new System.Collections.Generic.Dictionary() }; - System.Collections.Generic.Dictionary[] list_arr_null_unused = null; - - OuterMethod(); - Console.WriteLine("Just a test message, ignore"); - return 0; - } - - static bool IsMathNullDelegateTarget(Math m) => m == null; - - [System.Runtime.InteropServices.JavaScript.JSExport] public static void OuterMethod() - { - Console.WriteLine($"OuterMethod called"); - var nim = new Math.NestedInMath(); - var i = 5; - var text = "Hello"; - var new_i = nim.InnerMethod(i); - Console.WriteLine($"i: {i}"); - Console.WriteLine($"-- InnerMethod returned: {new_i}, nim: {nim}, text: {text}"); - int k = 19; - new_i = InnerMethod2("test string", new_i, out k); - Console.WriteLine($"-- InnerMethod2 returned: {new_i}, and k: {k}"); - } - - static int InnerMethod2(string s, int i, out int k) - { - k = i + 10; - Console.WriteLine($"s: {s}, i: {i}, k: {k}"); - return i - 2; - } - - public partial class NestedInMath - { - public int InnerMethod(int i) - { - SimpleStructProperty = new SimpleStruct() { dt = new DateTime(2020, 1, 2, 3, 4, 5) }; - int j = i + 10; - string foo_str = "foo"; - Console.WriteLine($"i: {i} and j: {j}, foo_str: {foo_str} "); - j += 9; - Console.WriteLine($"i: {i} and j: {j}"); - return j; - } - - Math m = new Math(); - public async System.Threading.Tasks.Task AsyncMethod0(string s, int i) - { - string local0 = "value0"; - await System.Threading.Tasks.Task.Delay(1); - Console.WriteLine($"* time for the second await, local0: {local0}"); - await AsyncMethodNoReturn(); - return true; - } - - public async System.Threading.Tasks.Task AsyncMethodNoReturn() - { - var ss = new SimpleStruct() { dt = new DateTime(2020, 1, 2, 3, 4, 5) }; - var ss_arr = new SimpleStruct[] { }; - //ss.gs.StringField = "field in GenericStruct"; - - //Console.WriteLine ($"Using the struct: {ss.dt}, {ss.gs.StringField}, ss_arr: {ss_arr.Length}"); - string str = "AsyncMethodNoReturn's local"; - //Console.WriteLine ($"* field m: {m}"); - await System.Threading.Tasks.Task.Delay(1); - Console.WriteLine($"str: {str}"); - } - - [System.Runtime.InteropServices.JavaScript.JSExport] public static async System.Threading.Tasks.Task AsyncTest(string s, int i) - { - var li = 10 + i; - var ls = s + "test"; - return await new NestedInMath().AsyncMethod0(s, i); - } - - public SimpleStruct SimpleStructProperty { get; set; } - } - - public static void PrimitiveTypesTest() - { - char c0 = '\u20AC'; - char c1 = 'A'; - // TODO: other types! - // just trying to ensure vars don't get optimized out - if (c0 < 32 || c1 > 32) - Console.WriteLine($"{c0}, {c1}"); - } - - public static int DelegatesSignatureTest() - { - Func>, GenericStruct> fn_func = (m, gs) => new GenericStruct(); - Func>, GenericStruct> fn_func_del = GenericStruct.DelegateTargetForSignatureTest; - Func>, GenericStruct> fn_func_null = null; - Func fn_func_only_ret = () => { Console.WriteLine($"hello"); return true; }; - var fn_func_arr = new Func>, GenericStruct>[] { - (m, gs) => new GenericStruct () }; - - Math.DelegateForSignatureTest fn_del = GenericStruct.DelegateTargetForSignatureTest; - Math.DelegateForSignatureTest fn_del_l = (m, gs) => new GenericStruct { StringField = "fn_del_l#lambda" }; - var fn_del_arr = new Math.DelegateForSignatureTest[] { GenericStruct.DelegateTargetForSignatureTest, (m, gs) => new GenericStruct { StringField = "fn_del_arr#1#lambda" } }; - var m_obj = new Math(); - Math.DelegateForSignatureTest fn_del_null = null; - var gs_gs = new GenericStruct> - { - List = new System.Collections.Generic.List> - { - new GenericStruct { StringField = "gs#List#0#StringField" }, - new GenericStruct { StringField = "gs#List#1#StringField" } - } - }; - - Math.DelegateWithVoidReturn fn_void_del = Math.DelegateTargetWithVoidReturn; - var fn_void_del_arr = new Math.DelegateWithVoidReturn[] { Math.DelegateTargetWithVoidReturn }; - Math.DelegateWithVoidReturn fn_void_del_null = null; - - var rets = new GenericStruct[] - { - fn_func(m_obj, gs_gs), - fn_func_del(m_obj, gs_gs), - fn_del(m_obj, gs_gs), - fn_del_l(m_obj, gs_gs), - fn_del_arr[0](m_obj, gs_gs), - fn_func_arr[0](m_obj, gs_gs) - }; - - var gs = new GenericStruct(); - fn_void_del(gs); - fn_void_del_arr[0](gs); - fn_func_only_ret(); - foreach (var ret in rets) Console.WriteLine($"ret: {ret}"); - OuterMethod(); - Console.WriteLine($"- {gs_gs.List[0].StringField}"); - return 0; - } - - public static int ActionTSignatureTest() - { - Action> fn_action = (_) => { }; - Action> fn_action_del = Math.DelegateTargetWithVoidReturn; - Action fn_action_bare = () => { }; - Action> fn_action_null = null; - var fn_action_arr = new Action>[] - { - (gs) => new GenericStruct(), - Math.DelegateTargetWithVoidReturn, - null - }; - - var gs = new GenericStruct(); - fn_action(gs); - fn_action_del(gs); - fn_action_arr[0](gs); - fn_action_bare(); - OuterMethod(); - return 0; - } - - public static int NestedDelegatesTest() - { - Func, bool> fn_func = (_) => { return true; }; - Func, bool> fn_func_null = null; - var fn_func_arr = new Func, bool>[] { - (gs) => { return true; } }; - - var fn_del_arr = new Func, bool>[] { DelegateTargetForNestedFunc> }; - var m_obj = new Math(); - Func, bool> fn_del_null = null; - Func fs = (i) => i == 0; - fn_func(fs); - fn_del_arr[0](fs); - fn_func_arr[0](fs); - OuterMethod(); - return 0; - } - - public static void DelegatesAsMethodArgsTest() - { - var _dst_arr = new DelegateForSignatureTest[] - { - GenericStruct.DelegateTargetForSignatureTest, - (m, gs) => new GenericStruct() - }; - Func _fn_func = (cs) => cs.Length == 0; - Action[]> _fn_action = (gss) => { }; - - new Math().MethodWithDelegateArgs(_dst_arr, _fn_func, _fn_action); - } - - void MethodWithDelegateArgs(Math.DelegateForSignatureTest[] dst_arr, Func fn_func, - Action[]> fn_action) - { - Console.WriteLine($"Placeholder for breakpoint"); - OuterMethod(); - } - - public static async System.Threading.Tasks.Task MethodWithDelegatesAsyncTest() - { - await new Math().MethodWithDelegatesAsync(); - } - - async System.Threading.Tasks.Task MethodWithDelegatesAsync() - { - var _dst_arr = new DelegateForSignatureTest[] - { - GenericStruct.DelegateTargetForSignatureTest, - (m, gs) => new GenericStruct() - }; - Func _fn_func = (cs) => cs.Length == 0; - Action[]> _fn_action = (gss) => { }; - - Console.WriteLine($"Placeholder for breakpoint"); - await System.Threading.Tasks.Task.CompletedTask; - } - - public delegate void DelegateWithVoidReturn(GenericStruct gs); - public static void DelegateTargetWithVoidReturn(GenericStruct gs) { } - - public delegate GenericStruct DelegateForSignatureTest(Math m, GenericStruct> gs); - static bool DelegateTargetForNestedFunc(T arg) => true; - - public struct SimpleStruct - { - public DateTime dt; - public GenericStruct gs; - } - - public struct GenericStruct - { - public System.Collections.Generic.List List; - public string StringField; - - public static GenericStruct DelegateTargetForSignatureTest(Math m, GenericStruct> gs) => new GenericStruct(); - } - - public static void TestSimpleStrings() - { - string str_null = null; - string str_empty = String.Empty; - string str_spaces = " "; - string str_esc = "\\"; - - var strings = new[] - { - str_null, - str_empty, - str_spaces, - str_esc - }; - Console.WriteLine($"break here"); - } - -} - -public partial class DebuggerTest -{ - [System.Runtime.InteropServices.JavaScript.JSExport] public static void run_all() - { - locals(); - } - - public static int locals() - { - int l_int = 1; - char l_char = 'A'; - long l_long = Int64.MaxValue; - ulong l_ulong = UInt64.MaxValue; - locals_inner(); - return 0; - } - - static void locals_inner() { } - - public static void BoxingTest() - { - int? n_i = 5; - object o_i = n_i.Value; - object o_n_i = n_i; - - object o_s = "foobar"; - object o_obj = new Math(); - DebuggerTests.ValueTypesTest.GenericStruct? n_gs = new DebuggerTests.ValueTypesTest.GenericStruct { StringField = "n_gs#StringField" }; - object o_gs = n_gs.Value; - object o_n_gs = n_gs; - - DateTime? n_dt = new DateTime(2310, 1, 2, 3, 4, 5); - object o_dt = n_dt.Value; - object o_n_dt = n_dt; - object o_null = null; - object o_ia = new int[] {918, 58971}; - - Console.WriteLine ($"break here"); - } - - public static async System.Threading.Tasks.Task BoxingTestAsync() - { - int? n_i = 5; - object o_i = n_i.Value; - object o_n_i = n_i; - - object o_s = "foobar"; - object o_obj = new Math(); - DebuggerTests.ValueTypesTest.GenericStruct? n_gs = new DebuggerTests.ValueTypesTest.GenericStruct { StringField = "n_gs#StringField" }; - object o_gs = n_gs.Value; - object o_n_gs = n_gs; - - DateTime? n_dt = new DateTime(2310, 1, 2, 3, 4, 5); - object o_dt = n_dt.Value; - object o_n_dt = n_dt; - object o_null = null; - object o_ia = new int[] {918, 58971}; - - Console.WriteLine ($"break here"); - await System.Threading.Tasks.Task.CompletedTask; - } - - public static void BoxedTypeObjectTest() - { - int i = 5; - object o0 = i; - object o1 = o0; - object o2 = o1; - object o3 = o2; - - object oo = new object(); - object oo0 = oo; - Console.WriteLine ($"break here"); - } - public static async System.Threading.Tasks.Task BoxedTypeObjectTestAsync() - { - int i = 5; - object o0 = i; - object o1 = o0; - object o2 = o1; - object o3 = o2; - - object oo = new object(); - object oo0 = oo; - Console.WriteLine ($"break here"); - await System.Threading.Tasks.Task.CompletedTask; - } - - public static void BoxedAsClass() - { - ValueType vt_dt = new DateTime(4819, 5, 6, 7, 8, 9); - ValueType vt_gs = new Math.GenericStruct { StringField = "vt_gs#StringField" }; - Enum e = new System.IO.FileMode(); - Enum ee = System.IO.FileMode.Append; - - Console.WriteLine ($"break here"); - } - - public static async System.Threading.Tasks.Task BoxedAsClassAsync() - { - ValueType vt_dt = new DateTime(4819, 5, 6, 7, 8, 9); - ValueType vt_gs = new Math.GenericStruct { StringField = "vt_gs#StringField" }; - Enum e = new System.IO.FileMode(); - Enum ee = System.IO.FileMode.Append; - - Console.WriteLine ($"break here"); - await System.Threading.Tasks.Task.CompletedTask; - } -} - -public class MulticastDelegateTestClass -{ - event EventHandler TestEvent; - MulticastDelegate Delegate; - - public static void run() - { - var obj = new MulticastDelegateTestClass(); - obj.Test(); - obj.TestAsync().Wait(); - } - - public void Test() - { - TestEvent += (_, s) => Console.WriteLine(s); - TestEvent += (_, s) => Console.WriteLine(s + "qwe"); - Delegate = TestEvent; - - TestEvent?.Invoke(this, Delegate?.ToString()); - } - - public async System.Threading.Tasks.Task TestAsync() - { - TestEvent += (_, s) => Console.WriteLine(s); - TestEvent += (_, s) => Console.WriteLine(s + "qwe"); - Delegate = TestEvent; - - TestEvent?.Invoke(this, Delegate?.ToString()); - await System.Threading.Tasks.Task.CompletedTask; - } -} - -public class EmptyClass -{ - public static void StaticMethodWithNoLocals() - { - Console.WriteLine($"break here"); - } - - public static async System.Threading.Tasks.Task StaticMethodWithNoLocalsAsync() - { - Console.WriteLine($"break here"); - await System.Threading.Tasks.Task.CompletedTask; - } - - public static void run() - { - StaticMethodWithNoLocals(); - StaticMethodWithNoLocalsAsync().Wait(); - } -} - -public struct EmptyStruct -{ - public static void StaticMethodWithNoLocals() - { - Console.WriteLine($"break here"); - } - - public static async System.Threading.Tasks.Task StaticMethodWithNoLocalsAsync() - { - Console.WriteLine($"break here"); - await System.Threading.Tasks.Task.CompletedTask; - } - - public static void StaticMethodWithLocalEmptyStruct() - { - var es = new EmptyStruct(); - Console.WriteLine($"break here"); - } - - public static async System.Threading.Tasks.Task StaticMethodWithLocalEmptyStructAsync() - { - var es = new EmptyStruct(); - Console.WriteLine($"break here"); - await System.Threading.Tasks.Task.CompletedTask; - } - - public static void run() - { - StaticMethodWithNoLocals(); - StaticMethodWithNoLocalsAsync().Wait(); - - StaticMethodWithLocalEmptyStruct(); - StaticMethodWithLocalEmptyStructAsync().Wait(); - } -} - -public class LoadDebuggerTest { - public static void LoadLazyAssembly(string asm_base64, string pdb_base64) - { - byte[] asm_bytes = Convert.FromBase64String(asm_base64); - byte[] pdb_bytes = null; - if (pdb_base64 != null) - pdb_bytes = Convert.FromBase64String(pdb_base64); - - var loadedAssembly = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromStream(new System.IO.MemoryStream(asm_bytes), new System.IO.MemoryStream(pdb_bytes)); - Console.WriteLine($"Loaded - {loadedAssembly}"); - } -} - -public partial class HiddenSequencePointTest { - public static void StepOverHiddenSP() - { - Console.WriteLine("first line"); - #line hidden - Console.WriteLine("second line"); - StepOverHiddenSP2(); - #line default - Console.WriteLine("third line"); - MethodWithHiddenLinesAtTheEnd(); - } - public static void StepOverHiddenSP2() - { - Console.WriteLine("StepOverHiddenSP2"); - } - - public static void MethodWithHiddenLinesAtTheEnd() - { - Console.WriteLine ($"MethodWithHiddenLinesAtTheEnd"); -#line hidden - Console.WriteLine ($"debugger shouldn't be able to step here"); - } -#line default -} - -public class LoadDebuggerTestALC { - static System.Reflection.Assembly loadedAssembly; - public static void LoadLazyAssemblyInALC(string asm_base64, string pdb_base64) - { - var context = new System.Runtime.Loader.AssemblyLoadContext("testContext", true); - byte[] asm_bytes = Convert.FromBase64String(asm_base64); - byte[] pdb_bytes = null; - if (pdb_base64 != null) - pdb_bytes = Convert.FromBase64String(pdb_base64); - - loadedAssembly = context.LoadFromStream(new System.IO.MemoryStream(asm_bytes), new System.IO.MemoryStream(pdb_bytes)); - Console.WriteLine($"Loaded - {loadedAssembly}"); - } - public static void RunMethodInALC(string type_name, string method_name) - { - var myType = loadedAssembly.GetType(type_name); - var myMethod = myType.GetMethod(method_name); - myMethod.Invoke(null, new object[] { 5, 10 }); - } -} - - public class TestHotReload { - static System.Reflection.Assembly loadedAssembly; - static byte[] dmeta_data1_bytes; - static byte[] dil_data1_bytes; - static byte[] dpdb_data1_bytes; - static byte[] dmeta_data2_bytes; - static byte[] dil_data2_bytes; - static byte[] dpdb_data2_bytes; - public static void LoadLazyHotReload(string asm_base64, string pdb_base64, string dmeta_data1, string dil_data1, string dpdb_data1, string dmeta_data2, string dil_data2, string dpdb_data2) - { - byte[] asm_bytes = Convert.FromBase64String(asm_base64); - byte[] pdb_bytes = Convert.FromBase64String(pdb_base64); - - dmeta_data1_bytes = Convert.FromBase64String(dmeta_data1); - dil_data1_bytes = Convert.FromBase64String(dil_data1); - dpdb_data1_bytes = Convert.FromBase64String(dpdb_data1); - - dmeta_data2_bytes = Convert.FromBase64String(dmeta_data2); - dil_data2_bytes = Convert.FromBase64String(dil_data2); - dpdb_data2_bytes = Convert.FromBase64String(dpdb_data2); - - - loadedAssembly = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromStream(new System.IO.MemoryStream(asm_bytes), new System.IO.MemoryStream(pdb_bytes)); - Console.WriteLine($"Loaded - {loadedAssembly}"); - - } - public static void RunMethod(string className, string methodName, string methodName2, string methodName3) - { - var ty = typeof(System.Reflection.Metadata.MetadataUpdater); - var mi = ty.GetMethod("GetCapabilities", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, Array.Empty()); - - if (mi == null) - return; - - var caps = mi.Invoke(null, null) as string; - - if (String.IsNullOrEmpty(caps)) - return; - - var myType = loadedAssembly.GetType($"ApplyUpdateReferencedAssembly.{className}"); - var myMethod = myType.GetMethod(methodName); - myMethod.Invoke(null, null); - - ApplyUpdate(loadedAssembly, 1); - - myType = loadedAssembly.GetType($"ApplyUpdateReferencedAssembly.{className}"); - myMethod = myType.GetMethod(methodName2); - myMethod.Invoke(null, null); - - ApplyUpdate(loadedAssembly, 2); - - myType = loadedAssembly.GetType($"ApplyUpdateReferencedAssembly.{className}"); - myMethod = myType.GetMethod(methodName3); - myMethod.Invoke(null, null); - } - - internal static void ApplyUpdate (System.Reflection.Assembly assm, int version) - { - string basename = assm.Location; - if (basename == "") - basename = assm.GetName().Name + ".dll"; - Console.Error.WriteLine($"Apply Delta Update for {basename}, revision {version}"); - - if (version == 1) - { - System.Reflection.Metadata.MetadataUpdater.ApplyUpdate(assm, dmeta_data1_bytes, dil_data1_bytes, dpdb_data1_bytes); - } - else if (version == 2) - { - System.Reflection.Metadata.MetadataUpdater.ApplyUpdate(assm, dmeta_data2_bytes, dil_data2_bytes, dpdb_data2_bytes); - } - - } - } - - -public class Something -{ - public string Name { get; set; } - public Something() => Name = "Same of something"; - public override string ToString() => Name; -} - -public class Foo -{ - public string Bar => Stuffs.First(x => x.Name.StartsWith('S')).Name; - public System.Collections.Generic.List Stuffs { get; } = Enumerable.Range(0, 10).Select(x => new Something()).ToList(); - public string Lorem { get; set; } = "Safe"; - public string Ipsum { get; set; } = "Side"; - public Something What { get; } = new Something(); - public int Bart() - { - int ret; - if (Lorem.StartsWith('S')) - ret = 0; - else - ret = 1; - return ret; - } - public static void RunBart() - { - Foo foo = new Foo(); - foo.Bart(); - Console.WriteLine(foo.OtherBar()); - foo.OtherBarAsync().Wait(10); - } - public bool OtherBar() - { - var a = 1; - var b = 2; - var x = "Stew"; - var y = "00.123"; - var c = a + b == 3 || b + a == 2; - var d = TimeSpan.TryParseExact(y, @"ss\.fff", null, out var ts) && x.Contains('S'); - var e = TimeSpan.TryParseExact(y, @"ss\.fff", null, out var ts1) - && x.Contains('S'); - var f = TimeSpan.TryParseExact(y, @"ss\.fff", null, out var ts2) - && - x.Contains('S'); - var g = TimeSpan.TryParseExact(y, @"ss\.fff", null, out var ts3) && - x.Contains('S'); - return d && e == true; - } - public async System.Threading.Tasks.Task OtherBarAsync() - { - var a = 1; - var b = 2; - var x = "Stew"; - var y = "00.123"; - var c = a + b == 3 || b + a == 2; - var d = TimeSpan.TryParseExact(y, @"ss\.fff", null, out var ts) && await AsyncMethod(); - var e = TimeSpan.TryParseExact(y, @"ss\.fff", null, out var ts1) - && await AsyncMethod(); - var f = TimeSpan.TryParseExact(y, @"ss\.fff", null, out var ts2) - && - await AsyncMethod(); - var g = await AsyncMethod() && - await AsyncMethod(); - Console.WriteLine(g); - await System.Threading.Tasks.Task.CompletedTask; - } - public async System.Threading.Tasks.Task AsyncMethod() - { - await System.Threading.Tasks.Task.Delay(1); - Console.WriteLine($"time for await"); - return true; - } - -} - -public class MainPage -{ - public MainPage() - { - } - - int count = 0; - private int someValue; - - public int SomeValue - { - get - { - return someValue; - } - set - { - someValue = value; - count++; - - if (count == 10) - { - var view = 150; - - if (view != 50) - { - - } - System.Diagnostics.Debugger.Break(); - } - - SomeValue = count; - } - } - - public static void CallSetValue() - { - var mainPage = new MainPage(); - mainPage.SomeValue = 10; - } -} - -public class LoopClass -{ - public static void LoopToBreak() - { - for (int i = 0; i < 10; i++) - { - Console.WriteLine($"should pause only on i == 3"); - } - Console.WriteLine("breakpoint to check"); - } -} - -public class SteppingInto -{ - static int currentCount = 0; - static MyIncrementer incrementer = new MyIncrementer(); - public static void MethodToStep() - { - currentCount = incrementer.Increment(currentCount); - } -} - -public class MyIncrementer -{ - private Func todayFunc = () => new DateTime(2061, 1, 5); // Wednesday - - public int Increment(int count) - { - var today = todayFunc(); - if (today.DayOfWeek == DayOfWeek.Sunday) - { - return count + 2; - } - - return count + 1; - } -} - -public class DebuggerAttribute -{ - [System.Diagnostics.DebuggerHidden] - public static void HiddenMethod() - { - var a = 9; - } - - [System.Diagnostics.DebuggerHidden] - public static void HiddenMethodUserBreak() - { - System.Diagnostics.Debugger.Break(); - } - - public static void RunDebuggerHidden() - { - HiddenMethod(); - HiddenMethodUserBreak(); - } - - [System.Diagnostics.DebuggerStepThroughAttribute] - public static void StepThroughBp() - { - var a = 0; - a++; - var b = 1; - } - - [System.Diagnostics.DebuggerStepThroughAttribute] - public static void StepThroughUserBp() - { - System.Diagnostics.Debugger.Break(); - } - - public static void RunStepThrough() - { - StepThroughBp(); - StepThroughUserBp(); - } - - [System.Diagnostics.DebuggerNonUserCode] - public static void NonUserCodeBp() - { - var a = 0; - a++; - var b = 1; - } - - [System.Diagnostics.DebuggerNonUserCode] - public static void NonUserCodeUserBp() - { - System.Diagnostics.Debugger.Break(); - } - - public static void RunNonUserCode() - { - NonUserCodeBp(); - NonUserCodeUserBp(); - } - - [System.Diagnostics.DebuggerStepperBoundary] - public static void BoundaryBp() - { - var a = 5; - } - - [System.Diagnostics.DebuggerStepperBoundary] - public static void BoundaryUserBp() - { - System.Diagnostics.Debugger.Break(); - } - - [System.Diagnostics.DebuggerNonUserCode] - public static void NonUserCodeForBoundaryEscape(Action boundaryTestFun) - { - boundaryTestFun(); - } - - public static void RunNoBoundary() - { - NonUserCodeForBoundaryEscape(DebuggerAttribute.BoundaryBp); - NonUserCodeForBoundaryEscape(DebuggerAttribute.BoundaryUserBp); - } - - [System.Diagnostics.DebuggerStepThroughAttribute] - [System.Diagnostics.DebuggerHidden] - public static void StepThroughWithHiddenBp() - { - var a = 9; - } - - [System.Diagnostics.DebuggerStepThroughAttribute] - [System.Diagnostics.DebuggerHidden] - public static void StepThroughWithHiddenUserBp() - { - System.Diagnostics.Debugger.Break(); - } - - public static void RunStepThroughWithHidden() - { - StepThroughWithHiddenBp(); - StepThroughWithHiddenUserBp(); - } - - [System.Diagnostics.DebuggerStepThroughAttribute] - [System.Diagnostics.DebuggerNonUserCode] - public static void StepThroughWithNonUserCodeBp() - { - var a = 0; - a++; - var b = 1; - } - - [System.Diagnostics.DebuggerStepThroughAttribute] - [System.Diagnostics.DebuggerNonUserCode] - public static void StepThroughWithNonUserCodeUserBp() - { - System.Diagnostics.Debugger.Break(); - } - - public static void RunStepThroughWithNonUserCode() - { - StepThroughWithNonUserCodeBp(); - StepThroughWithNonUserCodeUserBp(); - } - - [System.Diagnostics.DebuggerNonUserCode] - [System.Diagnostics.DebuggerHidden] - public static void NonUserCodeWithHiddenBp() - { - var a = 9; - } - - [System.Diagnostics.DebuggerNonUserCode] - [System.Diagnostics.DebuggerHidden] - public static void NonUserCodeWithHiddenUserBp() - { - System.Diagnostics.Debugger.Break(); - } - - public static void RunNonUserCodeWithHidden() - { - NonUserCodeWithHiddenBp(); - NonUserCodeWithHiddenUserBp(); - } -} - -public class DebugTypeFull -{ - public static void CallToEvaluateLocal() - { - var asm = System.Reflection.Assembly.LoadFrom("debugger-test-with-full-debug-type.dll"); - var myType = asm.GetType("DebuggerTests.ClassToInspectWithDebugTypeFull"); - var myMethod = myType.GetConstructor(new Type[] { }); - var a = myMethod.Invoke(new object[]{}); - System.Diagnostics.Debugger.Break(); - } -} - -public class TestHotReloadUsingSDB { - static System.Reflection.Assembly loadedAssembly; - public static string LoadLazyHotReload(string asm_base64, string pdb_base64) - { - byte[] asm_bytes = Convert.FromBase64String(asm_base64); - byte[] pdb_bytes = Convert.FromBase64String(pdb_base64); - - loadedAssembly = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromStream(new System.IO.MemoryStream(asm_bytes), new System.IO.MemoryStream(pdb_bytes)); - var GUID = loadedAssembly.Modules.FirstOrDefault()?.ModuleVersionId.ToByteArray(); - return Convert.ToBase64String(GUID); - } - - public static string GetModuleGUID() - { - var GUID = loadedAssembly.Modules.FirstOrDefault()?.ModuleVersionId.ToByteArray(); - return Convert.ToBase64String(GUID); - } - - public static void RunMethod(string className, string methodName) - { - if (loadedAssembly is null) - throw new InvalidOperationException($"{nameof(loadedAssembly)} is null!"); - var myType = loadedAssembly.GetType($"ApplyUpdateReferencedAssembly.{className}"); - var myMethod = myType.GetMethod(methodName); - myMethod.Invoke(null, null); - } -} - -#region Default Interface Method -public interface IDefaultInterface -{ - public static string defaultInterfaceMember = "defaultInterfaceMember"; - - string DefaultMethod() - { - string localString = "DefaultMethod()"; - DefaultInterfaceMethod.MethodForCallingFromDIM(); - return $"{localString} from IDefaultInterface"; - } - - int DefaultMethodToOverride() - { - int retValue = 10; - return retValue; - } - - async System.Threading.Tasks.Task DefaultMethodAsync() - { - string localString = "DefaultMethodAsync()"; - DefaultInterfaceMethod.MethodForCallingFromDIM(); - await System.Threading.Tasks.Task.FromResult(0); - } - static string DefaultMethodStatic() - { - string localString = "DefaultMethodStatic()"; - DefaultInterfaceMethod.MethodForCallingFromDIM(); - return $"{localString} from IDefaultInterface"; - } - - // cannot override the static method of the interface - skipping - - static async System.Threading.Tasks.Task DefaultMethodAsyncStatic() - { - string localString = "DefaultMethodAsyncStatic()"; - DefaultInterfaceMethod.MethodForCallingFromDIM(); - await System.Threading.Tasks.Task.FromResult(0); - } -} - -public interface IExtendIDefaultInterface : IDefaultInterface -{ - void DefaultMethod2(out string t) - { - string localString = "DefaultMethod2()"; - t = $"{localString} from IExtendIDefaultInterface"; - } - - int IDefaultInterface.DefaultMethodToOverride() - { - int retValue = 110; - DefaultInterfaceMethod.MethodForCallingFromDIM(); - return retValue; - } - - [System.Diagnostics.DebuggerHidden] - void HiddenDefaultMethod() - { - var a = 9; - } - - [System.Diagnostics.DebuggerStepThroughAttribute] - void StepThroughDefaultMethod() - { - var a = 0; - } - - [System.Diagnostics.DebuggerNonUserCode] - void NonUserCodeDefaultMethod(Action boundaryTestFun = null) - { - if (boundaryTestFun != null) - boundaryTestFun(); - } - - [System.Diagnostics.DebuggerStepperBoundary] - void BoundaryBp() - { - var a = 15; - } -} - -public class DIMClass : IExtendIDefaultInterface -{ - public int dimClassMember = 123; -} - -public static class DefaultInterfaceMethod -{ - public static void Evaluate() - { - IExtendIDefaultInterface extendDefaultInter = new DIMClass(); - string defaultFromIDefault = extendDefaultInter.DefaultMethod(); - int overrideFromIExtend = extendDefaultInter.DefaultMethodToOverride(); - extendDefaultInter.DefaultMethod2(out string default2FromIExtend); - } - - public static async void EvaluateAsync() - { - IDefaultInterface defaultInter = new DIMClass(); - await defaultInter.DefaultMethodAsync(); - } - - public static void EvaluateHiddenAttr() - { - IExtendIDefaultInterface extendDefaultInter = new DIMClass(); - extendDefaultInter.HiddenDefaultMethod(); - } - - public static void EvaluateStepThroughAttr() - { - IExtendIDefaultInterface extendDefaultInter = new DIMClass(); - extendDefaultInter.StepThroughDefaultMethod(); - } - - public static void EvaluateNonUserCodeAttr() - { - IExtendIDefaultInterface extendDefaultInter = new DIMClass(); - extendDefaultInter.NonUserCodeDefaultMethod(); - } - - public static void EvaluateStepperBoundaryAttr() - { - IExtendIDefaultInterface extendDefaultInter = new DIMClass(); - extendDefaultInter.NonUserCodeDefaultMethod(extendDefaultInter.BoundaryBp); - } - - public static void EvaluateStatic() - { - IExtendIDefaultInterface.DefaultMethodStatic(); - } - - public static async void EvaluateAsyncStatic() - { - await IExtendIDefaultInterface.DefaultMethodAsyncStatic(); - } - - public static void MethodForCallingFromDIM() - { - string text = "a place for pausing and inspecting DIM"; - } -} -#endregion -public class DebugWithDeletedPdb -{ - public static void Run() - { - var asm = System.Reflection.Assembly.LoadFrom("debugger-test-with-pdb-deleted.dll"); - var myType = asm.GetType("DebuggerTests.ClassWithPdbDeleted"); - var myMethod = myType.GetConstructor(new Type[] { }); - var exc = myMethod.Invoke(new object[]{}); - System.Diagnostics.Debugger.Break(); - } -} - -public class DebugWithoutDebugSymbols -{ - public static void Run() - { - var asm = System.Reflection.Assembly.LoadFrom("debugger-test-without-debug-symbols.dll"); - var myType = asm.GetType("DebuggerTests.ClassWithoutDebugSymbols"); - var myMethod = myType.GetConstructor(new Type[] { }); - var exc = myMethod.Invoke(new object[]{}); - System.Diagnostics.Debugger.Break(); - } -} - -public class AsyncGeneric -{ - public static async void TestAsyncGeneric1Parm() - { - var a = await GetAsyncMethod(10); - Console.WriteLine(a); - } - protected static async System.Threading.Tasks.Task GetAsyncMethod(K parm) - { - await System.Threading.Tasks.Task.Delay(1); - System.Diagnostics.Debugger.Break(); - return parm; - } - - public static async void TestKlassGenericAsyncGeneric() - { - var a = await MyKlass.GetAsyncMethod(10); - Console.WriteLine(a); - } - class MyKlass - { - public static async System.Threading.Tasks.Task GetAsyncMethod(K parm) - { - await System.Threading.Tasks.Task.Delay(1); - System.Diagnostics.Debugger.Break(); - return parm; - } - public static async System.Threading.Tasks.Task GetAsyncMethod2(K parm) - { - await System.Threading.Tasks.Task.Delay(1); - System.Diagnostics.Debugger.Break(); - return parm; - } - } - - public static async void TestKlassGenericAsyncGeneric2() - { - var a = await MyKlass.GetAsyncMethod(10); - Console.WriteLine(a); - } - class MyKlass - { - public static async System.Threading.Tasks.Task GetAsyncMethod(K parm) - { - await System.Threading.Tasks.Task.Delay(1); - System.Diagnostics.Debugger.Break(); - return parm; - } - public static async System.Threading.Tasks.Task GetAsyncMethod2(K parm) - { - await System.Threading.Tasks.Task.Delay(1); - System.Diagnostics.Debugger.Break(); - return parm; - } - public class MyKlassNested - { - public static async System.Threading.Tasks.Task GetAsyncMethod(K parm) - { - await System.Threading.Tasks.Task.Delay(1); - System.Diagnostics.Debugger.Break(); - return parm; - } - } - } - - public static async void TestKlassGenericAsyncGeneric3() - { - var a = await MyKlass.GetAsyncMethod2(10); - Console.WriteLine(a); - } - public static async void TestKlassGenericAsyncGeneric4() - { - var a = await MyKlass.GetAsyncMethod2(10); - Console.WriteLine(a); - } - public static async void TestKlassGenericAsyncGeneric5() - { - var a = await MyKlass.MyKlassNested.GetAsyncMethod('1'); - Console.WriteLine(a); - } - public static async void TestKlassGenericAsyncGeneric6() - { - var a = await MyKlass>.GetAsyncMethod('1'); - Console.WriteLine(a); - } -} - -public class InspectIntPtr -{ - public static void Run() - { - IntPtr myInt = default; - IntPtr myInt2 = new IntPtr(1); - - System.Diagnostics.Debugger.Break(); - } -} - -public partial class HiddenSequencePointTest { - public static void StepOverHiddenSP3() - { - MethodWithHiddenLinesAtTheEnd3(); - System.Diagnostics.Debugger.Break(); - } - public static void MethodWithHiddenLinesAtTheEnd3() - { - Console.WriteLine ($"MethodWithHiddenLinesAtTheEnd"); -#line hidden - Console.WriteLine ($"debugger shouldn't be able to step here"); - } -#line default -} - -public class ClassInheritsFromClassWithoutDebugSymbols : DebuggerTests.ClassWithoutDebugSymbolsToInherit -{ - public static void Run() - { - var myVar = new ClassInheritsFromClassWithoutDebugSymbols(); - myVar.CallMethod(); - } - - public void CallMethod() - { - System.Diagnostics.Debugger.Break(); - } - public int myField2; - public int myField; -} - -[System.Diagnostics.DebuggerNonUserCode] -public class ClassNonUserCodeToInherit -{ - private int propA {get;} - public int propB {get;} - protected int propC {get;} - private int d; - public int e; - protected int f; - private int G - { - get {return f + 1;} - } - private int H => f; - - public ClassNonUserCodeToInherit() - { - propA = 10; - propB = 20; - propC = 30; - d = 40; - e = 50; - f = 60; - Console.WriteLine(propA); - Console.WriteLine(propB); - Console.WriteLine(propC); - Console.WriteLine(d); - Console.WriteLine(e); - Console.WriteLine(f); - } -} - -public class ClassInheritsFromNonUserCodeClass : ClassNonUserCodeToInherit -{ - public static void Run() - { - var myVar = new ClassInheritsFromNonUserCodeClass(); - myVar.CallMethod(); - } - - public void CallMethod() - { - System.Diagnostics.Debugger.Break(); - } - - public int myField2; - public int myField; -} - -public class ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass : DebuggerTests.ClassNonUserCodeToInheritThatInheritsFromNormalClass -{ - public static void Run() - { - var myVar = new ClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass(); - myVar.CallMethod(); - } - - public void CallMethod() - { - System.Diagnostics.Debugger.Break(); - } - - public int myField; -} -public class ReadOnlySpanTest -{ - struct S1 { - internal double d1, d2; - } - - ref struct R1 { - internal ref double d1; // 8 - internal ref object o1; // += sizeof(MonoObject*) - internal object o2; // skip - internal ref S1 s1; //+= instance_size(S1) - internal S1 s2; // skip - public R1(ref double d1, ref object o1, ref S1 s1) { - this.d1 = ref d1; - this.o1 = ref o1; - this.s1 = ref s1; - } - internal double Run() - { - return s1.d1; - } - } - - ref struct R1Sample2 { - public ref double d1; - public R1Sample2(ref double d1) { - this.d1 = ref d1; - } - } - - ref struct R2Sample2 { - R1Sample2 r1; - public R2Sample2 (ref double d1) { - r1 = new R1Sample2 (ref d1); - } - - public void Modify(double newDouble) { - r1.d1 = newDouble; - } - - public double Run() { - return r1.d1; - } - } - - public static void Run() - { - Invoke(new string[] {"TEST"}); - ReadOnlySpan var1 = new ReadOnlySpan(); - System.Diagnostics.Debugger.Break(); - } - public static void Invoke(object[] parameters) - { - CheckArguments(parameters); - } - public static void CheckArguments(ReadOnlySpan parameters) - { - double d1 = 123.0; - object o1 = new String("hi"); - var s1 = new S1(); - s1.d1 = 10; - s1.d2 = 20; - R1 myR1 = new R1(ref d1, ref o1, ref s1); - myR1.o2 = new String("hi"); - myR1.s2 = new S1(); - myR1.s2.d1 = 30; - myR1.s2.d2 = 40; - double xyz = 123.0; - R2Sample2 r2 = new R2Sample2(ref xyz); - xyz = 456.0; - System.Diagnostics.Debugger.Break(); - } -} - -public class ToStringOverridden -{ - class ToStringOverriddenA { - public override string ToString() - { - return "helloToStringOverriddenA"; - } - } - class ToStringOverriddenB: ToStringOverriddenA {} - - class ToStringOverriddenC {} - class ToStringOverriddenD: ToStringOverriddenC - { - public override string ToString() - { - return "helloToStringOverriddenD"; - } - } - - struct ToStringOverriddenE - { - public override string ToString() - { - return "helloToStringOverriddenE"; - } - } - - class ToStringOverriddenF - { - public override string ToString() - { - return "helloToStringOverriddenF"; - } - } - class ToStringOverriddenG: ToStringOverriddenF - { - public override string ToString() - { - return "helloToStringOverriddenG"; - } - } - - class ToStringOverriddenH - { - public override string ToString() - { - return "helloToStringOverriddenH"; - } - public string ToString(bool withParms = true) - { - return "helloToStringOverriddenHWrong"; - } - } - - class ToStringOverriddenI - { - public string ToString(bool withParms = true) - { - return "helloToStringOverriddenIWrong"; - } - } - - struct ToStringOverriddenJ - { - public override string ToString() - { - return "helloToStringOverriddenJ"; - } - public string ToString(bool withParms = true) - { - return "helloToStringOverriddenJWrong"; - } - } - - struct ToStringOverriddenK - { - public string ToString(bool withParms = true) - { - return "helloToStringOverriddenKWrong"; - } - } - - record ToStringOverriddenL - { - public override string ToString() - { - return "helloToStringOverriddenL"; - } - } - - record ToStringOverriddenM - { - public string ToString(bool withParms = true) - { - return "helloToStringOverriddenMWrong"; - } - } - - record ToStringOverriddenN - { - public override string ToString() - { - return "helloToStringOverriddenN"; - } - public string ToString(bool withParms = true) - { - return "helloToStringOverriddenNWrong"; - } - } - - public override string ToString() - { - return "helloToStringOverridden"; - } - public static void Run() - { - var a = new ToStringOverridden(); - var b = new ToStringOverriddenB(); - var c = new ToStringOverriddenD(); - var d = new ToStringOverriddenE(); - ToStringOverriddenA e = new ToStringOverriddenB(); - object f = new ToStringOverriddenB(); - var g = new ToStringOverriddenG(); - var h = new ToStringOverriddenH(); - var i = new ToStringOverriddenI(); - var j = new ToStringOverriddenJ(); - var k = new ToStringOverriddenK(); - var l = new ToStringOverriddenL(); - var m = new ToStringOverriddenM(); - var n = new ToStringOverriddenN(); - System.Diagnostics.Debugger.Break(); - } -} -public class TestLoadSymbols -{ - public static void Run() - { - var array = new Newtonsoft.Json.Linq.JArray(); - var text = new Newtonsoft.Json.Linq.JValue("Manual text"); - var date = new Newtonsoft.Json.Linq.JValue(new DateTime(2000, 5, 23)); - - System.Diagnostics.Debugger.Break(); - - array.Add(text); - array.Add(date); - } -} - -public class MultiThreadedTest -{ - public static void Run() - { - System.Collections.Generic.List myThreads = new(); - for (int i = 0 ; i < 3; i++) - { - var t = new System.Threading.Thread (() => Write("y")); - myThreads.Add(t); - t.Start(); - } - foreach (System.Threading.Thread curThread in myThreads) - { - curThread.Join(); - } - } - static void Write(string input) - { - var currentThread = System.Threading.Thread.CurrentThread.ManagedThreadId; - Console.WriteLine($"Thread:{currentThread} - {input}"); - } -} - -[AttributeUsage(AttributeTargets.Class)] -public sealed class CustomAttribute : Attribute -{ -} - -[Custom] -public class GenericCustomAttributeDecoratedClassInheritsFromClassWithoutDebugSymbols : DebuggerTests.ClassWithoutDebugSymbolsToInherit -{ - public static void Run() - { - var myVar = new GenericCustomAttributeDecoratedClassInheritsFromClassWithoutDebugSymbols(); - myVar.CallMethod(); - } - - public void CallMethod() - { - System.Diagnostics.Debugger.Break(); - } - public int myField2; - public int myField; -} - -[Custom] -public class GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClass : ClassNonUserCodeToInherit -{ - public static void Run() - { - var myVar = new GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClass(); - myVar.CallMethod(); - } - - public void CallMethod() - { - System.Diagnostics.Debugger.Break(); - } - - public int myField2; - public int myField; -} - -[Custom] -public class GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass : DebuggerTests.ClassNonUserCodeToInheritThatInheritsFromNormalClass -{ - public static void Run() - { - var myVar = new GenericCustomAttributeDecoratedClassInheritsFromNonUserCodeClassThatInheritsFromNormalClass(); - myVar.CallMethod(); - } - - public void CallMethod() - { - System.Diagnostics.Debugger.Break(); - } - - public int myField; -} - -namespace DebuggerBreakpointTests -{ - public partial class BreakpointTestsClass - { - public BreakpointTestsClass() - { - // cctr defined in different file than members - int localVar = 123; - } - } - - public class CreateGoodBreakpointAtTheEndOfFileAndHit - { - public static void Run() - { - BreakpointTestsClass bpTest = new(); - } - } -} - -public class SpanByte -{ - public static void Run() - { - System.Span span = new (); - System.Diagnostics.Debugger.Break(); - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj b/src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj deleted file mode 100644 index 64358661431c0f..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-test.csproj +++ /dev/null @@ -1,123 +0,0 @@ - - - true - $(NoWarn);219 - true - false - PrepareForWasmBuildApp;$(WasmBuildAppDependsOn) - true - library - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_AssemblyForDynamicLoading Include="lazy-debugger-test" /> - <_AssemblyForDynamicLoading Include="lazy-debugger-test-chinese-char-in-path-ㄨ" /> - <_AssemblyForDynamicLoading Include="debugger-test-with-full-debug-type" /> - <_AssemblyForDynamicLoading Include="debugger-test-with-pdb-deleted" /> - <_AssemblyForDynamicLoading Include="debugger-test-without-debug-symbols" /> - <_AssemblyForDynamicLoading Include="library-dependency-debugger-test1" /> - <_AssemblyForDynamicLoading Include="library-dependency-debugger-test2" /> - - - - - - - - - - - - - - false - $(AppDir) - - -1 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-test2.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-test2.cs deleted file mode 100644 index f5d5f03e1cf9ab..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-test2.cs +++ /dev/null @@ -1,141 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.Net.Http.Json; - -public class Misc -{ //Only append content to this class as the test suite depends on line info - public static int CreateObject(int foo, int bar) - { - var f = new Fancy() - { - Foo = foo, - Bar = bar, - }; - - Console.WriteLine($"{f.Foo} {f.Bar}"); - return f.Foo + f.Bar; - } -} - -public class Fancy -{ - public int Foo; - public int Bar { get; set; } - public static void Types() - { - double dPI = System.Math.PI; - float fPI = (float)System.Math.PI; - - int iMax = int.MaxValue; - int iMin = int.MinValue; - uint uiMax = uint.MaxValue; - uint uiMin = uint.MinValue; - - long l = uiMax * (long)2; - long lMax = long.MaxValue; // cannot be represented as double - long lMin = long.MinValue; // cannot be represented as double - - sbyte sbMax = sbyte.MaxValue; - sbyte sbMin = sbyte.MinValue; - byte bMax = byte.MaxValue; - byte bMin = byte.MinValue; - - short sMax = short.MaxValue; - short sMin = short.MinValue; - ushort usMin = ushort.MinValue; - ushort usMax = ushort.MaxValue; - - var d = usMin + usMax; - } -} - -public class UserBreak { - public static void BreakOnDebuggerBreakCommand() - { - int a = 10; - Debugger.Break(); - a = 20; - a = 50; - a = 100; - } -} - -public class WeatherForecast -{ - public DateTime Date { get; set; } - - public int TemperatureC { get; set; } - - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - - public string Summary { get; set; } -} - -public class InspectTask -{ - public static async System.Threading.Tasks.Task RunInspectTask() - { - WeatherForecast[] forecasts = null; - var httpClient = new System.Net.Http.HttpClient(); - var getJsonTask = httpClient.GetFromJsonAsync("http://localhost:9400/weather.json"); - try - { - await getJsonTask.ContinueWith(t => - { - int a = 10; - Console.WriteLine(a); - if (t.IsCompletedSuccessfully) - forecasts = t.Result; - - if (t.IsFaulted) - throw t.Exception!; - }); - } - catch (Exception ex) - { - Console.WriteLine($"error {ex}"); - return; - } - } -} - -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 DateTime GetD => new DateTime(2020, 7, 6, 5, 4, 3); - public TestChild() - { - Console.WriteLine("Hi"); - } - public static void TestWatchWithInheritance() - { - TestChild test = new TestChild(); - Debugger.Break(); - } -} - -namespace DebuggerBreakpointTests -{ - public partial class BreakpointTestsClass - { - // Variables with initializers defined in different file than cctr - public int variable1 = 10; - public string variable2 = "Hello"; - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/debugger-test/debugger-valuetypes-test.cs b/src/mono/browser/debugger/tests/debugger-test/debugger-valuetypes-test.cs deleted file mode 100644 index 825634491679e1..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/debugger-valuetypes-test.cs +++ /dev/null @@ -1,267 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -namespace DebuggerTests -{ - public partial class ValueTypesTest - { //Only append content to this class as the test suite depends on line info - - [System.Runtime.InteropServices.JavaScript.JSExport] public static void MethodWithLocalStructs() - { - var ss_local = new SimpleStruct("set in MethodWithLocalStructs", 1, DateTimeKind.Utc); - var gs_local = new GenericStruct { StringField = $"gs_local#GenericStruct#StringField" }; - - ValueTypesTest vt_local = new ValueTypesTest - { - StringField = "string#0", - SimpleStructField = new SimpleStruct("SimpleStructField#string#0", 5, DateTimeKind.Local), - SimpleStructProperty = new SimpleStruct("SimpleStructProperty#string#0", 2, DateTimeKind.Utc), - DT = new DateTime(2020, 1, 2, 3, 4, 5), - RGB = RGB.Blue - }; - Console.WriteLine($"Using the struct: {ss_local.gs.StringField}, gs: {gs_local.StringField}, {vt_local.StringField}"); - } - - public static void TestStructsAsMethodArgs() - { - var ss_local = new SimpleStruct("ss_local#SimpleStruct#string#0", 5, DateTimeKind.Local); - var ss_ret = MethodWithStructArgs("TestStructsAsMethodArgs#label", ss_local, 3); - Console.WriteLine($"got back ss_local: {ss_local.gs.StringField}, ss_ret: {ss_ret.gs.StringField}"); - } - - static SimpleStruct MethodWithStructArgs(string label, SimpleStruct ss_arg, int x) - { - Console.WriteLine($"- ss_arg: {ss_arg.str_member}"); - ss_arg.Kind = DateTimeKind.Utc; - ss_arg.str_member = $"ValueTypesTest#MethodWithStructArgs#updated#ss_arg#str_member"; - ss_arg.gs.StringField = $"ValueTypesTest#MethodWithStructArgs#updated#gs#StringField#{x}"; - return ss_arg; - } - - public static async Task MethodWithLocalStructsStaticAsync() - { - var ss_local = new SimpleStruct("set in MethodWithLocalStructsStaticAsync", 1, DateTimeKind.Utc); - var gs_local = new GenericStruct - { - StringField = "gs_local#GenericStruct#StringField", - List = new System.Collections.Generic.List { 5, 3 }, - Options = Options.Option2 - - }; - - var result = await ss_local.AsyncMethodWithStructArgs(gs_local); - Console.WriteLine($"Using the struct: {ss_local.gs.StringField}, result: {result}"); - - return result; - } - - public string StringField; - public SimpleStruct SimpleStructProperty { get; set; } - public SimpleStruct SimpleStructField; - - public struct SimpleStruct - { - public uint V { get { return 0xDEADBEEF + (uint)dt.Month; } set { } } - public string str_member; - public DateTime dt; - public GenericStruct gs; - public DateTimeKind Kind; - - public SimpleStruct(string str, int f, DateTimeKind kind) - { - str_member = $"{str}#SimpleStruct#str_member"; - dt = new DateTime(2020 + f, 1 + f, 2 + f, 3 + f, 5 + f, 6 + f); - gs = new GenericStruct - { - StringField = $"{str}#SimpleStruct#gs#StringField", - List = new System.Collections.Generic.List { new DateTime(2010 + f, 2 + f, 3 + f, 10 + f, 2 + f, 3 + f) }, - Options = Options.Option1 - }; - Kind = kind; - } - - public Task AsyncMethodWithStructArgs(GenericStruct gs) - { - Console.WriteLine($"placeholder line for a breakpoint"); - if (gs.List.Count > 0) - return Task.FromResult(true); - - return Task.FromResult(false); - } - } - - public struct GenericStruct - { - public System.Collections.Generic.List List; - public string StringField; - - public Options Options { get; set; } - } - - public DateTime DT { get; set; } - public RGB RGB; - - public static void MethodWithLocalsForToStringTest(bool call_other) - { - var dt0 = new DateTime(2020, 1, 2, 3, 4, 5); - var dt1 = new DateTime(2010, 5, 4, 3, 2, 1); - var ts = dt0 - dt1; - var dto = new DateTimeOffset(dt0, new TimeSpan(4, 5, 0)); - decimal dec = 123987123; - var guid = new Guid("3d36e07e-ac90-48c6-b7ec-a481e289d014"); - - var dts = new DateTime[] - { - new DateTime(1983, 6, 7, 5, 6, 10), - new DateTime(1999, 10, 15, 1, 2, 3) - }; - - var obj = new ClassForToStringTests - { - DT = new DateTime(2004, 10, 15, 1, 2, 3), - DTO = new DateTimeOffset(dt0, new TimeSpan(2, 14, 0)), - TS = ts, - Dec = 1239871, - Guid = guid - }; - - var sst = new StructForToStringTests - { - DT = new DateTime(2004, 10, 15, 1, 2, 3), - DTO = new DateTimeOffset(dt0, new TimeSpan(3, 15, 0)), - TS = ts, - Dec = 1239871, - Guid = guid - }; - Console.WriteLine($"MethodWithLocalsForToStringTest: {dt0}, {dt1}, {ts}, {dec}, {guid}, {dts[0]}, {obj.DT}, {sst.DT}"); - if (call_other) - MethodWithArgumentsForToStringTest(call_other, dt0, dt1, ts, dto, dec, guid, dts, obj, sst); - } - - static void MethodWithArgumentsForToStringTest( - bool call_other, // not really used, just to help with using common code in the tests - DateTime dt0, DateTime dt1, TimeSpan ts, DateTimeOffset dto, decimal dec, - Guid guid, DateTime[] dts, ClassForToStringTests obj, StructForToStringTests sst) - { - Console.WriteLine($"MethodWithArgumentsForToStringTest: {dt0}, {dt1}, {ts}, {dec}, {guid}, {dts[0]}, {obj.DT}, {sst.DT}"); - } - - public static async Task MethodWithLocalsForToStringTestAsync(bool call_other) - { - var dt0 = new DateTime(2020, 1, 2, 3, 4, 5); - var dt1 = new DateTime(2010, 5, 4, 3, 2, 1); - var ts = dt0 - dt1; - var dto = new DateTimeOffset(dt0, new TimeSpan(4, 5, 0)); - decimal dec = 123987123; - var guid = new Guid("3d36e07e-ac90-48c6-b7ec-a481e289d014"); - - var dts = new DateTime[] - { - new DateTime(1983, 6, 7, 5, 6, 10), - new DateTime(1999, 10, 15, 1, 2, 3) - }; - - var obj = new ClassForToStringTests - { - DT = new DateTime(2004, 10, 15, 1, 2, 3), - DTO = new DateTimeOffset(dt0, new TimeSpan(2, 14, 0)), - TS = ts, - Dec = 1239871, - Guid = guid - }; - - var sst = new StructForToStringTests - { - DT = new DateTime(2004, 10, 15, 1, 2, 3), - DTO = new DateTimeOffset(dt0, new TimeSpan(3, 15, 0)), - TS = ts, - Dec = 1239871, - Guid = guid - }; - Console.WriteLine($"MethodWithLocalsForToStringTest: {dt0}, {dt1}, {ts}, {dec}, {guid}, {dts[0]}, {obj.DT}, {sst.DT}"); - if (call_other) - await MethodWithArgumentsForToStringTestAsync(call_other, dt0, dt1, ts, dto, dec, guid, dts, obj, sst); - } - - static async Task MethodWithArgumentsForToStringTestAsync( - bool call_other, // not really used, just to help with using common code in the tests - DateTime dt0, DateTime dt1, TimeSpan ts, DateTimeOffset dto, decimal dec, - Guid guid, DateTime[] dts, ClassForToStringTests obj, StructForToStringTests sst) - { - Console.WriteLine($"MethodWithArgumentsForToStringTest: {dt0}, {dt1}, {ts}, {dec}, {guid}, {dts[0]}, {obj.DT}, {sst.DT}"); await Task.CompletedTask; - } - - public static void MethodUpdatingValueTypeMembers() - { - var obj = new ClassForToStringTests - { - DT = new DateTime(1, 2, 3, 4, 5, 6) - }; - var vt = new StructForToStringTests - { - DT = new DateTime(4, 5, 6, 7, 8, 9) - }; - Console.WriteLine($"#1"); - obj.DT = new DateTime(9, 8, 7, 6, 5, 4); - vt.DT = new DateTime(5, 1, 3, 7, 9, 10); - Console.WriteLine($"#2"); - } - - public static async Task MethodUpdatingValueTypeLocalsAsync() - { - var dt = new DateTime(1, 2, 3, 4, 5, 6); - Console.WriteLine($"#1"); - dt = new DateTime(9, 8, 7, 6, 5, 4); - Console.WriteLine($"#2"); await Task.CompletedTask; - } - - public static void MethodUpdatingVTArrayMembers() - { - var ssta = new[] - { - new StructForToStringTests { DT = new DateTime(1, 2, 3, 4, 5, 6) } - }; - Console.WriteLine($"#1"); - ssta[0].DT = new DateTime(9, 8, 7, 6, 5, 4); - Console.WriteLine($"#2"); - } - } - - class ClassForToStringTests - { - public DateTime DT; - public DateTimeOffset DTO; - public TimeSpan TS; - public decimal Dec; - public Guid Guid; - } - - struct StructForToStringTests - { - public DateTime DT; - public DateTimeOffset DTO; - public TimeSpan TS; - public decimal Dec; - public Guid Guid; - } - - public enum RGB - { - Red, - Green, - Blue - } - - [Flags] - public enum Options - { - None = 0, - Option1 = 1, - Option2 = 2, - Option3 = 4, - - All = Option1 | Option3 - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/dependency.cs b/src/mono/browser/debugger/tests/debugger-test/dependency.cs deleted file mode 100644 index 16508eb6f89e2c..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/dependency.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Simple -{ - public class Complex - { - public int A { get; set; } - public string B { get; set; } - object c; - public int d; - - public Complex(int a, string b) - { - A = a; - B = b; - this.c = this; - d = 15; - } - - public int DoStuff() - { - return DoOtherStuff(); - } - - public int DoOtherStuff() - { - return DoEvenMoreStuff() - 1; - } - - public int DoEvenMoreStuff() - { - return 1 + BreakOnThisMethod(); - } - - public int BreakOnThisMethod() - { - var x = A + 10; - c = $"{x}_{B}"; - - return x; - } - } -} diff --git a/src/mono/browser/debugger/tests/debugger-test/non-wasm-page.html b/src/mono/browser/debugger/tests/debugger-test/non-wasm-page.html deleted file mode 100644 index 1442fc9b6af961..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/non-wasm-page.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/src/mono/browser/debugger/tests/debugger-test/other.js b/src/mono/browser/debugger/tests/debugger-test/other.js deleted file mode 100644 index 0dc37939a9ff07..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/other.js +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -"use strict"; - -function big_array_js_test (len) { - const big = new Array(len); - for (let i=0; i < len; i ++) { - big[i]=i + 1000; - } - console.log('break here'); -}; - -function object_js_test () { - const obj = { - a_obj: { aa: 5, ab: 'foo' }, - b_arr: [ 10, 12 ] - }; - - return obj; -}; - -function getters_js_test () { - const ptd = { - get Int () { return 5; }, - get String () { return "foobar"; }, - get DT () { return "dt"; }, - get IntArray () { return [1,2,3]; }, - get DTArray () { return ["dt0", "dt1"]; }, - DTAutoProperty: "dt", - StringField: "string field value" - }; - console.log (`break here`); - return ptd; -} - -function exception_caught_test () { - try { - throw new TypeError ('exception caught'); - } catch (e) { - console.log(e); - } -} - -function exception_uncaught_test () { - console.log('uncaught test'); - throw new RangeError ('exception uncaught'); -} - -function exceptions_test () { - exception_caught_test (); - exception_uncaught_test (); -} - -function negative_cfo_test (str_value = null) { - const ptd = { - get Int () { return 5; }, - get String () { return "foobar"; }, - get DT () { return "dt"; }, - get IntArray () { return [1,2,3]; }, - get DTArray () { return ["dt0", "dt1"]; }, - DTAutoProperty: "dt", - StringField: str_value - }; - console.log (`break here`); - return ptd; -} - -function eval_call_on_frame_test () { - let obj = { - a: 5, - b: "hello", - c: { - c_x: 1 - }, - }; - - let obj_undefined = undefined; - console.log(`break here`); -} - -function get_properties_test () { - let vehicle = { - kind: "car", - make: "mini", - get available () { return true; } - }; - - let obj = { - owner_name: "foo", - get owner_last_name () { return "bar"; }, - } - // obj.prototype.this_vehicle = vehicle; - Object.setPrototypeOf(obj, vehicle); - - console.log(`break here`); -} - -function malloc_to_reallocate_test () { - //need to allocate this buffer size to force wasm linear memory to grow - const _debugger_buffer = Module._malloc(4500000); - Module._free(_debugger_buffer); -} diff --git a/src/mono/browser/debugger/tests/debugger-test/wasm-page-without-assets.html b/src/mono/browser/debugger/tests/debugger-test/wasm-page-without-assets.html deleted file mode 100644 index 9fcdbf4570c1ee..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/wasm-page-without-assets.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - Stuff goes here - - - \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/debugger-test/weather.json b/src/mono/browser/debugger/tests/debugger-test/weather.json deleted file mode 100644 index e1ca33d0beb843..00000000000000 --- a/src/mono/browser/debugger/tests/debugger-test/weather.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "dateFormatted": "06/05/2018", - "temperatureC": 1, - "summary": "Freezing", - "temperatureF": 33 - }, - { - "dateFormatted": "07/05/2018", - "temperatureC": 14, - "summary": "Bracing", - "temperatureF": 57 - }, - { - "dateFormatted": "08/05/2018", - "temperatureC": -13, - "summary": "Freezing", - "temperatureF": 9 - }, - { - "dateFormatted": "09/05/2018", - "temperatureC": -16, - "summary": "Balmy", - "temperatureF": 4 - }, - { - "dateFormatted": "10/05/2018", - "temperatureC": -2, - "summary": "Chilly", - "temperatureF": 29 - } -] diff --git "a/src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test-chinese-char-in-path-\343\204\250.csproj" "b/src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test-chinese-char-in-path-\343\204\250.csproj" deleted file mode 100644 index 35e3d8428b7cfc..00000000000000 --- "a/src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test-chinese-char-in-path-\343\204\250.csproj" +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git "a/src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test.cs" "b/src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test.cs" deleted file mode 100644 index 2da3c708e85acb..00000000000000 --- "a/src/mono/browser/debugger/tests/lazy-debugger-test-chinese-char-in-path-\343\204\250/lazy-debugger-test.cs" +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -public partial class LazyMath -{ - public static int IntAdd(int a, int b) - { - int c = a + b; - return c; - } -} - -namespace DebuggerTests -{ - public class ClassToCheckFieldValue - { - public int valueToCheck; - public ClassToCheckFieldValue() - { - valueToCheck = 20; - } - } -} diff --git a/src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.cs b/src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.cs deleted file mode 100644 index 203f5353092f57..00000000000000 --- a/src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -public partial class LazyMath -{ - public static int IntAdd(int a, int b) - { - int c = a + b; - return c; - } -} \ No newline at end of file diff --git a/src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.csproj b/src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.csproj deleted file mode 100644 index 8b32648c2c4303..00000000000000 --- a/src/mono/browser/debugger/tests/lazy-debugger-test-embedded/lazy-debugger-test-embedded.csproj +++ /dev/null @@ -1,5 +0,0 @@ - - - embedded - - diff --git a/src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.cs b/src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.cs deleted file mode 100644 index 2da3c708e85acb..00000000000000 --- a/src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -public partial class LazyMath -{ - public static int IntAdd(int a, int b) - { - int c = a + b; - return c; - } -} - -namespace DebuggerTests -{ - public class ClassToCheckFieldValue - { - public int valueToCheck; - public ClassToCheckFieldValue() - { - valueToCheck = 20; - } - } -} diff --git a/src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.csproj b/src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.csproj deleted file mode 100644 index 35e3d8428b7cfc..00000000000000 --- a/src/mono/browser/debugger/tests/lazy-debugger-test/lazy-debugger-test.csproj +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.cs b/src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.cs deleted file mode 100644 index 82d1120504b976..00000000000000 --- a/src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -using System; -public class TestDependency -{ - public static int IntAdd(int a, int b) - { - System.Console.WriteLine("rodei o intadd"); - int c = a + b; - return c; - } -} -public class SomeAttribute : Attribute -{ - public SomeAttribute(SomeEnum something) - { - Something = something; - } - - public SomeEnum Something { get; } -} - -[Some(SomeEnum.Something)] // <-- comment this to make blazor WASM debugging work -public class SomeClass -{ - -} diff --git a/src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.csproj b/src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.csproj deleted file mode 100644 index 21b5134996ce52..00000000000000 --- a/src/mono/browser/debugger/tests/library-dependency-debugger-test1/library-dependency-debugger-test1.csproj +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.cs b/src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.cs deleted file mode 100644 index 4c519c54b249d5..00000000000000 --- a/src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -public enum SomeEnum -{ - Something -} - diff --git a/src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.csproj b/src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.csproj deleted file mode 100644 index 35e3d8428b7cfc..00000000000000 --- a/src/mono/browser/debugger/tests/library-dependency-debugger-test2/library-dependency-debugger-test2.csproj +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/mono/wasi/Makefile b/src/mono/wasi/Makefile index e8e8cc051cbb5b..d533be06d0793d 100644 --- a/src/mono/wasi/Makefile +++ b/src/mono/wasi/Makefile @@ -67,12 +67,6 @@ run-tests-%: run-build-tests: WASI_SDK_PATH=$(WASI_SDK_PATH) $(DOTNET) build $(TOP)/src/mono/wasi//Wasi.Build.Tests/ /t:Test /bl $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS) -build-debugger-tests-helix: - $(DOTNET) build -restore -bl:$(TOP)/artifacts/log/$(CONFIG)/Wasm.Debugger.Tests.binlog \ - /p:ContinuousIntegrationBuild=true /p:ArchiveTests=true \ - $(TOP)/src/mono/browser/debugger/Wasm.Debugger.Tests/Wasm.Debugger.Tests.csproj \ - $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS) - submit-wbt-helix: PATH="$(JSVU):$(PATH)" \ $(DOTNET) build $(TOP)/src/mono/wasi/Wasi.Build.Tests/ /v:m /p:ArchiveTests=true /t:ArchiveTests $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS) && \ @@ -95,17 +89,7 @@ submit-tests-helix: $(_MSBUILD_WASM_BUILD_ARGS) \ $(MSBUILD_ARGS) -run-debugger-tests: - rm -f $(TOP)/artifacts/bin/DebuggerTestSuite/x64/Debug/*log; \ - if [ ! -z "$(TEST_FILTER)" ]; then \ - $(DOTNET) test $(TOP)/src/mono/browser/debugger/DebuggerTestSuite $(MSBUILD_ARGS) "-l:trx;LogFileName=DebuggerTestsResults.xml" --results-directory $(TOP)/artifacts/log/$(CONFIG) --filter "category!=failing&FullyQualifiedName$(TEST_FILTER)" $(TEST_ARGS); \ - else \ - $(DOTNET) test $(TOP)/src/mono/browser/debugger/DebuggerTestSuite $(MSBUILD_ARGS) "-l:trx;LogFileName=DebuggerTestsResults.xml" --results-directory $(TOP)/artifacts/log/$(CONFIG) --filter "category!=failing" $(TEST_ARGS); \ - fi - build-dbg-proxy: $(DOTNET) build $(TOP)/src/mono/browser/debugger/wasiDebugHost $(MSBUILD_ARGS) -build-dbg-testsuite: - $(DOTNET) build $(TOP)/src/mono/browser/debugger/DebuggerTestSuite $(MSBUILD_ARGS) build-app-host: $(DOTNET) build $(TOP)/src/mono/wasm/host $(_MSBUILD_WASM_BUILD_ARGS) $(MSBUILD_ARGS) diff --git a/src/mono/wasm/sln/WasmBuild.sln b/src/mono/wasm/sln/WasmBuild.sln index 48bbfe555ab42b..6f0028e6ec28a4 100755 --- a/src/mono/wasm/sln/WasmBuild.sln +++ b/src/mono/wasm/sln/WasmBuild.sln @@ -11,18 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoAOTCompiler", "..\..\.. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasm.Build.Tests", "..\Wasm.Build.Tests\Wasm.Build.Tests.csproj", "{94E18644-B0E5-4DBB-9CE4-EA1515ACE4C2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DebuggerTestSuite", "..\..\browser\debugger\DebuggerTestSuite\DebuggerTestSuite.csproj", "{4C0EE027-FC30-4167-B2CF-A6D18F00E08F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserDebugHost", "..\..\browser\debugger\BrowserDebugHost\BrowserDebugHost.csproj", "{292A88FD-795F-467A-8801-B5B791CEF96E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BrowserDebugProxy", "..\..\browser\debugger\BrowserDebugProxy\BrowserDebugProxy.csproj", "{F5AE2AF5-3C30-45E3-A0C6-D962C51FE5E7}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WasmAppHost", "..\host\WasmAppHost.csproj", "{C7099764-EC2E-4FAF-9057-0321893DE4F8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WasmSymbolicator", "..\symbolicator\WasmSymbolicator.csproj", "{ABC41254-EC2E-4FAF-9057-091ABF4DE4F8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplyUpdateReferencedAssembly", "..\..\browser\debugger\tests\ApplyUpdateReferencedAssembly\ApplyUpdateReferencedAssembly.csproj", "{75477B6F-DC8E-4002-88B8-017C992C568E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.NET.Sdk.WebAssembly.Pack.Tasks", "..\..\..\tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj", "{5EEC2925-2021-4830-B7E9-72BB8B2C283D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wasi.Build.Tests", "..\..\wasi\Wasi.Build.Tests\Wasi.Build.Tests.csproj", "{3A3AEAE5-0110-45D3-89B0-B82AC430535C}" diff --git a/src/mono/wasm/threads.md b/src/mono/wasm/threads.md index 705cc89f8fa60a..798f03518efb23 100644 --- a/src/mono/wasm/threads.md +++ b/src/mono/wasm/threads.md @@ -68,13 +68,6 @@ The runtime has a number of tasks that are scheduled with `mono_main_thread_sche The background tasks will run on the main thread. Calling `mono_main_thread_schedule_background_job` on a worker thread will use `async_run_in_main_thread` to queue up work for the main thread. -## Debugger tests ## - -To run the debugger tests in the runtime [built with enabled support for multi-threading](#building-the-runtime) we use: -``` -dotnet test src/mono/browser/debugger/DebuggerTestSuite -e RuntimeConfiguration=Debug -e Configuration=Debug -e DebuggerHost=chrome -e WasmEnableThreads=true -``` - ## JS interop on dedicated threads ## FIXME: better documentation, better public API. The JavaScript objects have thread (web worker) affinity. You can't use DOM, WebSocket or their promises on any other web worker than the original one.