From b3a256ff28977ffe970a4dccc622c102a20e33f5 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Wed, 23 Sep 2026 15:28:30 +0300 Subject: [PATCH] Rename intro section headings in C# 15 unions article Co-authored-by: Cursor --- .../post.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/en/Community-Articles/2026-09-23-csharp-15-union-types-and-closed-hierarchies/post.md b/docs/en/Community-Articles/2026-09-23-csharp-15-union-types-and-closed-hierarchies/post.md index fb11ae1d26..7a647b8b07 100644 --- a/docs/en/Community-Articles/2026-09-23-csharp-15-union-types-and-closed-hierarchies/post.md +++ b/docs/en/Community-Articles/2026-09-23-csharp-15-union-types-and-closed-hierarchies/post.md @@ -23,8 +23,8 @@ In this article, we'll start with the simplest possible usage of each feature, l Here's what we'll cover: - Where .NET 11 and C# 15 stand today -- Closed hierarchies: the two-minute version -- Union types: the two-minute version +- Closed hierarchies: a simple example and the rules +- Union types: a simple example and what they compile to - How they compare with enums, abstract base classes, interfaces, and result wrappers - A realistic scenario: an order API with exhaustive states and results - Going further: JSON contracts, a generic `Result`, `default` values, and versioning @@ -44,7 +44,7 @@ A quick status check first, because it affects everything else in this article: > **For ABP developers:** the latest stable ABP release on NuGet at the time of writing is **10.6.1**, and ABP 10.x packages target up to `net10.0`. You need a `net11.0` project to use C# 15. As usual, ABP will ship a **.NET 11-based ABP 11** release, so you'll get first-class .NET 11 support there. Until then, I tested ABP 10.6.1 packages inside a `net11.0` app, and you'll find the results in the [ABP section](#using-these-features-in-an-abp-solution) below. -## Closed Hierarchies: The Two-Minute Version +## Closed Hierarchies: A Simple Example Let's start with the easier one. You add the `closed` modifier to a class (or a record class), and from then on, **only code in the same assembly can derive directly from it**: @@ -84,7 +84,7 @@ Here are the rules I think are worth remembering. The ones with error codes are So what does the compiler actually emit? I checked with reflection. `OrderState` becomes a regular **abstract class** marked with `[IsClosedType]`, and its constructors are `protected` and marked `[CompilerFeatureRequired("ClosedClasses")]`. That last attribute is how the restriction survives compilation: a compiler that doesn't understand closed classes refuses to call those constructors, so it can't derive from the type either. -## Union Types: The Two-Minute Version +## Union Types: A Simple Example A union is a value that is **exactly one of a fixed list of case types**. The case types already exist, and the union just groups them: