Unions.Pure.Csharp
1.0.4
See the version list below for details.
dotnet add package Unions.Pure.Csharp --version 1.0.4
NuGet\Install-Package Unions.Pure.Csharp -Version 1.0.4
<PackageReference Include="Unions.Pure.Csharp" Version="1.0.4" />
<PackageVersion Include="Unions.Pure.Csharp" Version="1.0.4" />
<PackageReference Include="Unions.Pure.Csharp" />
paket add Unions.Pure.Csharp --version 1.0.4
#r "nuget: Unions.Pure.Csharp, 1.0.4"
#:package Unions.Pure.Csharp@1.0.4
#addin nuget:?package=Unions.Pure.Csharp&version=1.0.4
#tool nuget:?package=Unions.Pure.Csharp&version=1.0.4
C# Pure Unions
Roslyn source generator for minimal-overhead discriminated unions. Add the [Union] attribute to a partial type and the generator emits a compact tag enum, factory helpers, and Match/Switch helpers without extra allocations.
Getting started
- Install the package in your project:
dotnet add package Unions.Pure.Csharp
- Annotate a partial type with the union members you need:
using Unions.Pure.Csharp;
namespace Sample;
[Union(typeof(string), typeof(int))]
public partial record struct PaymentStatus;
- Use the generated factories and helpers:
var paid = PaymentStatus.FromInt32(200);
var message = paid.Match(
onString: s => $"Message: {s}",
onInt32: code => $"Code: {code}");
The [Union] attribute is injected by the generator; no manual reference is required beyond the package itself.
Local development
- Build and test everything:
dotnet test Unions.Pure.Csharp.sln --configuration Release
The Unions.Pure.Csharp.Tests project provides a small harness that compiles against the generator and exercises the generated API.
Publishing
Pushing a tag that starts with v (for example v1.2.3) runs the publish-nuget job in .github/workflows/ci.yml. The job packs the source generator and pushes it to NuGet using the NUGET_API_KEY repository secret. There is no publish on branches; branch pushes and pull requests only build and test.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.12 | 5,234 | 6/18/2026 |
| 2.0.11 | 168 | 6/18/2026 |
| 2.0.10 | 318 | 5/15/2026 |
| 2.0.9 | 124 | 5/15/2026 |
| 2.0.8 | 127 | 5/15/2026 |
| 2.0.7 | 126 | 5/15/2026 |
| 2.0.6 | 139 | 5/15/2026 |
| 2.0.5 | 149 | 2/18/2026 |
| 2.0.4 | 133 | 2/18/2026 |
| 2.0.3 | 2,628 | 1/15/2026 |
| 2.0.2 | 338 | 12/18/2025 |
| 2.0.1 | 315 | 12/18/2025 |
| 2.0.0 | 752 | 12/15/2025 |
| 1.1.0 | 296 | 12/15/2025 |
| 1.0.10 | 271 | 12/15/2025 |
| 1.0.8 | 259 | 12/14/2025 |
| 1.0.7 | 252 | 12/14/2025 |
| 1.0.6 | 261 | 12/14/2025 |
| 1.0.5 | 259 | 12/14/2025 |
| 1.0.4 | 256 | 12/14/2025 |