I have a soft spot for any .NET release that lets me delete an extension method. .NET 11 landed on November 10, and the one I’d go looking for is FullOuterJoin in the team’s LinqExtensions.cs file. If you’re thinking “wait, didn’t LINQ already have that?”, try answering this in one query. Which orders are missing a payment, and which payments are missing an order? It’s the and that gets you. Microsoft’s .NET 11 announcement
The receipt for order A103
Say the shop has two orders and the payment provider sends over two receipts. Each receipt has our order ID on it. Both sides agree we sold two things, which is reassuring right up until you look at the IDs.
string[] orders = ["A101", "A102"];string[] receipts = ["A101", "A103"];var rows = orders.FullJoin(receipts, id => id, id => id);foreach (var (order, receipt) in rows){ Console.WriteLine($"{order ?? "-"} | {receipt ?? "-"}");}
The first row is A101 | A101. Good, someone bought something and paid for it. Then there’s A102 | -, an order we have no receipt for. A left join from orders would have found that one too. The row I care about is - | A103. Someone has a receipt from our shop, their money is gone, and as far as our database is concerned their order doesn’t exist. An inner join would have given us one lovely, perfectly matching row to put in a completely useless report. FullJoin keeps all three. This example runs in memory. If yours runs through EF Core 11, check that your provider translates it and have a look at the SQL. LINQ reference · EF Core 11 query changes
What am I supposed to do with false?
Here’s a return type I’d question in a code review. CancelOrderAsync returns Task<bool>. I know what to do with true. What am I supposed to tell the customer when I get false? “We couldn’t find your order” and “your order is already on a truck” are two very different emails. In the second one I’d quite like to include the tracking number. C# 15 is the default when you target net11.0, so we can give each answer a type.
public sealed record Cancelled;public sealed record OrderMissing;public sealed record AlreadyShipped(string TrackingNumber);public union CancelOrderResult(Cancelled, OrderMissing, AlreadyShipped);
Now CancelOrderAsync can return Task<CancelOrderResult>. The order service knows whether the parcel shipped. The endpoint knows what a 409 is. Here’s the whole translation in a Minimal API, using the types from Microsoft.AspNetCore.Http.HttpResults.
static Results<NoContent, NotFound, Conflict<AlreadyShipped>> ToHttp(CancelOrderResult result) => result switch { Cancelled => TypedResults.NoContent(), OrderMissing => TypedResults.NotFound(), AlreadyShipped shipped => TypedResults.Conflict(shipped) };
I’d leave the _ arm out of this switch on purpose. Say we start allowing cancellations only within the first hour. Someone adds CancellationWindowExpired to the union, hits build, and gets a warning right here, where we owe the customer an explanation. I’d much rather get that warning while I still have the ticket open. I went into the mechanics in C# 15 Union Types.
I’d like to see my own method names
Open a profiler on that cancellation endpoint and you might find yourself squinting at MoveNext. You don’t remember writing a method called MoveNext, because the compiler wrote it for the async state machine. What you wanted to find was LoadShipmentAsync. With Runtime Async, the runtime handles suspending and resuming the method, and the live call stack can show the method names you actually recognize. If you’re wondering why the last exception you logged already looked fine, exception stack traces have hidden a lot of that plumbing for years. Try this in a debugger or profiler where you can see the stack live. Runtime Async documentation
The .NET runtime libraries already use Runtime Async. For our own code it’s still in preview. To try it, add <Features>runtime-async=on</Features> inside a <PropertyGroup> in a net11.0 project. I’d pick a request I’ve had trouble profiling and capture it twice, once each way. Can I follow the calls more easily? Did the allocations change? Those are things I can check before I decide whether to keep the setting.
Would I upgrade?
One detail I’d bring up if this came up in sprint planning is that .NET 10 LTS and .NET 11 STS both reach end of support on November 14, 2028. If our service is happily running on .NET 10, the calendar gives us no reason to move this week. Give me a ticket to change the cancellation rules, though, and I’d try .NET 11 on that branch. I want to be able to add a fourth outcome, hit build, and let the compiler remind me which bit of the API I’ve forgotten. Microsoft’s support dates
Affiliate promo
If you love learning new stuff and want to support me, consider buying a course from Dometrain using this link: Browse courses – Dometrain. Thank you!
Leave a Reply