Ferrous.Unions
3.1.0
dotnet add package Ferrous.Unions --version 3.1.0
NuGet\Install-Package Ferrous.Unions -Version 3.1.0
<PackageReference Include="Ferrous.Unions" Version="3.1.0" />
<PackageVersion Include="Ferrous.Unions" Version="3.1.0" />
<PackageReference Include="Ferrous.Unions" />
paket add Ferrous.Unions --version 3.1.0
#r "nuget: Ferrous.Unions, 3.1.0"
#:package Ferrous.Unions@3.1.0
#addin nuget:?package=Ferrous.Unions&version=3.1.0
#tool nuget:?package=Ferrous.Unions&version=3.1.0
Ferrous.Unions
Incremental Roslyn source generators (IIncrementalGenerator) for zero-boxing [DiscriminatedUnion] structs/records (with exhaustive Match, TryGet*, structural equality, JSON converters, and automatic .NET 11 / C# 15 [Union] light-up), validated [Newtype] wrappers (FE0101), compile-time [TypedBuilder] typestate builders (FE0102), zero-allocation [TryFromEnum] converters (FE0103), and [Instrument] ActivitySource spans.
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.westness.cc for full documentation.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Ferrous.Core (>= 3.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Ferrous.Unions:
| Package | Downloads |
|---|---|
|
Ferrous
Rust-grade compile-time safety, zero-allocation primitives, source generators, and 70 rustc-style Roslyn analyzers (FE0001–FE0508) for strict .NET 10 & .NET 11 builds and AI coding agents. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.0 | 0 | 12/1/2026 |
| 3.0.1 | 0 | 12/1/2026 |
| 3.0.0 | 0 | 11/30/2026 |
| 2.8.1 | 0 | 11/30/2026 |
| 2.8.0 | 0 | 11/30/2026 |
| 2.7.0 | 0 | 11/30/2026 |
| 2.6.0 | 0 | 11/30/2026 |
| 2.4.2 | 0 | 11/30/2026 |
| 2.4.1 | 0 | 11/30/2026 |
| 2.4.0 | 0 | 11/30/2026 |
| 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 |