From 56edefa3f1b3972513e5a7b3a5ba34c528c672f9 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Fri, 3 Nov 2023 14:42:16 -0400 Subject: [PATCH] WASM debug scenario update (#30849) --- aspnetcore/blazor/debug.md | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/aspnetcore/blazor/debug.md b/aspnetcore/blazor/debug.md index 7ff864ff53..cfa944a6dd 100644 --- a/aspnetcore/blazor/debug.md +++ b/aspnetcore/blazor/debug.md @@ -35,14 +35,12 @@ Available scenarios for Blazor WebAssembly debugging include: Unsupported scenarios include: -* Break on unhandled exceptions. -* Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app. * Debug in non-local scenarios (for example, [Windows Subsystem for Linux (WSL)](/windows/wsl/) or [Visual Studio Codespaces](https://visualstudio.microsoft.com/services/github-codespaces/)). * Debug in Firefox from Visual Studio or Visual Studio Code. :::moniker-end -:::moniker range="< aspnetcore-8.0" +:::moniker range=">= aspnetcore-6.0 < aspnetcore-8.0" Blazor Server apps can be debugged in an IDE, Visual Studio or Visual Studio Code. @@ -59,10 +57,28 @@ Unsupported scenarios for Blazor WebAssembly apps include: * Resume code execution with a keyboard shortcut in IDEs. * In the *Locals* window, observe the values of local variables. * See the call stack, including call chains between JavaScript and .NET. +* Debug in non-local scenarios (for example, [Windows Subsystem for Linux (WSL)](/windows/wsl/) or [Visual Studio Codespaces](https://visualstudio.microsoft.com/services/github-codespaces/)). +* Use a [symbol server](xref:test/debug-aspnetcore-source) for debugging. -For now, you *can't*: +:::moniker-end -* Break on unhandled exceptions. +:::moniker range="< aspnetcore-6.0" + +Blazor Server apps can be debugged in an IDE, Visual Studio or Visual Studio Code. + +Blazor WebAssembly apps can be debugged: + +* In an IDE, Visual Studio or Visual Studio Code. +* Using browser developer tools in Chromium-based browsers, including Microsoft Edge and Google Chrome. + +Unsupported scenarios for Blazor WebAssembly apps include: + +* Set and remove breakpoints. +* Run the app with debugging support in IDEs. +* Single-step through the code. +* Resume code execution with a keyboard shortcut in IDEs. +* In the *Locals* window, observe the values of local variables. +* See the call stack, including call chains between JavaScript and .NET. * Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app. * Debug in non-local scenarios (for example, [Windows Subsystem for Linux (WSL)](/windows/wsl/) or [Visual Studio Codespaces](https://visualstudio.microsoft.com/services/github-codespaces/)). * Use a [symbol server](xref:test/debug-aspnetcore-source) for debugging. @@ -493,6 +509,17 @@ To debug a Blazor WebAssembly app in Firefox during development: :::moniker-end +## Break on unhandled exceptions + +The debugger doesn't break on unhandled exceptions by default because Blazor catches exceptions that are unhandled by developer code. + +To break on unhandled exceptions: + +* Open the debugger's exception settings (**Debug** > **Windows** > **Exception Settings**) in Visual Studio. +* Set the following **JavaScript Exceptions** settings: + * **All Exceptions** + * **Uncaught Exceptions** + ## Browser source maps Browser source maps allow the browser to map compiled files back to their original source files and are commonly used for client-side debugging. However, Blazor doesn't currently map C# directly to JavaScript/WASM. Instead, Blazor does IL interpretation within the browser, so source maps aren't relevant.