The .NET Stacks #58: 📃 6 things about .NET 6 Preview 6
Tags: dotnet, csharp, azure
Published: 2021-07-26 00:25:50

---
title: The .NET Stacks #58: 📃 6 things about .NET 6 Preview 6
published: true
date: 2021-07-25 18:36:00 UTC
tags: dotnet,csharp,azure
canonical_url: https://www.daveabrock.com/2021/07/25/dotnet-stacks-58/
---

![.NET Stacks logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9is3idhpsqs1sj0dulgk.png)

Welcome to another wonderful week. I just learned you can put a timestamp in Notepad by hitting F5. I saw this by reading a blog post from 2002. How's _your_ Monday?

Here's what we have going on in #58:

- **One big thing**: 6 things about .NET 6 Preview 6
- **The little things**: Visual Studio 2022 Preview 2, abstracting Kubernetes
- Last week in the .NET world

* * *

## One big thing: 6 things about .NET 6 Preview 6

Last week, the .NET team rolled out .NET 6 Preview 6. Richard Lander [has the main blog post](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-6/).  Dan Roth [writes about ASP.NET Core updates](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6), Jeremy Likness [updates us on EF Core 6](https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-6-0-preview-6-configure-conventions), and David Ortinau [covers .NET MAUI](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-6/). Preview 6 is the second to last preview release of .NET 6. It appears to be a smaller release, with Preview 7 being bigger, as it's the last preview release.  .NET 6 will end up with seven preview releases, then two RC releases (the latter of which should come with go-live licenses).

The releases will be winding down soon, as Richard Lander says: "_We’ll soon be addressing only the most pressing feedback, approaching the same bug bar that we use for servicing releases. If you’ve been holding on to some feedback or have yet to try .NET 6, please do now. It’s your last chance to influence the release._"

If you want the full details, you can check out the links above—as for me, I'd like to highlight six things that caught my eye.

