A typical endpoint has several ways to end: it worked, the thing was missing, the input was bad. Most code expresses that with exceptions, or with a handler that returns an untyped IResult and hopes every branch picked the right status. Nothing tells the compiler which outcomes exist, so nothing can tell you when you forgot one.
.NET 11 ships C# 15 as the default language version for net11.0 , and C# 15 adds a union declaration. I built a small fee calculator API where every endpoint returns a closed list of outcomes, and the compiler checks that each outcome is turned into an HTTP status . A forgotten case fails the build instead of reaching production.
🧪 Synthetic data only. Findings are from .NET SDK 11.0.100 and Microsoft.AspNetCore.OpenApi 11.0.0. The union compiled with no preview switch.
Full code:
.NET 11 Web Samples
Three small ASP.NET Core 11 projects that try what is new on the web side of .NET 11, and write down what worked, what surprised me and what did not. All data is synthetic.…