Kongroo.BuildingBlocks.Domain
0.1.0
dotnet add package Kongroo.BuildingBlocks.Domain --version 0.1.0
NuGet\Install-Package Kongroo.BuildingBlocks.Domain -Version 0.1.0
<PackageReference Include="Kongroo.BuildingBlocks.Domain" Version="0.1.0" />
<PackageVersion Include="Kongroo.BuildingBlocks.Domain" Version="0.1.0" />
<PackageReference Include="Kongroo.BuildingBlocks.Domain" />
paket add Kongroo.BuildingBlocks.Domain --version 0.1.0
#r "nuget: Kongroo.BuildingBlocks.Domain, 0.1.0"
#:package Kongroo.BuildingBlocks.Domain@0.1.0
#addin nuget:?package=Kongroo.BuildingBlocks.Domain&version=0.1.0
#tool nuget:?package=Kongroo.BuildingBlocks.Domain&version=0.1.0
🦘 Kongroo.BuildingBlocks.Domain
DDD tactical building blocks for the domain layer of my .NET microservices — entities, aggregate roots, domain events, strongly-typed ids, and a domain-exception hierarchy. Dependency-free (BCL only) and AOT-compatible, so it stays at the center of a clean-architecture dependency graph.
Installation
dotnet add package Kongroo.BuildingBlocks.Domain
Building blocks
| Type | Purpose |
|---|---|
Entity<TId> |
Identity-equality base with a required init, strongly-typed Id |
AggregateRoot<TId> |
Consistency boundary that buffers domain events ([NotMapped]) |
IHasDomainEvents |
Hook for infrastructure to collect buffered events (e.g. an outbox) |
IDomainEvent |
Marker for domain events |
DomainEvent |
Optional event base record with a UUIDv7 EventId and UTC OccurredAt |
IStronglyTypedId / IStronglyTypedId<TSelf, TValue> |
Typed-id markers enforcing a static From factory |
IGuidId<TSelf> |
Guid-backed typed id, additionally enforcing a static Create factory |
DomainException (+ ConflictException, NotFoundException, UnauthorizedException) |
Domain error channel; map to HTTP/problem-details in your API's exception handler |
Usage
using Kongroo.BuildingBlocks.Domain;
using Kongroo.BuildingBlocks.Domain.Exceptions;
// Strongly-typed id — implement the two one-line factories:
public readonly record struct OrderId(Guid Value) : IGuidId<OrderId>
{
public static OrderId From(Guid value) => new(value);
public static OrderId Create() => From(Guid.CreateVersion7());
}
// Domain event carrying standard metadata (EventId + OccurredAt):
public sealed record OrderPlaced(OrderId OrderId) : DomainEvent;
// Aggregate root — identity equality plus a buffered domain-event stream:
public sealed class Order : AggregateRoot<OrderId>
{
public static Order Place() => new() { Id = OrderId.Create() };
public void Confirm()
{
if (DomainEvents.Count > 0)
{
throw new ConflictException(nameof(Order), "already placed");
}
RaiseDomainEvent(new OrderPlaced(Id));
}
}
After persisting an aggregate, infrastructure detects IHasDomainEvents to dispatch its buffered
events and then call ClearDomainEvents(). Strongly-typed ids carry no converters of their own — wire
generic JSON / EF Core converters off IStronglyTypedId<TSelf, TValue> and its TSelf.From(value)
factory.
Design notes
- Value objects are plain C#
record/readonly record structtypes — records already give value equality, so the kernel ships noValueObjectbase. - Errors are exceptions, not a
Result<T>type: throw aDomainExceptionand let the API layer translate it. - Identity is exact-type: two entities are equal only when their concrete type and
Idmatch. - Strongly-typed ids use static-abstract interface members (the
INumber<TSelf>mechanism), so theFrom/Createfactories are reachable from generic infrastructure with no reflection.
What's baked in
- Target:
net10.0, nullable + implicit usings, warnings-as-errors, latest .NET analyzers + SonarAnalyzer. - Zero dependencies: BCL only,
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
- .NET 10 SDK or later.
License
| Product | Versions 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. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Kongroo.BuildingBlocks.Domain:
| Package | Downloads |
|---|---|
|
Kongroo.BuildingBlocks.Application
DDD application building blocks (domain-event dispatch, CQRS contracts, unit of work, integration events, startup initializers) for Kongroo microservice application layers. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 229 | 6/27/2026 |
See the project's GitHub Releases for changes.