News

Blazor WebAssembly Marches On to GA: Now Debug from Visual Studio, VS Code

Planning for a May 2020 debut of client-side Blazor, Microsoft released preview 3 of Blazor WebAssembly 3.2, which lets developers debug projects from Visual Studio or Visual Studio Code rather than browser-based development tools.

The client-side started out using the then-experimental WebAssembly for compilation of C# code so it can be used in browser/web development and ran into problems, so it has lagged behind the server-side effort (Blazor Server shipped with .NET Core 3.1 in December 2019) as Microsoft seeks to unity the whole ecosystem with .NET 5, coming in November.

To prepare for that huge milestone, the company has issued a series of previews in which Blazor WebAssembly gets loads of new features and functionality, and debugging support is a big step.

"You can now debug Blazor WebAssembly apps directly from Visual Studio and Visual Studio Code," said Daniel Roth, principal program manager, ASP.NET, in a March 26 blog post. "You can set breakpoints, inspect locals, and step through your code. You can also simultaneously debug your Blazor WebAssembly app and any .NET code running on the server. Using the browser dev tools to debug your Blazor WebAssembly apps is also still supported."

Roth provides instructions on how to first enable such debugging with a tweak to the launchSettings.json settings, along with how to get started in Visual Studio and VS Code.

Note that with this initial support, many debugging features are missing:

  • Inspecting arrays
  • Hovering to inspect members
  • Step debugging into or out of managed code
  • Full support for inspecting value types
  • Breaking on unhandled exceptions
  • Hitting breakpoints during app startup
  • Debugging an app with a service worker

The third preview also sports several other new features, including:

  • Auto-rebuild in Visual Studio: Auto-rebuild support for Blazor WebAssembly projects and Razor Class Libraries comes with Visual Studio 2019 16.6, which monitors file changes in .cs and .razor files and automatically rebuilds and restarts the app so the changes can be seen by simply refreshing the browser. So developers no longer need to manually rebuild and restart an app when making code changes, just refresh the browser.
  • Configuration: Developers can now load configuration data from appsettings.json and environment-specific configuration data from appsettings.{environment}.json.
  • New HttpClient extension methods for JSON handling: These will replace existing helper methods in the Microsoft.AspNetCore.Blazor.HttpClient package, using System.Text.Json for JSON serialization and deserialization. Even though the Blazor WebAssembly template doesn't use them by default yet, developers can leverage them by tweak that include substituting one package for another.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube