MonadicTypes.NET.Generators 0.3.0-preview.2

This is a prerelease version of MonadicTypes.NET.Generators.
dotnet add package MonadicTypes.NET.Generators --version 0.3.0-preview.2
                    
NuGet\Install-Package MonadicTypes.NET.Generators -Version 0.3.0-preview.2
                    
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="MonadicTypes.NET.Generators" Version="0.3.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MonadicTypes.NET.Generators" Version="0.3.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="MonadicTypes.NET.Generators" />
                    
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 MonadicTypes.NET.Generators --version 0.3.0-preview.2
                    
#r "nuget: MonadicTypes.NET.Generators, 0.3.0-preview.2"
                    
#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 MonadicTypes.NET.Generators@0.3.0-preview.2
                    
#: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=MonadicTypes.NET.Generators&version=0.3.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MonadicTypes.NET.Generators&version=0.3.0-preview.2&prerelease
                    
Install as a Cake Tool

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.

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.

Complete API reference

Documented public members: 3

There are no supported framework assets in this package.

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