{"slug": "net-11-preview-5-brings-file-based-app-improvements-new-c-features-and-a-blazor", "title": ".NET 11 Preview 5: Brings File-Based App Improvements, New C# Features, and a Blazor Validation Wave", "summary": "Microsoft released .NET 11 Preview 5, introducing file-based app improvements, new C# features like closed classes and union declarations, and Blazor client-side validation. The update also includes SDK enhancements, ASP.NET Core Blazor updates, and .NET MAUI reliability fixes.", "body_md": "Last week, Microsoft has released the [fifth preview of .NET 11](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/README.md), delivering updates across the runtime, SDK, libraries, ASP.NET Core, .NET MAUI, C#, and Entity Framework Core.\n\nThe .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](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/sdk.md#file-based-apps-can-reference-other-c-files), 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.\n\nThe SDK also bundles the [Model Context Protocol](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/sdk.md#dotnet-new-includes-the-mcp-server-template) 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.\n\n[Console and worker apps](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/sdk.md#console-apps-include-systemnethttpjson-by-default)that target\n\n*net11.0*now include\n\n*System.Net.Http.Json*automatically when implicit usings are enabled.\n\nThe [C# language](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/csharp.md#c-in-net-11-preview-5---release-notes) 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.\n\n```\npublic closed record class GateState;\npublic record class Closed : GateState;\npublic record class Open(float Percent) : GateState;\n\nstatic string Describe(GateState state) => state switch\n{\n    Closed => \"closed\",\n    Open(var percent) => $\"{percent}% open\"\n};\n```\n\nA new [union declaration](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/csharp.md#union-declarations-and-union-patterns) creates a value type that holds one of a fixed set of case types, with pattern matching support. Work also continues on [Unsafe Evolution](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/csharp.md#unsafe-evolution), which allows pointer types to appear outside an unsafe context while keeping the unsafe boundary on operations that read unmanaged memory.\n\n```\nint value = 42;\nint* pointer = &value;\n\nunsafe\n{\n    System.Console.WriteLine(*pointer);\n}\n```\n\nNext, [ASP.NET Core](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/aspnetcore.md) focuses heavily on Blazor. Server-side rendered forms now support instant [client-side validation](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/aspnetcore.md#blazor-ssr-supports-client-side-validation) without a server round-trip, and forms gain support for async validation rules such as database lookups.\n\nValidation messages and property names can be localized. [QuickGrid](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/aspnetcore.md#quickgrid-works-without-interactivity) sorting and pagination now work on statically rendered pages, and also the standalone Blazor WebAssembly apps get a new development server called the [Gateway](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/aspnetcore.md#blazor-webassembly-gateway), which adds built-in SPA fallback routing.\n\nFuthermore, [.NET MAUI](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/dotnetmaui.md) receives a large reliability rollup that, according to the source, fixes dozens of reported issues across controls such as *CollectionView*, *Shell*, and *Label*.\n\n[Animation methods](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/dotnetmaui.md#animations-get-cancellationtoken-aware-overloads) 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.\n\n[Entity Framework Core](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/efcore.md) adds support for file-based apps in the [ dotnet ef tool](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/efcore.md#dotnet-ef-supports-file-based-apps) 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.\n\nOther 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.\n\nFor interested readers, the [full release notes](https://github.com/dotnet/core/blob/main/release-notes/11.0/preview/preview5/README.md) are available on the [dotnet/core repository](https://github.com/dotnet/core) on GitHub.", "url": "https://wpnews.pro/news/net-11-preview-5-brings-file-based-app-improvements-new-c-features-and-a-blazor", "canonical_source": "https://www.infoq.com/news/2026/06/dotnet-11-preview-5/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=global", "published_at": "2026-06-19 08:00:00+00:00", "updated_at": "2026-06-19 08:29:46.218599+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Microsoft", ".NET 11", "ASP.NET Core", "Blazor", ".NET MAUI", "Entity Framework Core", "C#", "NuGet"], "alternates": {"html": "https://wpnews.pro/news/net-11-preview-5-brings-file-based-app-improvements-new-c-features-and-a-blazor", "markdown": "https://wpnews.pro/news/net-11-preview-5-brings-file-based-app-improvements-new-c-features-and-a-blazor.md", "text": "https://wpnews.pro/news/net-11-preview-5-brings-file-based-app-improvements-new-c-features-and-a-blazor.txt", "jsonld": "https://wpnews.pro/news/net-11-preview-5-brings-file-based-app-improvements-new-c-features-and-a-blazor.jsonld"}}