Kongroo.BuildingBlocks.Application 0.2.0

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

🦘 Kongroo.BuildingBlocks.Application

CI NuGet Downloads License: MIT

Application-layer building blocks for the application layer of my .NET microservices — an in-process domain-event dispatcher, CQRS command/query contracts, a unit-of-work seam, an integration-event base, and startup initializers. Builds on Kongroo.BuildingBlocks.Domain plus one DI abstraction, and stays AOT-compatible.

Installation

dotnet add package Kongroo.BuildingBlocks.Application

Building blocks

Type Purpose
IDomainEventHandler / DomainEventHandler<TDomainEvent> Strongly-typed domain-event handler and its base
IDomainEventDispatcher In-process dispatcher: snapshots an aggregate's events, invokes handlers, clears
ICommand / ICommand<TResult> Markers for state-changing commands
ICommandHandler<TCommand> / ICommandHandler<TCommand, TResult> Command handler contracts
IQuery<TResult> / IQueryHandler<TQuery, TResult> Read-query contracts
IUnitOfWork Commit seam over the current transaction (e.g. a DbContext)
IntegrationEvent Base record for cross-service events (UUIDv7 IntegrationEventId + UTC OccurredAt)
IApplicationInitializer Ordered startup task, gated by IsEnabledAsync
AddDomainEventHandler<THandler>() AOT-safe DI registration; also wires the in-process dispatcher

Usage

using Kongroo.BuildingBlocks.Application;
using Microsoft.Extensions.DependencyInjection;

// A domain-event handler — derive from the typed base:
public sealed class OrderPlacedHandler : DomainEventHandler<OrderPlaced>
{
    protected override Task HandleAsync(OrderPlaced domainEvent, CancellationToken cancellationToken)
    {
        // react to the event…
        return Task.CompletedTask;
    }
}

// A command and its handler — plain contracts, no mediator:
public sealed record ConfirmOrder(OrderId OrderId) : ICommand;

public sealed class ConfirmOrderHandler(IUnitOfWork unitOfWork) : ICommandHandler<ConfirmOrder>
{
    public async Task HandleAsync(ConfirmOrder command, CancellationToken cancellationToken)
    {
        // load the aggregate, mutate it, then commit via EF Core…
        await unitOfWork.CommitAsync(cancellationToken);
    }
}

// Registration — one call per handler; the in-process dispatcher is wired automatically:
services.AddDomainEventHandler<OrderPlacedHandler>();
services.AddScoped<ICommandHandler<ConfirmOrder>, ConfirmOrderHandler>();

After persisting an aggregate, an infrastructure component (e.g. an EF Core SaveChanges interceptor) calls IDomainEventDispatcher.DispatchAsync(aggregates, …), which invokes each matching IDomainEventHandler and then clears the aggregates. CQRS handlers carry no dispatcher — inject the handler interface directly where you need it.

Design notes

  • No mediator: commands and queries are plain handler contracts you inject and call directly — no ISender, no pipeline behaviors.
  • Explicit registration: handlers are registered one by one (AddDomainEventHandler<T>), so there is no assembly scanning or reflection and the package stays AOT/trim-safe. The first call also registers the in-process IDomainEventDispatcher.
  • Dispatch is in-process and sequential: an aggregate's events are snapshotted before any handler runs, handlers fail fast, and sources are cleared only after a clean pass.
  • Errors are exceptions (Kongroo.BuildingBlocks.Domain's DomainException), not a Result<T>.
  • No repository abstraction — handlers use EF Core (or your data access) directly.

What's baked in

  • Target: net10.0, nullable + implicit usings, warnings-as-errors, latest .NET analyzers + SonarAnalyzer.
  • Dependencies: Kongroo.BuildingBlocks.Domain and Microsoft.Extensions.DependencyInjection.Abstractions; IsAotCompatible.
  • API stability: the public surface is tracked with the public-API analyzer.
  • Packaging: deterministic build, SourceLink, symbols (snupkg), and a MinVer-derived version.

Requirements

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Kongroo.BuildingBlocks.Application:

Package Downloads
Kongroo.BuildingBlocks.Infrastructure

The EF Core and hosting building blocks for the infrastructure layer of my .NET microservices — the concretions behind the Kongroo.BuildingBlocks.Application contracts.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 187 6/30/2026
0.1.0 138 6/27/2026

See the project's GitHub Releases for changes.