Mab.PipelineFramework.SourceGenerator 1.0.2

dotnet add package Mab.PipelineFramework.SourceGenerator --version 1.0.2
                    
NuGet\Install-Package Mab.PipelineFramework.SourceGenerator -Version 1.0.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="Mab.PipelineFramework.SourceGenerator" Version="1.0.2">
  <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="Mab.PipelineFramework.SourceGenerator" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Mab.PipelineFramework.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 Mab.PipelineFramework.SourceGenerator --version 1.0.2
                    
#r "nuget: Mab.PipelineFramework.SourceGenerator, 1.0.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 Mab.PipelineFramework.SourceGenerator@1.0.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=Mab.PipelineFramework.SourceGenerator&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Mab.PipelineFramework.SourceGenerator&version=1.0.2
                    
Install as a Cake Tool

PipelineFramework.SourceGenerator

Compile-time source generator for PipelineFramework providing 27.4x performance improvement over reflection-based execution.

Performance Benefits

Verified by BenchmarkDotNet on .NET 8.0:

Metric Reflection Source Generator Improvement
Execution Time 42.194 ns 1.542 ns 27.4x faster ⚡
Allocations 88 bytes 0 bytes Zero allocations 💚
Std Deviation ±0.518 ns ±0.042 ns 12x more consistent 📊

Quick Start

1. Install Package

dotnet add package PipelineFramework.SourceGenerator

2. Mark Your Pipeline Class

Add the [GeneratePipeline] attribute and make your class partial:

using Pipeline.Attributes;

[GeneratePipeline]  // 👈 Add this
public partial class OrderPipelineEvents : PipelineEvents  // 👈 Add 'partial'
{
    [PipelineEvent(Order = 1)]
    public PipelineContextAsync<OrderContext>? ValidateOrder { get; set; }

    [PipelineEvent(Order = 2, TimeoutMilliseconds = 5000)]
    public PipelineContextAsync<OrderContext>? ProcessPayment { get; set; }
}

3. Build and Use

dotnet build

The source generator automatically creates optimized methods:

// Use generated methods - NO REFLECTION! ⚡
await events.ExecuteAllAsync(context);
await events.ExecuteAsync("ValidateOrder", context);
bool hasSubscribers = events.HasSubscribers("ProcessPayment");
string[] eventNames = OrderPipelineEvents.GetEventNames();

Features

  • ⚡ 27.4x faster execution than reflection
  • 💚 Zero allocations - no garbage collection overhead
  • ✅ Compile-time safety - catch errors during build
  • 🔍 Better debugging - see and step through generated code
  • 🎯 100% optional - works alongside reflection-based code
  • ⏱️ Timeout support - automatic timeout handling for events
  • 🔀 Mixed sync/async - supports both synchronous and asynchronous events

Generated Methods

The source generator creates these methods for you:

ExecuteAll() / ExecuteAllAsync()

Executes all events in order with direct invocation:

await events.ExecuteAllAsync(context);

Execute(name) / ExecuteAsync(name)

Execute specific events by name:

await events.ExecuteAsync("ValidateOrder", context);

HasSubscribers(name)

Check if an event has subscribers:

bool hasValidation = events.HasSubscribers("ValidateOrder");

GetEventNames()

Get all event names at compile time:

string[] events = OrderPipelineEvents.GetEventNames();

Advanced Features

Timeout Handling

Events with TimeoutMilliseconds get automatic timeout handling:

[PipelineEvent(Order = 1, TimeoutMilliseconds = 5000)]
public PipelineContextAsync<OrderContext>? ProcessPayment { get; set; }

Skip If Cancelled

Events marked with SkipIfCancelled are automatically skipped:

[PipelineEvent(Order = 3, SkipIfCancelled = true)]
public PipelineContextAsync<OrderContext>? SendNotification { get; set; }

Requirements

  • .NET 8.0 or higher
  • PipelineFramework.Core 1.0.0 or higher

Documentation

License

MIT License - see LICENSE for details

Support

There are no supported framework assets in this package.

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
1.0.2 484 12/8/2025
1.0.0 298 11/10/2025

v1.0.0 - Initial stable release
     - 27.4x faster execution than reflection (verified by BenchmarkDotNet)
     - Zero memory allocations vs 88 bytes per reflection invocation
     - Compile-time code generation for ExecuteAll, Execute, HasSubscribers methods
     - Support for timeout handling and conditional execution
     - Mixed sync/async event support
     - Full debugging support with visible generated code
     - 100% optional and backward compatible