MonadicTypes.NET.Generators
0.3.0-preview.2
dotnet add package MonadicTypes.NET.Generators --version 0.3.0-preview.2
NuGet\Install-Package MonadicTypes.NET.Generators -Version 0.3.0-preview.2
<PackageReference Include="MonadicTypes.NET.Generators" Version="0.3.0-preview.2" />
<PackageVersion Include="MonadicTypes.NET.Generators" Version="0.3.0-preview.2" />
<PackageReference Include="MonadicTypes.NET.Generators" />
paket add MonadicTypes.NET.Generators --version 0.3.0-preview.2
#r "nuget: MonadicTypes.NET.Generators, 0.3.0-preview.2"
#:package MonadicTypes.NET.Generators@0.3.0-preview.2
#addin nuget:?package=MonadicTypes.NET.Generators&version=0.3.0-preview.2&prerelease
#tool nuget:?package=MonadicTypes.NET.Generators&version=0.3.0-preview.2&prerelease
MonadicTypes.NET.Generators
Compile-time struct-callable adapters for measured MonadicTypes.NET hot paths. This is an analyzer package: it adds generated source to the consuming project and has no runtime dependency.
Requirements
- C# 14 / .NET 10 consumer project
- Compatible with trimming and NativeAOT
- The annotated container must be a top-level, non-generic
static partial class
Install
dotnet add package MonadicTypes.NET --prerelease
dotnet add package MonadicTypes.NET.Generators --prerelease
Quick Start
using MonadicTypes;
public static partial class Operations
{
[GenerateValueFunction]
public static long Widen(int value) => value;
}
Result<int, string> source = Result<int, string>.Ok(42);
Result<long, string> widened = source.Map(Operations.Functions.Widen);
// The original method remains callable normally.
long direct = Operations.Widen(42);
Generation Contract
The generator adds a public callable token and an aggressively inlined adapter
implementing IValueFunction<TIn,TOut> or IValueAction<T>. It uses no runtime
reflection, registration, or dynamic code. Async method return types work with
the corresponding operators in MonadicTypes.NET.Async.
Annotatable methods must be implemented, static, non-generic, and accept exactly
one by-value parameter. An optional attribute name controls the generated token
name. Invalid shapes produce MTGEN001 through MTGEN004 compile-time errors.
Do not annotate every Result-related method. Cached static delegates already allocate 0 B per invocation. Generated generic callables can improve dispatch and inlining in measured hot paths, but each distinct callable can increase NativeAOT generic instantiation count and binary size.
Related Packages
| Package | Add it for |
|---|---|
MonadicTypes.NET |
Result, Option, and callable contracts used by generated tokens |
MonadicTypes.NET.Async |
Async operators that accept generated tokens |
Documentation
See generated callables.
Apache-2.0. Developed with AI assistance.
Documented public members: 3
Learn more about Target Frameworks and .NET Standard.
This package has 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 |
|---|---|---|
| 0.3.0-preview.2 | 63 | 9/12/2026 |
| 0.3.0-preview.1 | 58 | 9/12/2026 |
| 0.2.0-preview.2 | 68 | 8/30/2026 |
| 0.2.0-preview.1 | 76 | 8/17/2026 |
| 0.1.0-preview.1 | 68 | 8/12/2026 |