We're living in a time, Dragon Ball Z in AR in your living room! It maps to your room space, and this one surprisingly runs on Quest Link. Yup, the Meta Quest Link PC app, in passthrough
Union types are coming in C# 15.
I've wanted this one for years.
I've written a lot about the Result pattern. Take a method as small as GetUser(42). Its return type says User. You have to open the method to find out it throws if user 42 doesn't exist. That's a lot to hide in a lookup.
With a union, I can give GetUser a return type called UserResult with two cases. I can return a User or a NotFound. At the endpoint, I switch on the result. A User gets a 200. NotFound(42) gets a 404, and I still have the ID that was missing.
The part I'm most excited about comes later. Say we add a third case. The compiler can point me to the switch expressions that still handle only two. I get to fix those while the change is fresh in my head.
Here's how to get started with union types: https://t.co/a5dfwfONX7
.NET 11 and C# 15 will be released tomorrow.
And C# finally gets the feature developers have asked for over a decade 👇
.NET 11 is a Standard-Term Support (STS) release.
STS releases now get 24 months of support, so .NET 11 is supported until November 2028.
Here are 2 features I'm most excited about.
👉 𝗨𝗻𝗶𝗼𝗻 𝗧𝘆𝗽𝗲𝘀
A union says a value is exactly one of a fixed set of types:
public union PaymentMethod(CreditCard, PayPal, BankTransfer);
The case types don't need a common base class.
The compiler checks that your switch expression handles every case. You don't need a default branch.
Add a 4th payment method later → every switch that misses it gets a compiler warning.
Before C# 15, you had 3 weak options:
• object, which accepts anything
• A marker interface or base class, which anyone can extend
• A 3rd party library that emulates unions
👉 𝗥𝘂𝗻𝘁𝗶𝗺𝗲 𝗔𝘀𝘆𝗻𝗰
Since C# 5, the compiler has turned every async method into a hidden state machine class. And you paid in latency and garbage collection for each async-await call.
In .NET 11, the runtime handles async by itself.
According to Microsoft's .NET 11 performance post:
→ Live stack traces: 13 frames → 5 frames
→ Sync completion: 21.2 ns and 144 B → 6.2 ns and 0 B
→ Exceptions through 30 async layers: 51.3 μs → 10.7 μs
The best part: the .NET libraries are already compiled with Runtime Async.
So part of the speed-up comes for free in every .NET 11 app.
Tomorrow, I'll share with 28,000+ developers:
→ What's New in .NET 11
→ What's New in C# 15
→ What's New in .NET 11 Libraries
→ What's New in ASP .NET Core 11
→ What's New in EF Core 11
→ Breaking changes to check before you upgrade
📌 Subscribe to my weekly newsletter to get it first:
↳ https://t.co/jZVrU0xYhM