Final week, Microsoft’s crew launched .NET 11 Preview 7, an replace that brings adjustments and enhancements to the C# language, ASP.NET Core, .NET MAUI, Entity Framework Core, Home windows Varieties, and F#.
Within the C# space, the break and continue statements can now title an enclosing loop or change, so code can go away or proceed an outer assemble instantly from an interior one with no flag or a goto.
string? foundValue = null;
outer: for (int x = 0; x < xMax; x++)
{
for (int y = 0; y < yMax; y++)
{
if (GetValue(x, y) is { } worth && worth == goal)
{
foundValue = worth;
break outer;
}
}
}
Additionally, the Union types, nonetheless a preview function, now use a try-both method that first exams a sample towards the union itself after which towards its contained worth.
Correspondingly, switch-expression exhaustiveness additionally understands generic parameters constrained to a closed sort, so the compiler not warns when each derived case is dealt with. Additional work refines the Unsafe Evolution rules and provides a null check to inline-array helpers, so forming a reference from a null buffer now throws deterministically.
public closed file class Form;
public file class Circle(double Radius) : Form;
public file class Sq.(double Facet) : Form;
static double Space(T form) the place T : Form => form change
{
Circle(var r) => Math.PI * r * r,
Sq.(var s) => s * s
};
ASP.NET Core receives a large set of additives, most of them centred on Blazor. Interactive Server circuits can now pause themselves when a browser tab is hidden, releasing server sources till the person returns. A brand new CacheView component caches the rendered output of a server-side subtree, replaying saved HTML on a cache hit to chop processor and reminiscence use.
Moreover, five new Blazor analyzers ship on by default to flag widespread errors, and QuickGrid beneficial properties programmatic scrolling. Validation message localization is now inbuilt and prompts as quickly as a string localizer is registered, whereas the ValidatableType and SkipValidation attributes go away preview.
The SignalR .NET consumer can refresh authentication after a negotiate redirect, endpoints that return server-sent occasions are described in OpenAPI 3.2, and functions can learn the TLS channel-binding token to defend towards relay assaults.
One notable change reverses a part of Preview 6: automated cross-origin safety now validates solely endpoints that decide in, matching .NET 10 behaviour so present apps will not be damaged.
For .NET MAUI, Preview 7 provides cross-platform passkey authentication, XAML Incremental Scorching Reload, and Shell route templates,
Subsequent, Entity Framework Core now interprets int.Parse and associated strategies to a SQL Server CAST, rewrites a number of GroupBy patterns into single joins for cleaner queries, and likewise provides help for the 16-bit Half type on SQLite.
As reported, the Azure Cosmos DB supplier is modernised to make use of System.Text.Json, additionally, the Package Manager Console beneficial properties a -NoBuild change for including and making use of migrations.
Home windows Varieties introduces an opt-in fashionable rendering pipeline via VisualStylesMode, together with a method to react to system visible settings, deferred form reveal to keep away from, as reported, an unstyled flash at startup, and a SuspendPainting scope that reduces flicker throughout bulk updates.
The F# programming language receives minor compiler fixes, together with help for computation-expression bindings inside a plain let and proper attribute decision in recursive modules.
For readers and builders, the total launch notes for .NET 11 Preview 7 can be found on the dotnet/core repository on GitHub.