CleanArch.DevKit.Domain
0.1.0-preview.1
See the version list below for details.
dotnet add package CleanArch.DevKit.Domain --version 0.1.0-preview.1
NuGet\Install-Package CleanArch.DevKit.Domain -Version 0.1.0-preview.1
<PackageReference Include="CleanArch.DevKit.Domain" Version="0.1.0-preview.1" />
<PackageVersion Include="CleanArch.DevKit.Domain" Version="0.1.0-preview.1" />
<PackageReference Include="CleanArch.DevKit.Domain" />
paket add CleanArch.DevKit.Domain --version 0.1.0-preview.1
#r "nuget: CleanArch.DevKit.Domain, 0.1.0-preview.1"
#:package CleanArch.DevKit.Domain@0.1.0-preview.1
#addin nuget:?package=CleanArch.DevKit.Domain&version=0.1.0-preview.1&prerelease
#tool nuget:?package=CleanArch.DevKit.Domain&version=0.1.0-preview.1&prerelease
CleanArch.DevKit.Domain
Domain primitives for DDD-style modeling: Entity<TId>, AggregateRoot<TId>, IAggregateRoot, IDomainEvent. Standalone — no dispatcher dependency.
Part of the CleanArch.DevKit toolkit.
Install
dotnet add package CleanArch.DevKit.Domain
Entity
public sealed class User : Entity<Guid>
{
public string Email { get; private set; }
private User(Guid id, string email) : base(id) => Email = email;
public static User Create(string email) => new(Guid.NewGuid(), email);
}
Equality is by runtime type + non-default Id. Transient entities (default Id) are equal only to themselves by reference — the Vaughn-Vernon pattern. GetHashCode falls back to RuntimeHelpers.GetHashCode for transients so they don't collide in dictionaries before persistence.
Id is protected init so persistence frameworks can hydrate via parameterless constructor + property init, while domain code goes through the parameterised constructor.
AggregateRoot + IDomainEvent
public sealed record UserRegistered(Guid UserId, string Email) : IDomainEvent;
public sealed class User : AggregateRoot<Guid>
{
public string Email { get; private set; }
private User(Guid id, string email) : base(id)
{
Email = email;
Raise(new UserRegistered(id, email));
}
public static User Register(string email) => new(Guid.NewGuid(), email);
}
Raise(IDomainEvent) is protected, DomainEvents is public read-only, ClearDomainEvents() is public for the dispatcher to drain after commit.
IAggregateRoot is a non-generic marker so a UoW can scan DbContext.ChangeTracker (or your persistence equivalent) without needing to know TId.
IDomainEvent is a pure marker with no base interfaces — it does not couple your domain to any dispatcher.
Dispatching events
This package only buffers events on the aggregate. Publishing is the responsibility of your infrastructure layer.
- If you use
CleanArch.DevKit.Mediator, install theCleanArch.DevKit.Mediator.Domainbridge — it shipsIDomainEventNotification(combinesIDomainEvent+INotification) and a typedmediator.PublishDomainEventsAsync(aggregate)extension. - If you use another dispatcher, write a 15-line helper that iterates
aggregate.DomainEventsand feeds your bus.
ValueObject
This package does not ship a ValueObject base. Use C# 14 records — structural equality is native and free.
public sealed record Address(string Street, string City, string ZipCode);
License
MIT — see 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 CleanArch.DevKit.Domain:
| Package | Downloads |
|---|---|
|
CleanArch.DevKit.Mediator.Domain
Bridge between CleanArch.DevKit.Domain and CleanArch.DevKit.Mediator: IDomainEventNotification (combines IDomainEvent + INotification) and a typed PublishDomainEventsAsync extension on IMediator. Install this only if you use both Domain and Mediator together. Part of the CleanArch.DevKit set. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.1 | 106 | 5/17/2026 |
| 1.1.0 | 98 | 5/17/2026 |
| 1.0.0 | 109 | 5/15/2026 |
| 0.1.0-preview.1 | 52 | 5/14/2026 |