CleanArch.DevKit.Domain 0.1.0-preview.1

This is a prerelease version of CleanArch.DevKit.Domain.
There is a newer version of this package available.
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
                    
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="CleanArch.DevKit.Domain" Version="0.1.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CleanArch.DevKit.Domain" Version="0.1.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="CleanArch.DevKit.Domain" />
                    
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 CleanArch.DevKit.Domain --version 0.1.0-preview.1
                    
#r "nuget: CleanArch.DevKit.Domain, 0.1.0-preview.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 CleanArch.DevKit.Domain@0.1.0-preview.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=CleanArch.DevKit.Domain&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CleanArch.DevKit.Domain&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Tool

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 the CleanArch.DevKit.Mediator.Domain bridge — it ships IDomainEventNotification (combines IDomainEvent + INotification) and a typed mediator.PublishDomainEventsAsync(aggregate) extension.
  • If you use another dispatcher, write a 15-line helper that iterates aggregate.DomainEvents and 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 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.
  • 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