Microsoft previews Hot Reload for .NET developers, sets date for .NET 6

Faster Entity Framework, complete C++ 20 support in Visual Studio, but complications remain

Build Microsoft has previewed Hot Reload for .NET development, enabling on-the-fly changes to source code that are applied to a running application. The company also set the date for the first production release of .NET 6: November 9.

Long-time Microsoft-platform developers will recall Edit and continue (EnC) as a feature of Visual Basic way back when that was lost in the transition to .NET, and then regained in Visual Studio 2005.

Hot Reload is not the same feature, though according to senior program manger Dmitry Lyalin, "Hot Reload is powered by EnC."

Edit and continue requires pausing the code at a breakpoint, making the edit, and resuming, whereas Hot Reload does not require a pause.

We tried the feature in Visual Studio 2019 16.11 preview, using .NET 6.0 preview, and the feature worked well in a simple example. It also works the next time the code that is changed is re-executed; it does not reload the application. This is handy when fixing a bug or experimenting with code that runs on a button click, for example, saving time. XAML Hot Reload is an existing feature that is specifically for updating XAML-based user interfaces on the fly.

Clicking the Apply code changes button will update a running application without a pause, all going well

Click to enlarge

VS Code users can also try Hot Reload, using a utility called dotnet watch. This utility has existed for several years and runs a .NET core command when source files change.

It can be used to refresh the browser when a page changes, to recompile code, or to run tests. The dotnet watch utility can now be configured to support Hot Reload, by modifying a launch settings file.

Still coming

Lyalin said that more features are planned for the release of .NET 6 and Visual Studio 2022. Future plans include .NET Hot Reload for iOS, Android and Mac Catalyst applications, Razor and Blazor applications, applications running in release mode (currently debug mode is needed), and fewer limitations over what can be changed. Currently C# has the best support, Visual Basic has some support, and F# is not yet supported.

At the virtual Build event under way this week, Microsoft also unveiled .NET 6 preview 4, and gave the date of November 9 for general availability. .NET 6 is a big release since it is the first long-term support version of the unified .NET that succeeds both .NET Framework and .NET Core (though it is really .NET Core). Program manager Richard Lander said that production use of .NET 6 will be possible from August, using what the company calls go-live builds. .NET 6 will be supported for three years and the official list of platforms has been extended to include Android, iOS, Mac and Mac Catalyst for x64 and Apple Silicon, and Windows Arm64.

Lander mentioned new features in preview 4, including rewritten FileStream that performs faster and uses much less memory (Lander gave an example which shows memory allocations dropping from 39kB to 1kB).

He also said that the code for EventPipe, a mechanism for "egressing events, performance data and counters," has been migrated from C++ to C, the reason being to support the Mono runtime with the same code.

ASP.NET Core in the.NET 6 preview 4 has a new feature, called minimal APIs. "These streamlined APIs provide the benefits of ASP.NET MVC with less ceremony", said principal program manager Daniel Roth.

A skeleton API app can now be written in a few lines of code in one file, he said.

The team is also taking advantages of new features in C# 10 to enable more concise code. "The developer goes from using classes and methods to using lambdas without giving up the ability to use attributes and other features," said Roth.

There is also new logging middleware, optimisation for Entity Framework Core, and simplified templates for single-page applications.

There is an important change for Blazor WebAssembly applications, which now support compilation directly to WebAssembly rather than running on a .NET runtime implemented in WebAssembly.

The performance improvement "can be quite dramatic," said Roth, giving an example that was 5 times faster. It is also now possible to host Blazor components in a .NET MAUI (Multi-Platform App UI, the successor to Xamarin Forms) application, as a route to building cross-platform native applications using a web user interface.

The difference between this and alternatives like Electron is that developers can write everything in C#, though the extent to which that is desirable is up for debate. The evidence is that some .NET developers are quite taken with Blazor.

Blazor WebAssembly apps will now be compiled direct to Wasm rather than running as .NET intermediate language on a Wasm .NET runtime.

Blazor WebAssembly apps will now be compiled direct to Wasm rather than running as .NET intermediate language on a Wasm .NET runtime

