Ferrous.Unions
2.3.0
dotnet add package Ferrous.Unions --version 2.3.0
NuGet\Install-Package Ferrous.Unions -Version 2.3.0
<PackageReference Include="Ferrous.Unions" Version="2.3.0" />
<PackageVersion Include="Ferrous.Unions" Version="2.3.0" />
<PackageReference Include="Ferrous.Unions" />
paket add Ferrous.Unions --version 2.3.0
#r "nuget: Ferrous.Unions, 2.3.0"
#:package Ferrous.Unions@2.3.0
#addin nuget:?package=Ferrous.Unions&version=2.3.0
#tool nuget:?package=Ferrous.Unions&version=2.3.0
Ferrous.Unions
Incremental Roslyn source generator (IIncrementalGenerator) for zero-boxing discriminated unions in .NET—with exhaustive Match, TryGet*, structural equality, duplicate payload type support, and automatic .NET 11 / C# 15 [Union] light-up for native exhaustive switch expressions.
Installation
dotnet add package Ferrous.Unions
Quick Example
using Ferrous;
[DiscriminatedUnion]
public readonly partial struct Shape
{
public static partial Shape Circle(double radius);
public static partial Shape Rect(double width, double height);
public static partial Shape Point();
}
// Exhaustive Match works on both .NET 10 and .NET 11
double area = Shape.Circle(3.0).Match(
onCircle: r => Math.PI * r * r,
onRect: (w, h) => w * h,
onPoint: () => 0.0);
// On .NET 11 / C# 15, native exhaustive `switch` lights up automatically!
double areaNet11 = Shape.Circle(3.0) switch
{
Shape.CircleCase c => Math.PI * c.radius * c.radius,
Shape.RectCase r => r.width * r.height,
Shape.PointCase => 0.0,
};
See the Discriminated Unions Guide and Ferrous Repository for full documentation.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Ferrous.Core (>= 2.3.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Ferrous.Unions:
| Package | Downloads |
|---|---|
|
Ferrous
Rust-grade compile-time safety, zero-allocation primitives, source generators, and Clippy-style Roslyn analyzers for .NET (polyfilling on .NET 10 and lighting up natively on .NET 11 / C# 15). |
|
|
Ferrous.Testing
Rust-grade testing utilities for .NET: in-memory compile-fail assertions (CompileAssert, like Rust's trybuild), framework-agnostic Result/Option assertions, and zero-allocation assertions (AllocAssert). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.0 | 0 | 11/30/2026 |
| 2.2.0 | 0 | 11/30/2026 |
| 2.1.0 | 0 | 11/30/2026 |
| 2.0.0 | 0 | 11/30/2026 |
| 1.7.4 | 0 | 11/30/2026 |
| 1.7.3 | 0 | 11/30/2026 |
| 1.7.2 | 0 | 11/30/2026 |
| 1.7.1 | 0 | 11/30/2026 |
| 1.7.0 | 0 | 11/30/2026 |
| 1.6.0 | 0 | 11/30/2026 |
| 1.5.0 | 0 | 11/30/2026 |
| 1.4.0 | 39 | 11/30/2026 |
| 1.3.3 | 39 | 11/30/2026 |
| 1.3.2 | 39 | 11/30/2026 |
| 1.3.1 | 39 | 11/30/2026 |
| 1.3.0 | 42 | 11/30/2026 |
| 1.2.0 | 49 | 11/30/2026 |