C# 15 Union Types vs. the Discriminated-Union Workarounds They Replace
A short comparison of C# 15 union types against the discriminated-union workarounds .NET teams have shipped for years: sealed record hierarchies, OneOf-style generic chains, source-generated unions, visitor interfaces, and bool and out tuples. It walks through the same three-case order lookup, shows how a discard arm can silence CS8509 and turn a new case into a 500, and explains why the union proposal moves closedness into the declaration and makes exhaustiveness the compiler's job. It closes with the post's rule: adopt unions aggressively inside assemblies, stay conservative at the wire boundary until serialization and AOT behavior are verified, and measure tooling claims yourself. Caveat from the source: union syntax and exhaustiveness rules are proposal-shaped, not compiler-verified. Read the full comparison: https://hackyjs.com/posts/c-15-union-types-compared-with-the-discriminated-union-workarounds-they-replace