Skybeam 0.2.0

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

NuGet

Skybeam

Mediator-like service decoration without an actual mediator:

  • Improved code readability with explicit class dependencies and source generation. There is no IMediator or a service locator.
  • Supports decorators / middlewares / behaviors.
  • Built for modern ASP.NET Core on top of Microsoft.Extensions.DependencyInjection.
  • Better performance: pipelines are source-generated. There is no reflection or dictionary lookups on handlers execution path.
  • Handler and behavior contracts are intentionally made similar to MediatR.
  • By now, it's more of a proof-of-concept project.

If the only feature you need from MediatR is decoration, consider opting out. CQRS handler decoration (in a form of middlewares, pipelines, behaviors etc.) can be implemented in many other ways:

  • Reflection + DI: the classic, robust, and most flexible approach - less explicit, not the fastest, and not AOT-friendly.
  • IL weaving: PostSharp etc.
  • Source generation + DI: Skybeam (this project).

How to start

Reference Skybeam package directly in every project containing handlers. Preferably use Directory.Build.props in your solution to ensure that.

Use Skybeam.IRequestHandler for the handlers:

public class FirstHandler : IRequestHandler<Alpha, Omega>
{
    public Task<Omega> HandleAsync(Alpha input, CancellationToken ct = default) {}
}

Use Skybeam.IPipelineBehavior for the behaviors:

public class FirstBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
{
    public Task<TResponse> HandleAsync(
        TRequest request, 
        RequestHandlerDelegate<TResponse> next, 
        CancellationToken ct = default) {}
}

Build the project to trigger source generation. Then register the generated pipelines:

services.AddSkybeam()
    .AddBehavior(typeof(FirstBehavior<,>))
    .AddBehavior(typeof(SecondBehavior<,>), ServiceLifetime.Singleton);
Remarks
  • Handler registration is optional and can be used to control handler lifetime.
  • Handler's lifetime is preserved if there is a IRequestHandler<T1, T2> registration before AddSkybeam call. Otherwise, it defaults to Transient.
  • Behaviors are invoked in registration order.
  • Behavior's lifetime is either specified in AddBehavioror defaults to Transient.

Some explanation

What is PipelineRegistry

Skybeam.YourProject.PipelineRegistry type is the access point to the source code generated by Skybeam. By navigating to the registry's definition, you can inspect all discovered handlers and how they're processed. Each handler has a respectful source-generated pipeline that replaces a handler's registration in DI:

services.ReplaceWithPipeline<
	IRequestHandler<Alpha, Omega>, 
	FirstHandler, 
	FirstHandlerPipeline>();

Multiple registry types

In real-world applications, handlers are often located in multiple separated projects (e.g., YourProject.BusinessLayer). This leads to several PipelineRegistry types generated due to how C# source generators work. To use only one registry, just specify it in AddSkybeam<T> call, which means only the handlers from this respectful registry will be decorated (you probably don't want that). To process all handlers, stay on non-generic AddSkybeam version: this method runs a reflection-based assembly scan to find all available registries. What can be further limited by setting ScanAssemblies option:

services.AddSkybeam<Skybeam.YourProject42.PipelineRegistry>();

// or
services.AddSkybeam(options =>
{
    options.ScanAssemblies = [typeof(DummyRegistry).Assembly];
});

Known limitations

  • Currently supports only Microsoft.Extensions.DependencyInjection.
  • Full AOT compatibility is not guaranteed yet.
Product 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 was computed.  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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in 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
0.2.0 207 10/5/2025