Pipelines 1.0.0
See the version list below for details.
dotnet add package Pipelines --version 1.0.0
NuGet\Install-Package Pipelines -Version 1.0.0
<PackageReference Include="Pipelines" Version="1.0.0" />
<PackageVersion Include="Pipelines" Version="1.0.0" />
<PackageReference Include="Pipelines" />
paket add Pipelines --version 1.0.0
#r "nuget: Pipelines, 1.0.0"
#:package Pipelines@1.0.0
#addin nuget:?package=Pipelines&version=1.0.0
#tool nuget:?package=Pipelines&version=1.0.0
Pipelines
Pipelines is a lightweight library designed to simplify the implementation of the mediator pattern.
Installation
Isntall the latest package using the method that works for you as provided by the nuget site.
The package includes everything you need, including the generator.
How It Works
- Request and Response: Define your requests and responses.
- Handlers: Create handlers for your request/response pairs.
- Execution: Use the
Pipelineclass as a mediator to find the appropriate pipeline or inject/create aRequestPipeline, then execute the pipeline for a given request. This executes any behavrios before executing the handler and returns the expected response. - Behaviors: Add behaviors to your pipelines to customize the processing of requests and responses. This allows for additional functionality, such as logging, validation, or performance monitoring. Behavrios can be added to the DI too and will be injected.
- Source Generation: The
Pipelines.Generatorsimplifies the development process by generating code for handler registration, pipeline creation, and DI integration.
Implementing a specific interface for requests is optional, but it helps when using Pipeline class as you don't have to provide the generic arguments.
Generated handler registration registers handlers on their interfaces. Requesting an IRequestHandler<object, object> will give you your handler but requesting a RequestPipeline<object, object> will give you a built pipeline with your handler wrapped by any behaviors that could be injected.
Examples
You can also find samples here.
Requests
Declaring request/response/handler:
public class MyRequest : IRequest<MyRequest, MyResponse> // interface here is optional
{
public string Data { get; set; } = string.Empty;
}
public class MyResponse
{
public string Result { get; set; } = string.Empty;
}
public class MyHandler : IRequestHandler<MyRequest, MyResponse>
{
public ValueTask<MyResponse> Handle(MyRequest request)
{
return new(new MyResponse { Result = $"Processed: {request.Data}" });
}
}
DI registration if using Microsoft.Extensions.DependencyInjection
services.AddPipelines(); // adds pipelines to the di
services.AddHandlers(); // adds the assembly handlers to the di
Executing a request from di:
var pipeline = serviceProvider.GetRequiredService<Pipeline>();
// with interface
var response1 = pipeline.Request(new MyRequest { Data = "Hello, World!" });
// without interface
var response2 = pipeline.Request<MyRequest, MyResponse>(new MyRequest { Data = "Hello, World!" });
Streams
Declaring stream request/response/handler:
public class MyStreamRequest : IStreamRequest<MyStreamRequest, string> // interface here is optional
{
public string Query { get; set; }
}
public class MyStreamHandler : IStreamRequestHandler<MyStreamRequest, string>
{
public async IAsyncEnumerable<string> Handle(MyStreamRequest request)
{
yield return $"Result 1 for {request.Query}";
yield return $"Result 2 for {request.Query}";
}
}
DI registration same as Requests
Executing a stream from di:
var pipeline = serviceProvider.GetRequiredService<Pipeline>();
// with interface
await foreach (var result in pipeline.Stream(new MyStreamRequest { Query = "Test" }))
{
Console.WriteLine(result);
}
// without interface
await foreach (var result in pipeline.Stream<MyStreamRequest, string>(new MyStreamRequest { Query = "Test" }))
{
Console.WriteLine(result);
}
Build and Test
To build and test the project you need an editor/ide of your choice and the .NET SDK.
Structure
Projects
- Pipelines: Provides the main contracts to build and execute a pipeline.
- Pipelines.Generator: Provides per assembly extension method generation for registering pipeline and handler implementations to the DI. Referenced by Pipelines and there is no need to install.
Features
- Root: Contains the
Pipelineclass that acts as a mediator, determining which pipeline to execute for a given request backed by anIServiceProvider. - Requests: Request (Command, Query) functionality and contracts.
- Streams: StreamRequest functionality and contracts.
Testing
The project uses TUnit and the code was modeled after Andrew Lock's article Creating a source generator.
- Pipelines.Generator.Test Generator tests using Verify to validated generated output for each possible case. Each test case has it's files in the Resources folder with a
Program.csfile for compilation. it also includes the verify files. The naming convetion is{ClassName}/{MethodName}/Program.cs. - Pipelines.Generator.Test.Integration Tests all pipeline classes and the generated code from the generator by trying to immitate day to day use.
- Pipelines.Generator.Test.Integration.NuGet Executes all integration tests by publishing the package at a local nuget source
All tests can be executed using dotnet (excluding nuget), visual studio (excluding nuget) or better by using cake eg:
dotnet cake.cs -c Release -- --target testdotnet cake.cs -c Release -- --target test-nuget
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.10)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.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.1-dev.4 | 49 | 8/1/2026 |
| 1.0.0 | 58 | 7/25/2026 |
| 1.0.0-alpha.1 | 82 | 5/3/2026 |
| 1.0.0-alpha | 62 | 5/1/2026 |
| 0.0.0-dev.22 | 52 | 7/25/2026 |