The .NET Stacks #50: 🆕 What's new with C# 10?
This week we see what's coming with C# 10, talk about Azure Static Web Apps, and more.
NOTE: This is the web version of my weekly newsletter, released on May 17, 2021. To get the issues right away, subscribe at dotnetstacks.com or the bottom of this post.
Happy Monday! I hope you have a good week. Here's what we have this week:
- The big thing: Checking in on C# 10
- The little things: Azure Static Web Apps goes GA, JetBrains .NET days, .NET 6 FileStream improvements, JSON schema validation
- Last week in the .NET world
The big thing: Checking in on C# 10
Last week, Ken Bonny wrote a post highlighting some new C# 10 features. Of course, it's still a little early, and not all of these changes might make it in. But if language designer Mads Torgersen talks about them publicly, there's a good probability they will.
Ever since Microsoft rolled out records with C# 9, the community has been asking for record struct types. With the C# 9 release of records, the
record type is a reference type that enforces value-like behaviors. With C# 10, the team is rolling out a
record struct variant that makes the underlying type a value type. So, with a record struct, values will be copied over instead of by reference. Also, on the topic of records, you'll be able to add operators to them.
Apart from this, Ken recaps what else is (probably) coming:
- Flagging properties of classes, structs, records, or record structs as
- A new
fieldkeyword that can eliminate backing fields
- Enabling a single file to enable namespace imports
- Improvements with lambda attributes and lambda signature inference
There's a lot more with Ken's post, with some good code examples. Make sure to check it out to see what's coming with C# 10.
The little things: Azure Static Web Apps goes GA, JetBrains .NET days, .NET 6 FileStream improvements, JSON schema validation
This week, I recapped my favorite things about Azure Static Web Apps—some I knew previously and some I learned about this week. I'm most impressed with the local development story. When using an Azure Static Web Apps CLI, you can leverage a static site server, a proxy to your API endpoints, and a mock authentication and authorization server.
Azure Static Web Apps is now shipping with a Standard tier. For 9 USD/month, you can take advantage of a 99.95% SLA and a "bring your own Functions" model. I find the latter to be most valuable, especially when you want to leverage other Azure Functions triggers (by default, you can only use HTTP triggers with Azure Static Web Apps).
JetBrains hosted their .NET Days conference this week (online, of course). JetBrains always hosts first-class community events, and this was no different. You can check out all the sessions on YouTube.
On Day 1, folks talked about C# source generators, debugging .NET apps, writing high-performance code, Azure CosmosDB and React, gRPC in .NET, GraphQL and Blazor, and using .NET and Dapper.
On Day 2, we learned about the 10 best C# features, F#, legacy refactoring, using null and void in .NET, async and await best practices, debugging with JetBrains Rider, and containerizing with Kubernetes.
I'm getting a little antsy about the release of .NET 6 Preview 4. Since Preview 3 was shipped five weeks ago, and Microsoft aims for a new preview release every month or so, we'll see Preview 4 very soon. It'll be jam-packed with updates for minimal APIs, AOT support, and more.
We'll also see improvements to
FileStream. The .NET team is rewriting the library, focusing on Windows (as the Unix implementation, built 20 years later, was already fast). With these changes, the team notes that when used with async I/O, it now never performs blocking work.
"Dave, shut up and show us the benchmarks!" OK, fine:
Look at those allocations! In the example above, reading a 1 MB file is 2.5x faster, and writing is 5.5x faster.
When it comes to serialization with .NET, you've got a few options: mostly, the tried-and-true Newtonsoft.Json (which just surpassed a billion NuGet downloads) and the native System.Text.Json library. Unfortunately, with System.Text.Json, there's no easy way to perform JSON schema validation, and schema validation is a paid feature with Newtonsoft.Json. (There are also quite a few third-party options for schema validation as well.)
This week, Matthew Adams wrote a wonderful post on achieving schema validation with System.Text.Json. He used code generation to create .NET types that represent the structure of the schema (with strongly typed accessors for properties, array/list elements, and so on).
🌎 Last week in the .NET world
This week, we learn more about Azure Static Web Apps, GitHub Actions, modular monoliths, and more.
🔥 The Top 3
- Derek Comartin recaps using Problem Details in ASP.NET Core Web API.
- Steve Gordon introduces GitHub Actions for .NET developers and writes about string manipulation in C#.
- Jon P. Smith continues his series on evolving modular monoliths.
- Microsoft announces the GA release of Azure Static Web Apps.
- Auth0 introduces Auth0 Actions.
- Microsoft announces the May updates for the .NET Framework.
📅 Community and events
- Thomas Claudius Huber introduces a new MVVM library.
- InfoQ talks to Jeremy Likness about EF Core.
- David Ramel writes about Mercury, a "modern Visual Basic."
- For community standups: Languages & Runtime talks about source generation, and Machine Learning differentiates between a data scientist and a data engineer.
- The .NET Docs Show discusses mobile accessibility.
🌎 Web development
- Adam Storr tests HttpClient.
- Muhammed Saleem integrates Azure Cosmos DB with ASP.NET Core Web API.
- David Grace creates a tic-tac-toe game in Blazor.
- Damien Bowden presents and verifies verifiable credentials in ASP.NET Core using decentralized identities and MATTR.
- Burak Guzel writes a primer on HTTP headers.
- Jason Beres compares Blazor to React.
- Calvin Allen works on real-time updates with Postgres and SignalR.
🥅 The .NET platform
- Tomasz Pęczek streams JSON Objects (NDJSON) with HttpClient.
- Paul DeVito builds an event-driven .NET application.
- Kristoffer Strube uses the PriorityQueue in .NET 6.
- Ken Bonny introduces C# 10.
⛅ The cloud
- Daniel Krzyczkowski continues writing about Azure Identity.
- John Reilly creates a pipeline with the Azure DevOps API.
- Mark Heath runs Durable Functions locally with Azurite.
- Dave Brock recaps his favorite things about Azure Static Web Apps.
- Aaron Powell uses Okta with Azure Static Web Apps.
- Jeff Fritz writes about C# project structure.
- Sasha Mathews offers quick tips to improve C# performance.
- Matthew Adams works on C# serialization with JsonSchema and System.Text.Json.
- Kirtesh Shah writes about C# pattern matching.
- Khalid Abuhakmeh solves for the next DayOfWeek from DateTime.
- Josef Ottosson transforms C# objects to a flat string dictionary.
- Matthew Jones uses C# named arguments to handle complex tests.
- Brian Lagunas walks through async yield return in C#.
- David Ramel recaps free testing tools for Visual Studio 2019.
- Abhijit Jana reminds us that Visual Studio can add using directives automatically on paste.
- Aaron Stannard writes about integrating Akka.NET with ASP.NET Core and SignalR.
- Patrick Smacchia writes about the impacts of 64-bit Visual Studio 2022.
- Steve Smith fetches an upstream branch in GitHub.
- The Productive C# podcast talks about global usings in C# 10.
- The Coding Blocks podcast talks about making money with code.
- The 6-Figure Developer podcast discusses Orleans with Reuben Bond.
- The .NET Rocks podcast discusses Visual Studio 2022.
- The Azure DevOps podcast talks about customizing build agents.
- Azure Enablement plans for cloud adoption.
- The On .NET Show talks about supporting VB.NET in .NET 5 and C# ranges.
- Visual Studio Toolbox talks about Project Reunion.