The .NET Stacks #52: 🎂 Happy birthday to us
Tags: dotnet, csharp, azure
Published: 2021-06-01 00:12:54

---
title: The .NET Stacks #52: 🎂 Happy birthday to us
published: true
date: 2021-05-31 23:44:41 UTC
tags: dotnet, csharp, azure
canonical_url: https://www.daveabrock.com/2021/05/31/dotnet-stacks-52/
---

![](https://www.daveabrock.com/content/images/size/w1384/2021/05/dotnet-stacks-birthday.png)

*Note: This is a special extended edition of The .NET Stacks, available to the community right away! (The community usually receives the issues a week after email subscribers.) If you like what you read, subscribe at [dotnetstacks.com](https://dotnetstacks.com)!*
 
As if the completely ridiculous banner image didn't tip it off, it's true: today is the 1st birthday of _The .NET Stacks_! I'd like to thank [our friend Isaac Levin](https://www.daveabrock.com/2020/06/13/dev-discussions-isaac-levin/)—our first interview guest—for being such a good sport. If you haven't seen the [wonderful "Application Development" keynote from Build](https://www.youtube.com/watch?v=EWYYgEkGJfs), you should (and the picture will all make sense).

But most of all, I'd like to thank all of you for your support. Honestly, this little project started as a way to keep my mind busy during a pandemic lockdown and I really wasn't sure how things would go. (Looking back [at the first issue](https://www.daveabrock.com/2020/05/24/dotnet-stacks-1/) ... that was very evident.) I'm thrilled it's been able to have the impact it has, and I'm grateful to all of you for that.

With all that out of the way, what are we talking about this week? In this extended issue, there's a _lot_ here:  

- Build 2021 recap
- .NET 6 Preview 4 has arrived
- Visual Studio updates
- System.Console in .NET 7

* * *

## Build 2021 recap

Last week, Microsoft rolled out Build 2021. You can check out the 330 sessions [at the Build website](https://mybuild.microsoft.com/sessions), and there's a YouTube playlist at the [Microsoft Developer YouTube channel](https://www.youtube.com/watch?v=KQt0v950h6k&list=PLlrxD0HtieHgMGEnTzEEfkADbaG8aAWRp). It's no secret that these days Build is heavy on promoting Azure services, but .NET got a lot of love last week, too.

Your mileage may vary, but my favorite sessions included the [application development keynote](https://www.youtube.com/watch?v=EWYYgEkGJfs&ab_channel=MicrosoftDeveloper), a [.NET "Ask the Experts" session](https://www.youtube.com/watch?v=SMz_QDZYZCw),  [increasing productivity with Visual Studio](http://www.youtube.com/watch?v=Ok-csh6FLL0), [microservices with Dapr](http://www.youtube.com/watch?v=DyKYB76SDx0), [modern app development with .NET](https://www.youtube.com/watch?v=2Ky28Et3gy0), and a .NET 6 [deep-dive session with Scott Hunter](https://www.youtube.com/watch?v=GJ_PaRNDe9E). (Hunter is Microsoft's CSO—the Chief Scott Officer. He also runs .NET.)

I want to call out a few interesting details from that session: updates on C# 10 and a new Blazor FluentUI component library that's taking shape. (There were other nice updates on .NET MAUI and Minimal APIs that we'll surely address in depth in later issues.)

### C# 10 updates

In Scott Hunter's talk, Mads Torgersen and Dustin Campbell walked through some updates coming to C# 10. C# 10 looks to be focused on productivity and simplicity features. I want to show off record structs, required object initializers, auto-implemented property improvements, null parameter checking, global usings, and file-scoped namespaces.

#### Record structs

C# 9 [brought us records](https://www.daveabrock.com/2020/07/06/c-sharp-9-deep-dive-records/), which gives you the ability to enforce immutability with the benefits of "value-like" behavior. While the C# 9 records are really just a class under the covers and accessed by reference, the "value-like" behaviors ensure that default equality checking works with your object's data (as opposed to reference equality). A good use case is with DTOs and other objects that benefit from immutability.

With all reference types, though, passing around a lot of records can create a lot of pressure on the garbage collector. If you couple that with using `with` expressions, copying and GC pressure [can become an issue](https://twitter.com/MadsTorgersen/status/1327033065168748545) if you go crazy with records. Can we use structs with records? With C# 10, you can with the `record struct` syntax. It'll behave similarly, with the only key difference being that record structs aren't heap-allocated. This will also work with tuples, expressions, or any other struct types.

Let's look at some code, shall we? Let's say you have a `Person` record in C# 9:

```csharp
record Person
{
   public string FirstName { get; init; }
   public string LastName { get; init; }
}
```

To use a record struct, change it to this:

```csharp
record struct Person
{
   public string FirstName { get; init; }
   public string LastName { get; init; }
}
```

The default `record` declaration will still be a reference type. If you want to make that explicit, you can use the new `class struct` syntax. They are the same.

#### Required object initializers

I enjoy the flexibility of object initializers. You can use them to initialize objects however you want: you can initialize just a few properties, in whatever order you want, or none at all! Unfortunately, this flexibility can also bite you in the rear end if you aren't careful.

With C# 10, you can set fields to be required when performing object initialization, like this:

```csharp
record struct Person
{
   public required string FirstName { get; init; }
   public required string LastName { get; init; }
}
```

Its early days on this feature, but it might also help to enforce whether types can be instantiated by positional syntax (constructors) or object initialization.

#### Auto-implemented property improvements

In the Build talk, Dustin and Mads talked about _the cliff_: let's say you want to change one little thing about an auto-implemented property. The next thing you know, you're creating a backing field, adding bodies for your getters and setters, and you're left wondering why it takes so much work to change one little thing.

With C# 10, you can refer to the auto-generated backing field without all that nonsense. You'll be able to work with a `field` keyword in your getters, setters, or even both.

```csharp
record struct Person
{
   public string FirstName { get; init => field = value.Trim(); }
   public string LastName { get; init; }
}
```

This change provides better encapsulation and fewer lines of boilerplate code.

#### Null parameter checks

We've seen many nullability improvements over the last few C# releases, but null parameter checking can still be a manual chore—even with null reference types, you have to depend on the caller to do null checks.

With C# 10, this is taken care of with the `!!` keyword:

```csharp
public void DoAThing(string text!!)
{
   Console.WriteLine(text);
}
```

Don't worry, you aren't seeing double—this doesn't mean you're super excited about the `text` argument. Personally, I'm not a fan of the `!!`—at this rate, the C# team will need to start inventing new characters—but I _am_ a fan of removing a bunch of this boilerplate nonsense.

#### Global usings and file-based namespaces

Lastly, the team introduced a few enhancements to help simplify your C# codebase.

With global usings, you can use the `global using` keywords to signify usings should be accessible throughout every _.cs_ file in your project.

Here's a typical example of using statements you might want to use in your global using file:

```csharp
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Threading.Tasks;
global using static System.Console;
```

I wonder if we could use Roslyn analyzers to shake out unused global usings for individual files. Anyway, I think this is a feature I will originally hate, then learn to love. It's nice to see what is being used, but after a while, it's a maintenance headache. This will be nice. (Not to mention ASP.NET Core developers are familiar with a similar approach with Razor files.) In any case, in many files, you might wind up with a global usings file, then individual usings for references that aren't scattered across your projects.

Lastly, the team introduced file-scoped namespaces. It allows you to go from this:

```csharp
namespace MyNamespace
{
   record Person
   {
      public string FirstName { get; init; }
      public string LastName { get; init; }
   }
}
```

To this:

```csharp
namespace MyNamespace;

record Person
{
   public string FirstName { get; init; }
   public string LastName { get; init; }
}
```

Of course, you could use top-level statements to remove namespaces completely—however, there are plenty of reasons why you don't want to abstract away your namespace declarations. In those cases, it's a nice, clean approach.

### New Blazor component library

So here's something interesting that isn't getting a lot of attention: Microsoft is [working on a component library for Blazor](https://github.com/microsoft/fast-blazor). Technically, these are wrappers around Microsoft's existing FluentUI Web Components and are [built on FAST](https://www.fast.design/). You can fork the repository and browse to the _examples_ app for a test page:

![](https://www.daveabrock.com/content/images/2021/05/fast-components.jpg)

This is early, but I'd recommend taking a look—while it comes with the Blazor name, these are technically Razor components. This means you use them in other ASP.NET Core web apps, such as Razor Pages and MVC.

Microsoft customers have been asking for an in-house, free component library for a while—this will fill the need. While Microsoft will eventually introduce this as yet another tool at your disposal, they'll need to be careful here: the .NET community has a rich community of open-source and third-party component libraries (both free and paid), and they'll need to avoid the perception they're trying to replace these options. (To be abundantly clear, they definitely are not.)

* * *

## .NET 6 Preview 4 has arrived

Just minutes into Build, Microsoft announced the official release of .NET 6 Preview 4. We've teased a few features in the last month or so, but it's nice to see the official news. Richard Lander [wrote up the blog post](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4/). As a reminder, .NET 6 will be an LTS release.

[.NET Hot Reload](https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/) is a big .NET 6 feature (as is improving the developer inner loop in general). I've [written about](https://www.telerik.com/blogs/instant-feedback-is-here-introducing-hot-reload-in-dotnet-6) how you can use it by running `dotnet watch` with ASP.NET Core web apps (that is, Blazor, Razor Pages, and MVC). With Preview 4, [you can also use it](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4/#tools-hot-reload-with-the-visual-studio-debugger-and-dotnet-cli) with other project types like WPF, Windows Forms, WinUI, console apps and "other frameworks that are running on top of the CoreCLR runtime." It's now integrated with the Visual Studio debugger as well—to do this, you need to download VS 2019 16.11 Preview 1.

In Lander's post, we also see much of what we've discussed previously: check out the official details on [`System.Text.Json` improvements](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4/#system-text-json-support-for-iasyncenumerable), [LINQ enhancements](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4/#system-linq-enhancements), [FileStream performance improvements on Windows](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4/#significantly-improved-filestream-performance-on-windows), and [new `DateOnly` and `TimeOnly` structs](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4/#enhanced-date-time-and-time-zone-support).

What about ASP.NET Core? ASP.NET Core is bringing it in this release—there's [Minimal APIs](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#introducing-minimal-apis), [async streaming](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#async-streaming), [HTTP logging middleware](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#http-logging-middleware), [improved SPA templates](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#improved-single-page-app-spa-templates), [Blazor error boundaries](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#blazor-error-boundaries), and ... drum roll ... [Blazor WebAssembly ahead-of-time (AOT) compilation](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#blazor-webassembly-ahead-of-time-aot-compilation)! You can also start building [.NET MAUI client-side apps with Blazor](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4/#blazor-webassembly-ahead-of-time-aot-compilation). Speaking of MAUI, [there's a separate post outlining its Preview 4 updates](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-4/). If you're using Entity Framework, make sure to check out that team's Preview 4 post [to see all the wonderful perf improvements](https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-6-0-preview-4-performance-edition/).

Preview 4 is a big one. Even with a little under six months to go, we'll only have a few previews to go until the focus turns to bug fixes. .NET 6 is coming along nicely.

* * *

## Visual Studio updates

Last week, Microsoft also released [Visual Studio 2019 v16.10 and v16.11 Preview 1](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/).

With 16.10, we're seeing some more [Git workflow improvements](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/). The initial improvements to Git workflow in Visual Studio 2019 were a little rough, if we're being honest. It's nice to see the Visual Studio team listening to customer feedback and making it better. You can also now [remove unused references](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/)—a long-adored ReSharper feature. In other news, there's [improvements to Docker container tooling](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/#containers), [IntelliSense completion improvements](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/#containers), [Test Explorer improvements](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/#test-explorer-accessibility-improvements), and more. If F# is your jam, Phillip Carter [announced some tooling updates for 16.10](https://devblogs.microsoft.com/dotnet/f-and-f-tools-update-for-visual-studio-16-10/).

Also, if you're developing Azure Functions with the isolated worker in .NET 5, Azure Functions PM Anthony Chu has an update for you:

{% twitter 1397621201191665666 %}

With 16.11 Preview 1, the big news is supporting [hot reload in Visual Studio](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/#net-hot-reload). We're [also seeing .NET MAUI support](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today/#net-hot-reload).

On the topic of IDEs, JetBrains released its roadmaps for [ReSharper 2021.2](https://blog.jetbrains.com/dotnet/2021/05/25/resharper-2021-2-roadmap/) and [Rider 2021.2](https://blog.jetbrains.com/dotnet/2021/05/26/rider-2021-2-roadmap/).

* * *

## Rethinking System.Console in .NET 7

With .NET 7—yes, .NET 7!—Microsoft is taking a look at redesigning `System.Console`.

As [Adam Sitnik describes it](https://github.com/dotnet/runtime/issues/52374#issue-877319518), the initial design was driven by Windows OS capabilities and APIs. With .NET going cross-platform, it introduced a number of issues since there wasn't a good way to map Windows concepts to Unix. You're encouraged to [follow the discussion and provide feedback](https://github.com/dotnet/runtime/issues/52374).

We've seen a lot of community innovation in this space. For example, Patrik Svensson's [Spectre.Console library](https://github.com/spectreconsole/spectre.console) shows us that the developer console experience can be productive _and_ beautiful. This [isn't lost](https://github.com/dotnet/runtime/issues/52374#issuecomment-834159352) and I'm interested to see how this work evolves.  

* * *

## 🌎 Last week in the .NET world

Welcome to Build week, where announcements are everywhere.

### 🔥 The Top 3

- Microsoft Build 2021 came and went—[Amanda Silver](https://blogs.microsoft.com/blog/2021/05/24/from-developers-to-inspired-creators/) and [Scott Guthrie](https://blogs.microsoft.com/blog/2021/05/25/microsoft-loves-developers-welcome-to-build-2021/) welcome you, and Microsoft [provides the Build 2021 Book of News](https://news.microsoft.com/build-2021-book-of-news/).
- Richard Lander [announces .NET 6 Preview 4](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4), Dan Roth [announces ASP.NET Core updates](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-4), Shay Rojansky [does the same for EF Core](https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-6-0-preview-4-performance-edition), and David Ortinau [announces .NET MAUI Preview 4](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-4).
- Khalid Abuhakmeh [announces the roadmap for ReSharper 2021.2](https://blog.jetbrains.com/dotnet/2021/05/25/resharper-2021-2-roadmap/) and also for [Rider 2021.2](https://blog.jetbrains.com/dotnet/2021/05/26/rider-2021-2-roadmap/).

### 📢 Announcements

- Microsoft [releases Visual Studio 2019 v16.10 and v16.11 Preview 1](https://devblogs.microsoft.com/visualstudio/visual-studio-2019-v16-10-and-v16-11-preview-1-are-available-today), and Phillip Carter [announces F# and F# tools updates](https://devblogs.microsoft.com/dotnet/f-and-f-tools-update-for-visual-studio-16-10).
- Dmitry Lyalin [introduces the .NET Hot Reload experience for editing code at runtime](https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload).
- The Windows Package Manager [goes 1.0](https://devblogs.microsoft.com/commandline/windows-package-manager-1-0), and Kayla Cinnamon [releases Windows Terminal Preview 1.9](https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-9-release).
- Troy Hunt [announces that Have I Been Pwned is part of the .NET Foundation and a partnership with the FBI](https://www.troyhunt.com/pwned-passwords-open-source-in-the-dot-net-foundation-and-working-with-the-fbi/).
- Sam Basu [announces Telerik UI for MAUI](https://www.telerik.com/blogs/aloha-from-telerik-ui-for-maui).

### 📅 Community and events

- David Ramel [writes about the Visual Studio 2022 roadmap](https://visualstudiomagazine.com/articles/2021/05/24/vs-2022-roadmap.aspx).
- The .NET Docs Show [talks to Christos Matskas about Microsoft Identity](https://www.youtube.com/watch?v=jLJVMD2GBAA).
- Wolfgang Hennerbichler [writes about how GitHub is adopting OpenTelemetry](https://github.blog/2021-05-26-why-and-how-github-is-adopting-opentelemetry/).
- Because of Build, no community standups.

### 🌎 Web development

- The Code Maze blog [uses Serilog with ASP.NET Core](https://code-maze.com/structured-logging-in-asp-net-core-with-serilog/).
- Cody Merritt Anhorn [uses Blazor with SignalR](https://codyanhorn.tech/blog/blazor/2021/05/21/Blazor-and-SignalR.html).
- Matthew Groves [compares SQL and NoSQL in ASP.NET](https://blog.couchbase.com/sql-nosql-comparison-aspnet-application/).
- Jeremy Likness [writes about 10 Blazor features you might not know about](https://www.grapecity.com/blogs/10-blazor-features-you-probably-didnt-know).
- Jay Krishna Reddy [writes about using OData in .NET 5](https://www.c-sharpcorner.com/article/odata-in-net-5/).
- Mark Downie [disables FLoC in ASP.NET](https://www.poppastring.com/blog/disable-floc-in-aspnet).
- Joydip Kanjilal [implements nanoservices in ASP.NET Core](https://auth0.com/blog/implementing-nanoservices-in-aspnet-core/).
- Adam Storr [calls a REST API with HttpClient in .NET 5.0](https://adamstorr.azurewebsites.net/blog/simple-example-of-calling-rest-api-with-httpclient-in-net5.0).
- David McCarter [processes data with microservices](https://www.c-sharpcorner.com/article/architecture-processing-data-with-microservices/).

### 🥅 The .NET platform

- Patrick Smacchia [migrates Delegate.BeginInvoke Calls to .NET Core, .NET 5 and .NET 6](https://blog.ndepend.com/migrating-delegate-begininvoke-calls-to-net-core-net-5-and-net-6/).
- Maarten Balliauw [runs a .NET application as a service on Linux with Systemd](https://blog.maartenballiauw.be/post/2021/05/25/running-a-net-application-as-a-service-on-linux-with-systemd.html).
- Steve Gordon [uses DateOnly and TimeOnly in .NET 6](https://www.stevejgordon.co.uk/using-dateonly-and-timeonly-in-dotnet-6).
- David Ramel [provides updates on Project Reunion](https://visualstudiomagazine.com/articles/2021/05/27/build-win-dev.aspx).
- Khalid Abuhakmeh [explains the difference between HTML and URL Encode in .NET](https://khalidabuhakmeh.com/the-difference-between-html-and-url-encode-in-dotnet).
- Paula Fahmy [begins a series on async C#](https://dev.to/paulafahmy/asynchronous-c-making-a-simple-cup-of-tea-13i).
- Jonathan Allen [builds a source generator in C#](https://www.infoq.com/articles/CSharp-Source-Generator).

### ⛅ The cloud

- Daniel Krzyczkowski [uses Auth0 Actions with Azure Functions](https://daniel-krzyczkowski.github.io/Auth0-Actions-With-Azure-Function-App/).
- Aaron Powell [works with the Azure Static Web Apps CLI](https://dev.to/azure/leveling-up-static-web-apps-with-the-cli-5g5h).

### 🔧 Tools

- Andrew Lock [stops Visual Studio from creating launchsettings.json](https://andrewlock.net/how-to-stop-visual-studio-from-creating-launchsettings-json/).
- Steve Smith [disables logging loading symbols in VS Code](https://ardalis.com/vs-code-disable-logging-loading-symbols/).

### 📱 Xamarin

- Mark Allibone [uses the OIDC client in Xamarin Forms to refresh an access token](https://mallibone.com/post/xamarin-oidc-refresh).
- Sam Basu [provides his weekly MAUI update](https://www.telerik.com/blogs/sands-of-maui-issue-9).

### 🎤 Podcasts

- The .NET Rocks podcast [talks to Scott Hunter about Build 2021 announcements](https://www.dotnetrocks.com/default.aspx?ShowNum=1741).
- The Adventures in .NET podcast [talks to Chris Sainty about Blazor](https://devchat.tv/adventures-in-dotnet/youve-been-blazored-net-070/).
- The Azure DevOps Podcast [talks to David Ortinau about MAUI](http://azuredevopspodcast.clear-measure.com/david-ortinau-on-multi-platform-app-development-using-net-maui-episode-142).
- The Coding Blocks Podcast [talks through some fun APIs](https://www.codingblocks.net/podcast/some-fun-apis/).
- The 6-Figure Developer podcast [talks about .NET Data with Jeremy Likness](https://6figuredev.com/podcast/episode-197-net-data-with-jeremy-likness/).

### 🎥 Videos

- Azure Friday [provides an update on Azure Cosmos DB](https://channel9.msdn.com/Shows/Azure-Friday/Azure-Cosmos-DB-update-MongoDB-40-notebooks-and-continuous-backup).
- The On .NET Show [talks about clustering in Orleans](https://channel9.msdn.com/Shows/On-NET/Clustering-in-Orleans) and also [C# exception filters](https://www.youtube.com/watch?v=l3ynBm6X_IM&t=49s).
- One Dev Question asks: [who at Microsoft is using WinUI?](https://channel9.msdn.com/Blogs/One-Dev-Minute/Who-at-Microsoft-is-using-WinUI--One-Dev-Question)
- The Xamarin Show [improves accessibility with the Xamarin Community Toolkit](https://channel9.msdn.com/Shows/XamarinShow/Improving-Accessibility-with-Xamarin-Community-Toolkit).