Space.Abstraction 2.3.1

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

Space.Abstraction

Core abstractions for the Space framework: high?performance request/response handlers, notifications, pipelines and modular cross?cutting components implemented without runtime reflection (source generator driven).

Install

 dotnet add package Space.Abstraction

Goals (Summary)

  • Eliminate runtime reflection cost (uses a source generator for compile?time discovery & registration)
  • Minimize boilerplate (single [Handle] attribute instead of multiple request/handler interfaces)
  • Allow multiple related handlers in the same class
  • Support named handlers (select concrete handler by name at Send time)
  • Provide lightweight pipelines & pluggable system/user modules (e.g. Cache)
  • Provide fast notification (publish) model with configurable dispatch strategy

Key Building Blocks

Concept Attribute Context Parameter Return Description
Handler [Handle] HandlerContext<TRequest> ValueTask<TResponse> Core request/response unit
Pipeline [Pipeline] PipelineContext<TRequest> ValueTask<TResponse> Middleware around a handler chain (orderable)
Notification [Notification] NotificationContext<TEvent> ValueTask/Task Reacts to published events
Module (system) e.g. [CacheModule] N/A (wraps pipeline) wraps next Cross?cutting concern inserted before user pipelines

Basic Handler Example

public sealed record UserLoginRequest(string UserName);
public sealed record UserLoginResponse(bool Success);

public class UserHandlers
{
    [Handle]
    public ValueTask<UserLoginResponse> Login(HandlerContext<UserLoginRequest> ctx)
    {
        // var userService = ctx.ServiceProvider.GetRequiredService<UserService>();
        // bool success = await userService.Login(ctx.Request);
        bool success = true; // demo
        return ValueTask.FromResult(new UserLoginResponse(success));
    }
}

Named Handlers

Multiple handlers for the same request/response can be differentiated via the Name property:

public class PricingHandlers
{
    [Handle(Name = "Default")] public ValueTask<PriceResult> GetPrice(HandlerContext<PriceQuery> ctx) => ...;
    [Handle(Name = "Discounted")] public ValueTask<PriceResult> GetDiscounted(HandlerContext<PriceQuery> ctx) => ...;
}
// space.Send<PriceResult>(query, handlerName: "Discounted"); (Send overload in DI package)

Pipelines

Pipelines are middleware components executed around the resolved handler. They can short?circuit or augment behavior.

public class UserPipelines
{
    [Pipeline(Order = 1)]
    public async ValueTask<UserLoginResponse> Audit(PipelineContext<UserLoginRequest> ctx)
    {
        // before
        var response = await ctx.Next(ctx);
        // after
        return response;
    }
}

Order is optional; lower values execute earlier. System modules (e.g. cache) use very low order constants to run before user pipelines.

Notifications

public sealed record UserLoggedInSuccessfully(string UserName);

public class UserLoginNotifications
{
    [Notification]
    public ValueTask LogToFile(NotificationContext<UserLoggedInSuccessfully> ctx)
    {
        // file logging
        return ValueTask.CompletedTask;
    }

    [Notification]
    public ValueTask LogToDb(NotificationContext<UserLoggedInSuccessfully> ctx)
    {
        // db logging
        return ValueTask.CompletedTask;
    }
}

Dispatch mode (Parallel / Sequential) is configured via SpaceOptions.NotificationDispatchType (see DI package README).

Modules (Cross?Cutting)

Modules are framework?provided pipeline injectors. Example: Cache module (Space.Modules.InMemoryCache) adds caching behavior when a handler method is annotated:

public class UserQueries
{
    [Handle]
    [CacheModule(Duration = 60)] // seconds
    public ValueTask<UserDetail?> GetUser(HandlerContext<UserId> ctx) => ...;
}

A module attribute does not define its own method; it augments the associated handler.

Source Generator

The generator scans for the above attributes and emits DI registration / metadata so runtime reflection is avoided.

Use With Dependency Injection

Add the Space.DependencyInjection package and call services.AddSpace() (see that package README for details). Then:

ISpace space = provider.GetRequiredService<ISpace>();
var response = await space.Send<UserLoginResponse>(new UserLoginRequest("demo"));
await space.Publish(new UserLoggedInSuccessfully("demo"));
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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Space.Abstraction:

Package Downloads
Space.DependencyInjection

Dependency Injection extensions and runtime implementations for the Space framework.

Space.Modules.InMemoryCache

General In-Memory classes and helpers for the Space framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.1 338 12/25/2025
2.3.1-preview 137 12/20/2025
2.3.0 133 12/20/2025
2.3.0-preview 308 12/7/2025
2.2.0 311 11/26/2025
2.2.0-preview 152 11/8/2025
2.1.0-preview 127 11/7/2025
2.0.0 541 10/2/2025
2.0.0-preview 138 9/27/2025
1.3.4-preview 277 9/19/2025
1.3.3 388 9/19/2025
1.3.3-preview 320 9/18/2025
1.3.2-preview 309 9/18/2025
1.3.1 359 9/16/2025
1.3.1-preview 171 9/13/2025
1.3.0-preview-2-preview 167 9/13/2025
1.3.0-preview 163 9/13/2025
1.2.2 206 9/13/2025
1.2.1-preview 132 9/12/2025
1.2.0-preview 147 9/12/2025
Loading failed