The .NET Stacks #45: 🔥 At last, hot reload is (initially) here
Hey, hot reload is here! We also talk about C# updates.
Happy Monday! Here’s what we’re talking about this week:
- One big thing: .NET 6 Preview 3 is here, and so is hot reload
- The little thing: C# updates
- Last week in the .NET world
.NET 6 Preview 3 is here, and so is hot reload
On Thursday, Microsoft rolled out .NET 6 Preview 3. Richard Lander has the announcement covered. As he notes in the post, the release is “dedicated almost entirely to low-level performance features.” For example, we’ve got faster handling of structs as Dictionary values, faster interface checking and casting thanks to the use of pattern matching, and code generation improvements. The team resolved an issue where NuGet restore failed on Linux thanks to previous certificate issues. There were also updates to EF Core and ASP.NET Core.
Oh, and initial hot reload support is finally here.
Hot reload isn’t just for Blazor developers to enjoy—it’s built into the .NET 6 runtime. With Preview 3, you can use it by running
dotnet watch in your terminal with ASP.NET Core web apps—Razor Pages, MVC, and Blazor (Server and WebAssembly). In future updates, you’ll enjoy Visual Studio support and use it with other project types like mobile, console apps, and client and mobile apps.
It’s been highly requested, and for a good reason—front-end frameworks and libraries based on interpreted languages like JS have enjoyed this for the last five years, and it’s a fantastic productivity booster. It’s easy to rag on Microsoft for taking this long—but they’ve had more significant problems during this time. Five years ago, Microsoft was preparing the roll out of the first version of .NET Core, and a component library like Blazor was just a thought, if at all. Now, the runtime is ready to address these issues (as it’s a main goal of .NET 6).
I tried out hot reload with Blazor Server this weekend (a blog post is coming). I’ll include some GIFs that show what it’s like.
Here’s basic editing of static text:
Here’s what happens when I update C# code:
In the following example, you’ll see here that it preserves state. When I change the
currentCount value, the state of the component is maintained. I’ll need to refresh the page to see the new
currentCount.
Here’s where I put it all together by dropping in components (with independent state) and editing some CSS for good measure.
However, not all code actions are supported. When this happens—like renaming a method—it will revert to current
dotnet watch behavior by recompiling and refreshing your page with the latest bits.
If you have runtime errors, a banner displays at the top with the appropriate information. When you resolve your issues, the app will recompile and refresh.
On the subject of Blazor, Preview 3 ships with a
BlazorWebView control. This allows WPF and Windows Forms developers to embed Blazor functionality into existing .NET 6 desktop apps.
The little thing: C# updates
Last week, Bill Wagner announced open-source C# standardization. In addition to the compiler work repo (in dotnet/roslyn) and the repo for C# language evolution (dotnet/csharplang), there is now a new repo (dotnet/csharpstandard) dedicated to documenting the standard for the latest C# language versions.
The new repo sits under the .NET Foundation, and as Wagner states:#.
If you’re having trouble distinguishing between dotnet/csharplang and dotnet/csharpstandard, you aren’t alone. Bill Wagner notes that there’s some overlap between the repos, and it’s a work in progress.
Speaking of C#, it’s nice to check out any language proposals from time-to-time, and file-scoped namespaces is making progress as a C# 10 proposal.
🌎 Last week in the .NET world
🔥 The Top 3
- Richard Lander announces .NET 6 Preview 3, and Dan Roth shows off the ASP.NET Core updates in .NET 6 Preview 3.
- The .NET Docs Show has a C# roundtable with C# gods Mads Torgersen, Bill Wagner, and Jon Skeet.
- The NuGet team addresses restore failures on Linux distributions using NSS or ca-certificates, and Nikolche Kolev writes about NuGet performance improvements.
📢 Announcements
- Microsoft announces a preview of their own OpenJDK build.
- Jorge Garcia Hirota announces GA client libraries for Azure Communication Services.
- Dapr v1.1.0 is now available.
- The AWS SDK for .NET version 1 has reached the end of support.
- Andrew Lock announces the second edition of his book, ASP.NET Core in Action.
📅 Community and events
- Bill Wagner announces open-source C# standardization.
- For community standups: Languages & Runtime discusses C# standardization, Entity Framework talks about Azure SQL, and ASP.NET discusses Microsoft Identity.
🌎 Web development
- Kevin W. Griffin asks: does SignalR guarantee message deliverability?
- Claudio Bernasconi works on static images in Blazor.
- Dave Brock works with DynamicComponent in Blazor.
- Niels Swimberghe creates ZIP files on HTTP request without intermediate files using the ASP.NET MVC framework.
- Matthew Jones continues building his Tetris app in Blazor.
- Damien Bowden creates verifiable credentials in ASP.NET Core for decentralized identities using Trinsic.
- Marinko Spasojevic creates a Blazor nav menu using Material UI.
- Sam Xu writes about attribute routing in ASP.NET Core OData 8.0 RC.
- Kristoffer Strube troubleshoots a 404 issue when deploying Blazor Web Assembly to GitHub Pages.
🥅 The .NET platform
- David Hayden installs .NET on Ubuntu.
- Nick Randolph gets started with the Uno platform.
- Peter Vogel writes about moving to desktop applications in .NET 5.
- Andrea Chiarelli writes about secrets management in .NET apps.
- Sergey Tihon configures dotnet watch with Microsoft.Identity.Web or custom IDistributedCache.
- Tom Deseyn writes about C# 9 pattern matching.
⛅ The cloud
- GitHub explains their new authentication token formats, and also walks us through how they scaled the GitHub API with a rate limiter in Redis.
- John Bohannon shows you how to write your first GitHub Action.
- Adam Storr works through why Azure Functions doesn’t load his dependencies.
- Jimmy Bogard writes about local development with the Azure Service Bus.
- Paul Michaels writes about batching and pre-fetching with Azure Service Bus.
- Laurent Kempé accesses the Dapr secrets building block using the Dapr .NET SDK.
🔧 Tools
- Michael Washington creates Power BI paginated reports with Blazor.
- Khalid Abuhakmeh writes about recursive Data With Entity Framework Core and SQL Server and also models SQL relationships in EF Core.
- Mark Heath deploys an Azure Function app with Bicep.
- Scott Hanselman adds more icons to Windows Terminal.
📱 Xamarin
- Leomaris Reyes gets started with CollectionView.
- Sam Basu provides another MAUI update.
🏗 Design, testing, and best practices
- Jay Krishna Reddy unit tests using XUnit And Moq in ASP.NET Core.
- Derek Comartin develops smarter SPAs with REST APIs.
- Scott Hannen experiments experiments with making integration tests easier to write.
- Patrick Smacchia implements a domain with POCOs.
- Nish Anil answers .NET microservices questions.
- Tobias Günther explains how branches work in Git.
🎤 Podcasts
- The 6-Figure Developer podcast talks to Sean Whitesell about microservices.
- Scott Hanselman talks to Jean Yang about API observability.
- The Azure Podcast talks about cloud-native machine learning, and also talks about the API Management service.
- The Adventures in .NET podcast discusses use cases for GraphQL in .NET .
- The Complete Developer podcast talks about state machines.
- The Merge Conflict podcast talks about satisfying business requirements.
🎥 Videos
- The On .NET Show talks about .NET MAUI, and also creates .NET project templates.
- The AzureFunBytes stream talks to Mark Brown about Cosmos DB.
- Steve Collins talks to JetBrains about dependency injection.
- The Xamarin Show discusses XAML hot reload updates.
- At Technology and Friends, David Giard talks to Ted Neward about technology culture.
- Data Exposed talks about migrating databases to Azure.