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. Dan Roth writes about ASP.NET Core updates, Jeremy Likness updates us on EF Core 6, and David Ortinau covers .NET MAUI. 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 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. You do this by using a new [EditorRequired]
attribute, like this:
[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 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. 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.
Minimal API improvements. We've talked about .NET 6 Minimal APIs 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. You can do this using dependency injection (DI) or middleware. Here's an example using the DI method:
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:
app.MapGet("/movies", async ([FromServices] MovieDbContext db) =>
{
return await db.Movies.ToListAsync();
});
And now it's this:
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, 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:
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. 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 for .NET 6. In this release, the team is rolling out gesture recognizers, clipping region enhancements, and native alerts. Check out the announcement 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. 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. 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, 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, 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.
- Peter Kuhn conveys his thoughts on Microsoft and Blazor.
- Andrew Lock starts a deep dive on StringBuilder.
- Iris Classon writes that the nominations are open for the .NET Foundation Board of Directors 2021 election.
📢 Announcements
- Richard Lander announces .NET 6 Preview 6. Daniel Roth walks through ASP.NET Core updates, Jeremy Likness announces updates for EF Core 6, and David Ortinau writes about .NET MAUI updates for .NET 6 Preview 6.
- Visual Studio 2022 Preview 2 has arrived.
- Kayla Cinnamon rolls out the Windows Terminal Preview 1.10 release.
📅 Community and events
- Joe Guadagno reviews Software Architecture with C# 9 and .NET 5.
- Brandon Minnick writes about the future of the Xamarin Community Toolkit.
- The Focus on F# agenda is out.
- JetBrains is looking for feedback on dotMemory and dotTrace.
- For community standups: .NET Tooling updates on the latest, ASP.NET talks Powered4.tv and Entity Framework visualizes database query plans.
- The .NET Docs Show talks to Isaac Abraham about F#.
🌎 Web development
- Peter Kuhn works on Blazor Server apps in MVC subfolders.
- Jay Krishna Reddy creates and validates a JWT token in .NET 5.0.
- Cody Merritt Anhorn uses Blazor to scroll to a hash anchor on the current page.
- Andrea Chiarelli works on permission-based security for ASP.NET Web APIs.
- Sam Xu introduces an API versioning extension with ASP.NET Core OData 8.
- David Grace uses the button onclick event in Blazor WebAssembly.
🥅 The .NET platform
- Bar Arnon writes about the evolution of an async LINQ operator.
- John Reilly works with Directory.Build.props and C# 9.
- Oren Eini investigates a performance issue.
- Davide Bellone works with the DebuggerDisplay attribute.
⛅ The cloud
- Aaron Powell calls Azure Static Web Apps authenticated API endpoints, works with Azure Functions, F# and CosmosDB Output Bindings, and adds user profiles to Azure Static Web Apps.
- Chloe Condon makes bots with Azure Logic Apps.
- Milan Milanović secures the modern development lifecycle with Microsoft Identity.
📔 Languages
- The Code Maze blog writes about C# tips for code quality and performance.
- Jason Roberts works on init-only property setters in C#.
- Mike Hadlow writes a simple console periodic loop in C#.
- Adam Storr writes about target typed new expressions in C# 9.
- Anthony Giretti writes about global usings in .NET 6 and ASP.NET Core.
🔧 Tools
- Domagoj Vidovic runs through common Git commands.
- Pam Selle tests a command inside a docker container.
- Erik Heemskerk creates reusable build scripts with NUKE components.
- The Kubernetes Blog outlines Kubernetes API and feature removals In 1.22.
- Stephane Eyskens hardens an ASP.NET container running on Kubernetes.
- Steve Tidwell writes how developers should learn Kubernetes.
- Khalid Abuhakmeh shows off a better way to discover APIs with JetBrains Rider.
🏗 Design, testing, and best practices
- Scott Carey writes about how companies got their developers to care about cloud costs.
- Suzanne Scacca writes about building trustworthy websites.
- Al Tenhundfeld talks about writing good Git commit messages.
- Josef Ottoson deals with access tokens in .NET.
- Ron Jeffries asks: Can scrum be fixed?
- Jimmy Bogard continues his series on domain-driven refactoring.
- Paul Michaels tries out mutation testing.
🎤 Podcasts
- The Azure Podcast discusses cloud-native apps.
- The Unhandled Exception podcast talks to Chris Sainty about Blazor.
- The Merge Conflict podcast talks about GitHub Copilot.
- The 6-Figure Developer podcast talks to Jon Douglas.
- Scott Hanselman talks to Maria Naggaga about teaching computer science.
- The No Dogma Podcast talks to David Guida about event sourcing.
🎥 Videos
- Azure Friday talks about several Azure Cosmos DB updates.
- Data Exposed uses SQL Data Sync.
- The On .NET Show discusses commands, queries, and Clean Architecture, positional pattern matching, and explores Spark and ML .NET with F#.
- Technology and Friends talks to Jason Bock about mutation testing.
Top comments (1)
Hear hear.