The .NET Stacks #41: 🎁 Your monthly preview fix has arrived

This week, Ignite wraps and we get a new upgrade assistant.

Dave Brock
Dave Brock

Did you know e-mail turns 50 this year? Do you remember when in 2004, Bill Gates pledged to rid the world of spam emails in two years?

  • One big thing: .NET 6 Preview 2 is here
  • The little things: Azure Functions .NET 5 support goes GA, new .NET APIs coming, event sourcing examples
  • Last week in the .NET world

One big thing: .NET 6 Preview 2 is here

Last week, Microsoft released .NET Preview 2. From here on out, the .NET team will ship a new preview every month until .NET 6 goes live in November 2021. As a reminder, .NET 6 is an LTS release, meaning Microsoft will support it for three years.

A big focus for .NET 6 is improving the inner loop experience and performance: maximizing developer productivity by optimizing the tools we use. While it’s early Stephen Toub writes that the team has trimmed overheads when running dotnet new, dotnet build, and dotnet run. This includes fixing issues where tools were unexpectedly JIT’ing and changing the ASP.NET Razor compiler to use a Roslyn source generator to avoid extra compilation steps. A chart of the drastic build time improvements shows a clean build of Blazor Server decreasing from over 3600 milliseconds to around 1500 milliseconds. If you bundle this with a best-in-class hot reload capability, developers have a lot to be excited about with .NET 6.

In .NET 6, you’ll be hearing a lot about MAUI (Multi-Platform App UI), which is the next iteration of Xamarin.Forms. With MAUI, Xamarin developers can use the latest .NET SDKs for the apps they build. If you aren’t a Xamarin developer, you can still take advantage of MAUI: for example, using MAUI Blazor apps can run natively on Windows and macOS machines. With Preview 2, Microsoft enabled a single-project experience that reduces overhead when running Android, iOS, and macOS apps.

While .NET library improvements don’t come with the same fanfare, a couple of improvements caught my eye. The System.Text.Json library now has a ReferenceHandler.IgnoreCycles option that allows you to ignore cycles when you serialize a complex object graph—a big step for web developers. Little by little, Microsoft’s Newtonsoft comparison chart is getting better. Additionally, a new PriorityQueue<TElement, TPriority> collection enables you to add new items with a value and a priority.

Aside from the Razor performance improvements, ASP.NET Core now has support for custom event arguments in Blazor, CSS isolation for MVC and Razor Pages, and the ability to preserve prerendered state in Blazor apps. (And no, AOT is not ready yet—the comment CTRL + F “AOT” 0 results, closes the tab from the last preview is the hardest I’ve laughed in a while.) In Entity Framework Core land, the team is working on preserving the synchronization context in SaveChangesAsync, flexible free-text search, and smoother integration with System.Linq.Async.

If you want the full details on what’s new in Preview 2, Richard Lander has it all. You can also check out what’s new in ASP.NET Core and Entity Framework Core as well.

The little things: Azure Functions .NET 5 support goes GA, new .NET APIs coming, event sourcing examples

I’ve mentioned this a few times before, but the Azure Functions team has developed a new out-of-process worker that will help with quicker support of .NET versions. Here’s the gist of why they are decoupling a worker from the host, from Anthony Chu:

The Azure Functions host is the runtime that powers Azure Functions and runs on .NET and .NET Core. Since the beginning, .NET and .NET Core function apps have run in the same process as the host. Sharing a process has enabled us to provide some unique benefits to .NET functions, most notably is a set of rich bindings and SDK injections. … However, sharing the same process does come with some tradeoffs. In earlier versions of Azure Functions, dependencies could conflict. While flexibility of packages was largely addressed in Azure Functions V2 and beyond, there are still restrictions on how much of the process is customizable by the user. Running in the same process also means that the .NET version of user code must match the .NET version of the host. These tradeoffs of sharing a process motivated us to choose an out-of-process model for .NET 5.

A few weeks ago, I wrote about how you can use this with .NET 5 today, but it was very much in preview and involved a lot of manual work. This week, it became production-ready. .NET 6 will support both the in-process and out-of-process options so that .NET Core 3.1 can remain supported. Long term (for .NET 7 and beyond), the team hopes to move new feature capabilities to the out-of-process worker completely—allowing support of .NET 7 on Day 1 from only the isolated worker.


The .NET team approved a proposal for a new Timer API. As ASP.NET Core architect David Fowler notes in the issue, the current implementation can incur overlapping callbacks (which aren’t async). Additionally, he notes it always captures the execution context, which can cause problems for long-lived operations. How will this new API help? It pauses when user code is executing while resuming the next period when it ends, can be stopped using a CancellationToken, and doesn’t capture an execution context. If you’re only firing a timer once, Task.Delay will continue to be a better option.

Also, .NET is getting a new Task.WaitAsync API. This appears to replace WhenAny, allowing Microsoft to assure us that naming things is still the hardest part of computer science. I say call it WhenAsync. If you look at the name hard enough after a few drinks, WhenAny is still there.


If you’re into event sourcing, check out Oskar Dudycz’s EventSourcing.NetCore repo. It’s full of nice tutorials and practical examples. That’s all.


Lastly, a nice tip on how you can tell when a site’s static file was last updated (even if several factors can make this unpredictable).


🌎 Last week in the .NET world

🔥 The Top 3

📢 Announcements

📅 Community and events

🌎 Web development

🥅 The .NET platform

⛅ The cloud

📔 Languages

🔧 Tools

📱 Xamarin

🏗 Design, testing, and best practices

🎤 Podcasts

🎥 Videos

.NET Stacks

Consider subscribing to The .NET Stacks, my free weekly newsletter. I write about news and trends, interview community leaders, and catch you up fast. (No spam, ever, and unsubscribe whenever you want.)


    Consider subscribing to The .NET Stacks, my free weekly newsletter. I write about news and trends, interview community leaders, and catch you up fast. (No spam, ever, and unsubscribe whenever you want.)