Microsoft has also updated Visual Studio 2019 (no sign of Visual Studio 2022 yet, though a preview was promised in the summer). Visual Studio 2019 16.10 (the production version) now has a feature-complete C++ 20 computer and STL, according to senior program manager Justin Johnson.

There are also improvements to the Git support, an improved .NET performance profiler using a new analysis engine, and some other tweaks.

Finally, the Entity Framework Core team has reported performance improvements in the forthcoming version for .NET 6. EF Core as executing queries 31 per cent faster, and in combination with other .NET 6.0 improvements, 70 per cent faster than version 5.0.

The team said it was inspired by Dapper, an alternative to EF Core that is much faster, maintained and used by StackOverflow, and that it has narrowed the performance gap to 5 per cent on some benchmarks.

Although Microsoft is putting huge effort into making sense of its sprawling .NET platform, there are still areas of confusion.

A developer asked whether Xamarin would now use the same base class libraries as .NET on Windows. "Yes", said Lander, but "The answer is a tiny bit more nuanced."

He observed that rather than .NET on Windows, it was more precisely .NET 6 cross-platform libraries on Windows, and that "there may always be a different behavior for certain APIs in iOS vs Windows vs Linux, depending on what the OS enables."

Write once, test everywhere.®

Similar topics

Broader topics

Other stories you might like

  • Twitter founder Dorsey beats a hasty retweet from the board
    We'll see you around the Block

    Twitter has officially entered the post-Dorsey age: its founder and two-time CEO's board term expired Wednesday, marking the first time the social media company hasn't had him around in some capacity.

    Jack Dorsey announced his resignation as Twitter chief exec in November 2021, and passed the baton to Parag Agrawal while remaining on the board. Now that board term has ended, and Dorsey has stepped down as expected. Agrawal has taken Dorsey's board seat; Salesforce co-CEO Bret Taylor has assumed the role of Twitter's board chair. 

    In his resignation announcement, Dorsey – who co-founded and is CEO of Block (formerly Square) – said having founders leading the companies they created can be severely limiting for an organization and can serve as a single point of failure. "I believe it's critical a company can stand on its own, free of its founder's influence or direction," Dorsey said. He didn't respond to a request for further comment today. 

    Continue reading
  • Snowflake stock drops as some top customers cut usage
    You might say its valuation is melting away

    IPO darling Snowflake's share price took a beating in an already bearish market for tech stocks after filing weaker than expected financial guidance amid a slowdown in orders from some of its largest customers.

    For its first quarter of fiscal 2023, ended April 30, Snowflake's revenue grew 85 percent year-on-year to $422.4 million. The company made an operating loss of $188.8 million, albeit down from $205.6 million a year ago.

    Although surpassing revenue expectations, the cloud-based data warehousing business saw its valuation tumble 16 percent in extended trading on Wednesday. Its stock price dived from $133 apiece to $117 in after-hours trading, and today is cruising back at $127. That stumble arrived amid a general tech stock sell-off some observers said was overdue.

    Continue reading
  • Amazon investors nuke proposed ethics overhaul and say yes to $212m CEO pay
    Workplace safety, labor organizing, sustainability and, um, wage 'fairness' all struck down in vote

    Amazon CEO Andy Jassy's first shareholder meeting was a rousing success for Amazon leadership and Jassy's bank account. But for activist investors intent on making Amazon more open and transparent, it was nothing short of a disaster.

    While actual voting results haven't been released yet, Amazon general counsel David Zapolsky told Reuters that stock owners voted down fifteen shareholder resolutions addressing topics including workplace safety, labor organizing, sustainability, and pay fairness. Amazon's board recommended voting no on all of the proposals.

    Jassy and the board scored additional victories in the form of shareholder approval for board appointments, executive compensation and a 20-for-1 stock split. Jassy's executive compensation package, which is tied to Amazon stock price and mostly delivered as stock awards over a multi-year period, was $212 million in 2021. 

    Continue reading

Biting the hand that feeds IT © 1998–2022