Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor WASM hot reload and debugging #28953

Merged
merged 10 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion aspnetcore/blazor/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,34 @@ uid: blazor/debug

This article describes how to debug Blazor WebAssembly with browser developer tools and an integrated development environment (IDE).

:::moniker range=">= aspnetcore-7.0"
:::moniker range=">= aspnetcore-8.0"

Blazor WebAssembly apps can be debugged using the browser developer tools in Chromium-based browsers (Edge/Chrome) and Firefox. You can also debug your app using the following IDEs:

* Visual Studio
* Visual Studio for Mac
* Visual Studio Code

Available scenarios 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.
* Use a [symbol server](xref:test/debug-aspnetcore-source) for debugging.

For now, you *can't*:

* Break on unhandled exceptions.
* Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in `Program.cs` 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/)).
* Automatically rebuild the backend **:::no-loc text="Server":::** app of a hosted Blazor WebAssembly [solution](xref:blazor/tooling#visual-studio-solution-file-sln) during debugging, for example by running the app with [`dotnet watch run`](xref:tutorials/dotnet-watch).

:::moniker-end

:::moniker range=">= aspnetcore-7.0 < aspnetcore-8.0"

Blazor WebAssembly apps can be debugged using the browser developer tools in Chromium-based browsers (Edge/Chrome). You can also debug your app using the following IDEs:

Expand All @@ -37,6 +64,11 @@ For now, you *can't*:
* Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in `Program.cs` 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/)).
* Automatically rebuild the backend **:::no-loc text="Server":::** app of a hosted Blazor WebAssembly [solution](xref:blazor/tooling#visual-studio-solution-file-sln) during debugging, for example by running the app with [`dotnet watch run`](xref:tutorials/dotnet-watch).
* Use a [symbol server](xref:test/debug-aspnetcore-source) for debugging.

:::moniker-end

:::moniker range=">= aspnetcore-7.0"

## Prerequisites

Expand Down Expand Up @@ -833,6 +865,7 @@ For now, you *can't*:
* Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in `Program.cs` 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/)).
* Automatically rebuild the backend **:::no-loc text="Server":::** app of a hosted Blazor WebAssembly [solution](xref:blazor/tooling#visual-studio-solution-file-sln) during debugging, for example by running the app with [`dotnet watch run`](xref:tutorials/dotnet-watch).
* Use a [symbol server](xref:test/debug-aspnetcore-source) for debugging.

## Prerequisites

Expand Down Expand Up @@ -1284,6 +1317,7 @@ For now, you *can't*:
* Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in `Program.cs` 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/)).
* Automatically rebuild the backend **:::no-loc text="Server":::** app of a hosted Blazor WebAssembly [solution](xref:blazor/tooling#visual-studio-solution-file-sln) during debugging, for example by running the app with [`dotnet watch run`](xref:tutorials/dotnet-watch).
* Use a [symbol server](xref:test/debug-aspnetcore-source) for debugging.

## Prerequisites

Expand Down
29 changes: 26 additions & 3 deletions aspnetcore/test/hot-reload.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For more information on supported scenarios, see [Supported code changes (C# and

## Blazor WebAssembly

::: moniker range=">= aspnetcore-7.0"
::: moniker range=">= aspnetcore-8.0"

Blazor WebAssembly Hot Reload supports the following code changes:

Expand All @@ -35,7 +35,7 @@ Blazor WebAssembly Hot Reload supports the following code changes:
* Most changes to method bodies, such as adding, removing, and editing variables, expressions, and statements.
* Changes to the bodies of [lambda expressions](/dotnet/csharp/language-reference/operators/lambda-expressions) and [local functions](/dotnet/csharp/programming-guide/classes-and-structs/local-functions).
* Adding static and instance methods to existing types.
* Adding static fields and methods to existing types.
* Adding static and instance fields, events, and properties to existing types.
* Adding static lambdas to existing methods.
* Adding lambdas that capture `this` to existing methods that already captured `this` previously.

Expand All @@ -45,7 +45,29 @@ The following code changes aren't supported for Blazor WebAssembly apps:

* Adding a new [`await` operator](/dotnet/csharp/language-reference/operators/await) or [`yield` keyword](/dotnet/csharp/language-reference/keywords/yield) expression.
* Changing the names of method parameters.
* Adding new non-`static` fields, events, or properties

::: moniker-end

::: moniker range=">= aspnetcore-7.0 < aspnetcore-8.0"

Blazor WebAssembly Hot Reload supports the following code changes:

* New types.
* Nested classes.
* Most changes to method bodies, such as adding, removing, and editing variables, expressions, and statements.
* Changes to the bodies of [lambda expressions](/dotnet/csharp/language-reference/operators/lambda-expressions) and [local functions](/dotnet/csharp/programming-guide/classes-and-structs/local-functions).
* Adding static and instance methods to existing types.
* Adding static fields to existing types.
* Adding static lambdas to existing methods.
* Adding lambdas that capture `this` to existing methods that already captured `this` previously.

Note that when an attribute is removed that previously set the value of a component parameter, the component is disposed and re-initialized to set the removed parameter back to its default value.

The following code changes aren't supported for Blazor WebAssembly apps:

* Adding a new [`await` operator](/dotnet/csharp/language-reference/operators/await) or [`yield` keyword](/dotnet/csharp/language-reference/keywords/yield) expression.
* Changing the names of method parameters.
* Adding instance (non-`static`) fields, events, or properties.

::: moniker-end

Expand All @@ -62,6 +84,7 @@ The following code changes aren't supported for Blazor WebAssembly apps:
* Adding a new [`await` operator](/dotnet/csharp/language-reference/operators/await) or [`yield` keyword](/dotnet/csharp/language-reference/keywords/yield) expression.
* Changing the names of method parameters.
* Changes outside of method bodies.
* Adding instance (non-`static`) fields, events, or properties.

::: moniker-end

Expand Down