**Sync-over-async thread performance**. The sync-over-async pattern—which means using synchronous functionality asynchronously—is a common source of performance degradation and thread starvation. A [new change in Preview 6](https://github.com/dotnet/runtime/pull/53471) will improve the rate of default thread injection when the only blocking work on the thread pool is sync-over-async.

**New functionality for working with parameters in ASP.NET Core**. The ASP.NET Core team released two new features that help when working with components in ASP.NET Core.

The first involves [required Blazor component parameters](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6/#required-blazor-component-parameters). You do this by using a new `[EditorRequired]` attribute, like this:

```csharp
[EditorRequired]
[Parameter]
public string Title { get; set; }
```

This functionality is enforced at design time and when building—it's important to note it isn't enforced at runtime and won't guarantee the value of the parameter won't be null.

The next feature now supports [optional parameters for view component tag helpers](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6/#optional-parameters-for-view-components-tag-helpers) in ASP.NET Core. With this update, you no longer need to specify a value for an optional parameter as a tag helper attribute.

**WebSocket compression**. ASP.NET Core [now supports WebSocket compression](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6/#optional-parameters-for-view-components-tag-helpers). This can yield tremendous performance benefits with comes with _a ton_ of caveats. It's disabled by default because enabling it over encrypted connections can make your app subject to attacks. As such, you should only enable it when you know sensitive information isn't being passed around. If that isn't clear enough, the setting is called `DangerousEnableCompression`. No, [seriously](https://github.com/dotnet/aspnetcore/pull/32600/files#diff-c980da9f0c086f0f16ca6d9b1208731773bef1262623a0c6947a733c6512e67fR32).

**Minimal API improvements**. We've talked about [.NET 6 Minimal APIs](https://www.telerik.com/blogs/low-ceremony-high-value-tour-minimal-apis-dotnet-6) quite a bit—so much you're probably sick of me talking about them. Even so, the team keeps building them out and Preview 6 brings some enhancements.

First, you can now integrate those APIs [with OpenAPI (Swagger) support](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6/#openapi-support-in-minimal-apis). You can do this using dependency injection (DI) or middleware. Here's an example using the DI method:

```csharp
builder.Services.AddEndpointsApiExplorer();

builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Description = "My Swagger", Version = "v1" });
});
```

Second, you can now inject services into the `[FromServices]` attribute. Previously, you [needed to do something like this](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6/#inject-services-into-minimal-apis-without-fromservices-attribute):

```csharp
app.MapGet("/movies", async ([FromServices] MovieDbContext db) =>
{
    return await db.Movies.ToListAsync();
});
```

 And now it's this:

```csharp
app.MapGet("/movies", async (MovieDbContext db) =>
{
    return await db.Movies.ToListAsync();
});
```

**Pre-convention model configuration**. From Preview 6 of EF Core, they've released pre-convention model configuration. From [the announcement](https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-6-0-preview-6-configure-conventions/), Jeremy Likness says it's part of "finding ways to enhance model building so that it can more efficiently figure out what is an entity type and what is not." As more types are mapped, it can be painful to exclude types as entity types (and bringing all that overhead into a model) and reverting types from being entity types in certain situations.

You can now use a `ConfigureConventions` override to avoid the hassle of configuring every entity. In Jeremy's example, if you want to always store strings as byte arrays, you can use the override instead:

```csharp
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
  {
      configurationBuilder.Properties<string>()
          .HaveConversion<byte[]>()
          .HaveMaxLength(255);

      configurationBuilder.IgnoreAny<INonPersisted>();
  }
```

**.NET MAUI packaged as workload installation**. With .NET 6, Xamarin is merging into the .NET Multi-platform UI (MAUI). MAUI is aiming to be a cross-platform framework for creating mobile and desktop apps with C# and XAML. I don't mention it much here in the newsletter for two reasons—I can't speak about it intelligently because I have no experience with it, and I'm allergic to XAML. The last time I opened a XAML file I got a fever and was in bed for three days.

Even so, there's a lot of great work going into it, and Preview 6 [marks the first time MAUI will be shipped as a workload installation](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-6/). Like the rest of .NET, you can use SDK workloads to enable specific workloads. In MAUI's case, the team is introducing `maui`, `maui-mobile`, and `maui-desktop` workloads, and soon Visual Studio 2022 will include these workloads in the installer.

MAUI is [getting close to feature-complete](https://github.com/dotnet/maui/wiki/Status) for .NET 6. In this release, the team is rolling out [gesture recognizers](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-6/#gestures), [clipping region enhancements](https://github.com/dotnet/maui/wiki/Status), and [native alerts](https://github.com/dotnet/maui/wiki/Status). Check out [the announcement](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-6) to learn more.

* * *

## The little things: Visual Studio 2022 Preview 2, abstracting Kubernetes

Since we're on the topic of previews, [Visual Studio 2022 Preview 2 is out](https://devblogs.microsoft.com/visualstudio/visual-studio-2022-preview-2-is-out/). Preview 2 is fully localized and ships with over a dozen language packs.

In this update, VS 2022 includes new "Live Preview" experiences with XAML and web apps, which allows you to kiss goodbye to the ancient-feeling recompile-and-run workflow. They are also touting a new Web Live Preview, to allow you to speed up your workflow, with instant updates when working with CSS or data controls. (I suppose we're happy to have it, even if it's an expected feature from modern IDEs these days.) Lastly, this update introduces Force Run, a way to run your app to a specific point that ignores other breakpoints or exceptions. (If you work on C++, [check out the post](https://devblogs.microsoft.com/visualstudio/visual-studio-2022-preview-2-is-out/). C++ isn't a .NET language, so I don't write about it here.)

* * *

When I see click-baity articles with headlines like [_Why Developers Should Learn Kubernetes_](https://thenewstack.io/why-developers-should-learn-kubernetes/), I can't help but cringe. Thankfully, the article is better than the headline suggests—but even so, it's a lot to suggest developers should know the ins and outs of pods, containers, networking, DNS, and load balancing. There's a difference between asking developers to Shift Left, and making them become SRE experts.

Kubernetes gets a lot of grief: it can be extreme overkill and it incurs a steep learning curve. Even so, containerization (and orchestrating these containers) is here to stay, but we should be providing developers with more abstractions over Kubernetes to make it a more PaaS-like experience. Microsoft is [working on their part](https://thenewstack.io/microsoft-takes-practical-approach-to-kubernetes-management/), and don't be surprised to see Azure (and other clouds) make investments in this space.

* * *

## 🌎 Last week in the .NET world

### 🔥 The Top 4

- Jimmy Bogard [continues his series on domain-driven refactoring](https://jimmybogard.com/domain-driven-refactoring-procedural-beginnings/).
- Peter Kuhn [conveys his thoughts on Microsoft and Blazor](https://www.mistergoodcat.com/post/thoughts-on-microsoft-and-blazor).
- Andrew Lock [starts a deep dive on StringBuilder](https://andrewlock.net/a-deep-dive-on-stringbuilder-part-1-the-overall-design-and-first-look-at-the-internals/).
- Iris Classon writes that [the nominations are open for the .NET Foundation Board of Directors 2021 election](https://dotnetfoundation.org/blog/2021/07/14/net-foundation-election-2021-nominations-open).

### 📢 Announcements

- Richard Lander [announces .NET 6 Preview 6](https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-6/). Daniel Roth [walks through ASP.NET Core updates,](https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-6) Jeremy Likness [announces updates for EF Core 6](https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-6-0-preview-6-configure-conventions), and David Ortinau [writes about .NET MAUI updates for .NET 6 Preview 6](https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-6/).
- Visual Studio 2022 Preview 2 [has arrived](https://devblogs.microsoft.com/visualstudio/visual-studio-2022-preview-2-is-out).
- Kayla Cinnamon [rolls out the Windows Terminal Preview 1.10 release](https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-10-release/).

### 📅 Community and events

- Joe Guadagno [reviews _Software Architecture with C# 9 and .NET 5_](https://www.josephguadagno.net/2021/07/15/software-architecture-with-c-sharp-and-dot-net-5-book-review).
- Brandon Minnick [writes about the future of the Xamarin Community Toolkit](https://devblogs.microsoft.com/xamarin/the-future-of-xamarin-community-toolkit/).
- The Focus on F# [agenda is out](https://focus.dotnetconf.net/agenda).
- JetBrains is looking [for feedback on dotMemory and dotTrace](https://blog.jetbrains.com/dotnet/2021/07/15/get-a-reward-for-sharing-your-dottrace-or-dotmemory-experience/).
- For community standups: .NET Tooling [updates on the latest](https://www.youtube.com/watch?v=0i0d7CncwGU), ASP.NET talks [Powered4.tv](https://www.youtube.com/watch?v=hKxciQMxueI) and Entity Framework [visualizes database query plans](https://www.youtube.com/watch?v=Zhy5antRDJk). 
- The .NET Docs Show [talks to Isaac Abraham about F#](https://www.youtube.com/watch?v=jWdMLP13vVo).

### 🌎 Web development

- Peter Kuhn [works on Blazor Server apps in MVC subfolders](https://www.mistergoodcat.com/post/blazor-server-apps-in-mvc-subfolders).
- Jay Krishna Reddy [creates and validates a JWT token in .NET 5.0](https://www.c-sharpcorner.com/article/jwt-validation-and-authorization-in-net-5-0/).
- Cody Merritt Anhorn [uses Blazor to scroll to a hash anchor on the current page](https://nu-codyanhorn-tech.azurewebsites.net/blog/blazor-anchor-tag-scroll-to).
- Andrea Chiarelli [works on permission-based security for ASP.NET Web APIs](https://auth0.com/blog/permission-based-security-aspnet-webapi/).
- Sam Xu [introduces an API versioning extension with ASP.NET Core OData 8](https://devblogs.microsoft.com/odata/api-versioning-extension-with-asp-net-core-odata-8/).
- David Grace [uses the button onclick event in Blazor WebAssembly](https://www.roundthecode.com/dotnet/blazor/how-to-use-button-onclick-event-blazor-webassembly).

### 🥅 The .NET platform

- Bar Arnon [writes about the evolution of an async LINQ operator](http://blog.i3arnon.com/2021/07/12/async-linq-operator/).
- John Reilly [works with Directory.Build.props and C# 9](https://blog.johnnyreilly.com/2021/07/14/directory-build-props-c-sharp-9-for-all/).
- Oren Eini [investigates a performance issue](https://ayende.com/blog/194177-A/postmortem-the-case-of-the-pauses-the-fault-and-the-gc?Key=01e08ec5-4e36-4293-a58a-1343784f8d0e).
- Davide Bellone [works with the DebuggerDisplay attribute](https://www.code4it.dev/blog/debuggerdisplay-attribute).

### ⛅ The cloud

- Aaron Powell [calls Azure Static Web Apps authenticated API endpoints](https://techcommunity.microsoft.com/t5/apps-on-azure/calling-static-web-apps-authenticated-api-endpoints/ba-p/2536870), [works with Azure Functions, F# and CosmosDB Output Bindings](https://www.aaron-powell.com/posts/2021-07-11-functions-cosmosdb-output-bindings-and-fsharp/), and [adds user profiles to Azure Static Web Apps](https://www.aaron-powell.com/posts/2021-07-16-adding-user-profiles-to-swa/).
- Chloe Condon [makes bots with Azure Logic Apps](https://dev.to/azure/got-bots-2-making-bots-with-azure-logic-apps-47nm).
- Milan Milanović [secures the modern development lifecycle with Microsoft Identity](https://milan.milanovic.org/post/protect-web-apis-using-azure/).

### 📔 Languages

- The Code Maze blog [writes about C# tips for code quality and performance](https://code-maze.com/c-tips-to-improve-code-quality-and-performance/).
- Jason Roberts [works on init-only property setters in C#](http://dontcodetired.com/blog/post/ICYMI-C-9-New-Features-Reduce-Boilerplate-Constructor-Code-with-Init-Only-Property-Setters).
- Mike Hadlow [writes a simple console periodic loop in C#](https://mikehadlow.com/posts/simple-console-loop/).
- Adam Storr [writes about target typed new expressions in C# 9](https://adamstorr.azurewebsites.net/blog/target-typed-new-expressions-in-csharp-9-are-they-the-future).
- Anthony Giretti writes about [global usings in .NET 6 and ASP.NET Core](https://anthonygiretti.com/2021/07/18/introducing-c-10-global-usings-example-with-asp-net-core-6/).

### 🔧 Tools

- Domagoj Vidovic [runs through common Git commands](https://dev.to/domagojvidovic/11-git-commands-i-use-every-day-43eo).
- Pam Selle [tests a command inside a docker container](https://thewebivore.com/testing-a-command-inside-a-docker-container-or-getting-an-interactive-session/).
- Erik Heemskerk [creates reusable build scripts with NUKE components](https://www.erikheemskerk.nl/nuke-build-components/).
- The Kubernetes Blog [outlines Kubernetes API and feature removals In 1.22](https://kubernetes.io/blog/2021/07/14/upcoming-changes-in-kubernetes-1-22/).
- Stephane Eyskens [hardens an ASP.NET container running on Kubernetes](https://techcommunity.microsoft.com/t5/azure-developer-community-blog/hardening-an-asp-net-container-running-on-kubernetes/ba-p/2542224?WT.mc_id=DOP-MVP-4025064).
- Steve Tidwell [writes how developers should learn Kubernetes](https://thenewstack.io/why-developers-should-learn-kubernetes/).
- Khalid Abuhakmeh [shows off a better way to discover APIs with JetBrains Rider](https://blog.jetbrains.com/dotnet/2021/07/12/a-better-way-to-discover-apis-with-the-new-endpoints-window/).

### 🏗 Design, testing, and best practices

- Scott Carey [writes about how companies got their developers to care about cloud costs](https://www.arnnet.com.au/article/689569/how-5-companies-got-their-developers-care-about-cloud-costs/).
- Suzanne Scacca [writes about building trustworthy websites](https://www.telerik.com/blogs/6-things-to-make-websites-appear-more-trustworthy).
- Al Tenhundfeld [talks about writing good Git commit messages](https://www.simplethread.com/git-commit-message-101/).
- Josef Ottoson [deals with access tokens in .NET](https://josef.codes/dealing-with-access-tokens-in-dotnet/).
- Ron Jeffries asks: [Can scrum be fixed?](https://ronjeffries.com/articles/021-01ff/fix-scrum-01/)
- Jimmy Bogard [continues his series on domain-driven refactoring](https://jimmybogard.com/domain-driven-refactoring-procedural-beginnings/).
- Paul Michaels [tries out mutation testing](https://www.pmichaels.net/2021/07/10/mutation-testing/).

### 🎤 Podcasts

- The Azure Podcast [discusses cloud-native apps](http://azpodcast.azurewebsites.net/post/Episode-385-Cloud-Native-apps-in-Azure).
- The Unhandled Exception podcast [talks to Chris Sainty about Blazor](https://unhandledexceptionpodcast.com/posts/0019-blazor/).
- The Merge Conflict podcast [talks about GitHub Copilot](https://www.mergeconflict.fm/262).
- The 6-Figure Developer podcast [talks to Jon Douglas](https://6figuredev.com/podcast/episode-203-nuget-and-tiktok-with-jon-douglas/).
- Scott Hanselman [talks to Maria Naggaga about teaching computer science](https://www.hanselminutes.com/797/new-ways-to-teach-computer-science-with-maria-naggaga).
- The No Dogma Podcast [talks to David Guida about event sourcing](https://nodogmapodcast.bryanhogan.net/155-david-guida-event-sourcing/).

### 🎥 Videos

- Azure Friday [talks about several Azure Cosmos DB updates](https://channel9.msdn.com/Shows/Azure-Friday/Azure-Cosmos-DB-cache-serverless-MongoDB-and-Managed-Apache-Cassandra).
- Data Exposed [uses SQL Data Sync](https://channel9.msdn.com/Shows/Data-Exposed/Using-SQL-Data-Sync-for-Bidirectional-Data-Replication-in-SQL-Server-and-Azure-SQL-DBs).
- The On .NET Show [discusses commands, queries, and Clean Architecture](https://www.youtube.com/watch?v=IRvDGPbxdTs), [positional pattern matching](https://www.youtube.com/watch?v=tnepPn3Py8s), and [explores Spark and ML .NET with F#](https://www.youtube.com/watch?v=Z7KVKHZsWyM).
- Technology and Friends [talks to Jason Bock about mutation testing](https://www.davidgiard.com/2021/07/12/JasonBockOnMutationTesting.aspx).