# March 9, 2025

## 1.12.0-rc17

**`(fix):`** Generate snippets for unions when `use-discriminated-unions` is `true` in the generator configuration.

## 1.12.0-rc16

**`(fix):`** Remove hardcoded namespace import from JsonElementComparer.cs

## 1.12.0-rc15

**`(feat):`** Generate **discriminated unions** with:

* Type safety with compile-time checking
* Exhaustive discriminant value matching
* JSON serialization support

Here's a simple example how to use a shape discriminated union:

```csharp
var shape = new Shape(new Circle { Radius = 5 });

// Type checking
if (shape.IsCircle) {
    Console.WriteLine($"Radius: {circle.AsCircle().Radius}");
}

// Discriminant value matching
var area = shape.Match(
    circle => Math.PI * circle.Radius * circle.Radius,
    square => square.Length * square.Length,
    (type, _) => throw new NotSupportedException($"Unknown: {type}")
);

// TryAs pattern
if (shape.TryAsCircle(out var circle)) {
    Console.WriteLine($"Radius: {circle.Radius}");
}
```

This feature is off by default for backward compatibility.
To enable it, set `use-discriminated-unions` to `true` in the generator configuration.

**`(feat):`** Improved serialization tests for generated classes for normal objects and discriminated unions.

**`(feat):`** Generated classes now follow the C# convention for odering consts, fields, constructors, properties, methods, operators, and inner classes.