News

Hot Reload Hits .NET (Kinda)

Much-requested and long-awaited Hot Reload functionality has hit .NET, supported in an early, incomplete form in the new Visual Studio 2019 version 16.11 (Preview 1).

Announced at the beginning of Microsoft's Build 2021 developer conference, Hot Reload has been a longstanding feature for projects like Blazor and Xamarin, coming late for the latter, after other dev frameworks like Flutter and React Native.

Hot Reload will eventually enable developers to make code changes while debugging that are instantly reflected in a running app without need of a restart, as part of a "Hot Reload Everywhere" push.

Today (May 25), Hot Reload for .NET proper was announced. "With Hot Reload you can now modify your apps managed source code while the application is running, without the need to manually pause or hit a breakpoint. Simply make a supported change while your app is running and in our new Visual Studio experience use the 'apply code changes' button to apply your edits."

In addition to being supported in VS 2019 v16.11 (Preview 1), it can be implemented with the dotnet watch command-line tool (with this reporter actually getting it to work last month with .NET 6 Preview 3).

Blazor Hot Reload in Animated Action
[Click on image for larger, animated GIF view.] Blazor Hot Reload in Animated Action (source: Microsoft).

Here's how it looks now:

Blazor Hot Reload in Animated Action
[Click on image for larger, animated GIF view.] New Hot Reload in Animated Action (source: Microsoft).

However, as noted, full functionality won't come until .NET 6 (coming in November) and Visual Studio 2022, of which we received a sneak peek last month, but for which we are still awaiting the first preview, coming this summer.

"With today's release this is just a preview of our full vision of Hot Reload for .NET developers," Microsoft said. "While some capability is being made available in early .NET 6 previews and in Visual Studio 2019, for the full power of this feature we are targeting .NET 6 (and future releases of .NET) and Visual Studio 2022 as the set of frameworks and tooling that will have the most complete and optimized experience."

For now, developers can expect some glitches and incomplete support and documentation. For example, Microsoft said it's still working to document what types of edits are supported.

Eventually, though, Microsoft said the final product's features will include:

  • .NET Multi-platform App UI (.NET MAUI): With .NET 6 Preview 4 developers building .NET MAUI applications can now use .NET Hot Reload with projects targeting WinUI 3. In future releases we're bringing .NET Hot Reload support to iOS, Android, and Mac Catalyst scenarios.
  • Razor Pages: In future releases Hot Reload and Edit and Continue (EnC) will be supported for editing Razor for websites or Blazor apps targeting .NET 6 or higher
  • No Debugger Required in Visual Studio: In future release of Visual Studio 2022 we are working to add support to use Hot Reload without needing the debugger, this means developers will be able to launch their apps using CTRL-F5 and still use Hot Reload to patch their running app
  • Reducing the number of unsupported changes: In future releases of Visual Studio 2022 and .NET 6+ we're planning work across multiple teams that will reduce the number of unsupported edits at runtime
  • Optimizing frameworks to work best with Hot Reload: In .NET 6 we're investigating how certain frameworks can be improved to better support Hot Reload. Examples of this in the future will include improvements to ASP.NET Core, .NET MAUI and other frameworks where tweaks and optimization will make Hot Reload changes more useful in more situations.
  • At this point, you can implement the prerequisite tooling and get started, with this caveat: "In this early preview release, we want to acknowledge that there will be bugs. Sometimes if you try to apply a change it might silently fail, or your app might crash, etc. If you do encounter any problems, please take a moment to report issues to us, as only with your feedback can we ensure that critical problems are resolved, and future decisions are prioritized based on your input."

    About the Author

    David Ramel is an editor and writer for Converge360.

    comments powered by Disqus

    Featured

    Subscribe on YouTube