Unio.SourceGenerator 1.2.1

Requires NuGet 2.12 or higher.

dotnet add package Unio.SourceGenerator --version 1.2.1
                    
NuGet\Install-Package Unio.SourceGenerator -Version 1.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Unio.SourceGenerator" Version="1.2.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Unio.SourceGenerator" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Unio.SourceGenerator">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Unio.SourceGenerator --version 1.2.1
                    
#r "nuget: Unio.SourceGenerator, 1.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Unio.SourceGenerator@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Unio.SourceGenerator&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Unio.SourceGenerator&version=1.2.1
                    
Install as a Cake Tool

Unio.SourceGenerator

Roslyn incremental source generator for Unio discriminated unions.

Generates named, strongly-typed union wrappers from a simple declaration:

using Unio;

[GenerateUnio]
public partial class StringOrInt : UnioBase<string, int>;

The generator adds constructors, implicit conversions and typed equality to a sealed partial class. The union API is inherited from UnioBase<...>.

Use a top-level, non-generic partial class with 2–20 distinct branch types. Nested, generic, abstract, static and file-local classes receive UNIO005; missing partial receives UNIO006. Duplicate branch types receive UNIO003 as an error.

Native AOT and requirements

The generated code supports Native AOT and trimming without runtime reflection or dynamic code. The generator itself runs inside Roslyn at build time and is packaged only as an analyzer; it is not a runtime dependency and does not need IsAotCompatible.

The analyzer targets netstandard2.0 for compiler-host compatibility and requires a Roslyn 5.0-compatible compiler (.NET 10 SDK or newer). This does not add older .NET runtime support: the Unio runtime packages target .NET 9, .NET 10 and .NET 11 RC1.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Unio.SourceGenerator:

Package Downloads
Tlib.Union

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 134 10/4/2026
1.0.4 1,996 3/31/2026
1.0.2 133 3/30/2026
0.7.28 206 3/3/2026