BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News .NET 11 Preview 5: Brings File-Based App Improvements, New C# Features, and a Blazor Validation Wave

.NET 11 Preview 5: Brings File-Based App Improvements, New C# Features, and a Blazor Validation Wave

Listen to this article -  0:00

Last week, Microsoft has released the fifth preview of .NET 11, delivering updates across the runtime, SDK, libraries, ASP.NET Core, .NET MAUI, C#, and Entity Framework Core.

The .NET SDK gains several improvements for file-based apps. According to the release notes, developers can now split code across files using the new #:ref directive, which references another file-based app as a library, without first creating a project. More command-line tools, including package and NuGet commands, now understand file-based app paths.

The SDK also bundles the Model Context Protocol server template, so dotnet new mcpserver works without a separate package. Also, projects can opt in to checks that warn when the installed SDK has known vulnerabilities or has reached end of life. Console and worker apps that target net11.0 now include System.Net.Http.Json automatically when implicit usings are enabled.

The C# language receives three notable additions, all still in preview. A closed class can only be derived from within the same assembly, which, as stated in the documentation, lets the compiler verify that switch expressions handle every case.

public closed record class GateState;
public record class Closed : GateState;
public record class Open(float Percent) : GateState;

static string Describe(GateState state) => state switch
{
    Closed => "closed",
    Open(var percent) => $"{percent}% open"
};

A new union declaration creates a value type that holds one of a fixed set of case types, with pattern matching support. Work also continues on Unsafe Evolution, which allows pointer types to appear outside an unsafe context while keeping the unsafe boundary on operations that read unmanaged memory.

int value = 42;
int* pointer = &value;

unsafe
{
    System.Console.WriteLine(*pointer);
}

Next, ASP.NET Core focuses heavily on Blazor. Server-side rendered forms now support instant client-side validation without a server round-trip, and forms gain support for async validation rules such as database lookups.

Validation messages and property names can be localized. QuickGrid sorting and pagination now work on statically rendered pages, and also the standalone Blazor WebAssembly apps get a new development server called the Gateway, which adds built-in SPA fallback routing.

Futhermore, .NET MAUI receives a large reliability rollup that, according to the source, fixes dozens of reported issues across controls such as CollectionView, Shell, and Label.

Animation methods gain CancellationToken-aware overloads. Regarding the controls, sveral of them recieves updates, BoxView adds a Fill property that accepts brushes, and the Windows Map control now has a real implementation backed by Azure Maps. The minimum Android version rises to API 24, and Apple Intelligence APIs ship in Essentials.AI.

Entity Framework Core adds support for file-based apps in the dotnet ef tool and a configuration file for storing default options. A new analyzer warning, EF1004, flags async queries that would run synchronously. The SQL Server 2022 compatibility is now the default, and generated C# uses file-scoped namespaces.

Other changes in this release are stricter container registry authentication validation, an opt-in Native AOT mode for the CLI, cleaner SQL query translation in EF Core, and the disabling of ANSI output during dotnet test in LLM environments.

For interested readers, the full release notes are available on the dotnet/core repository on GitHub.

About the Author

Rate this Article

Adoption
Style

BT