NOF.Domain
9.0.0
dotnet add package NOF.Domain --version 9.0.0
NuGet\Install-Package NOF.Domain -Version 9.0.0
<PackageReference Include="NOF.Domain" Version="9.0.0" />
<PackageVersion Include="NOF.Domain" Version="9.0.0" />
<PackageReference Include="NOF.Domain" />
paket add NOF.Domain --version 9.0.0
#r "nuget: NOF.Domain, 9.0.0"
#:package NOF.Domain@9.0.0
#addin nuget:?package=NOF.Domain&version=9.0.0
#tool nuget:?package=NOF.Domain&version=9.0.0
NOF.Domain
Domain layer package for the NOF Framework.
Overview
Provides the foundational building blocks for domain-driven design: entities, aggregate roots, repositories, domain events, and domain-specific annotations with source generation support.
Key Abstractions
Entities & Aggregate Roots
public class Order : AggregateRoot
{
public Guid Id { get; private set; }
public OrderStatus Status { get; private set; }
public void Confirm()
{
Status = OrderStatus.Confirmed;
AddEvent(new OrderConfirmedEvent(Id));
}
}
Repository
public interface IRepository<TAggregateRoot> where TAggregateRoot : class, IAggregateRoot
{
ValueTask<TAggregateRoot?> FindAsync(object?[] keyValues, CancellationToken cancellationToken = default);
void Add(TAggregateRoot entity);
void Remove(TAggregateRoot entity);
}
[Failure] Attribute
Declaratively define domain failure codes. The source generator produces static FailResult instances at compile time.
[Failure("NotFound", "Order not found", "404001")]
[Failure("AlreadyPaid", "Order has already been paid", "409001")]
public partial class OrderFailures;
// Generated usage:
return OrderFailures.NotFound;
IValueObject<T> Interface
Implement IValueObject<T> on a readonly partial struct to define a value object. The source generator produces:
- Private constructor +
Of(T)factory that callsValidate(T) - Explicit cast to the primitive type
GetUnderlyingValue()returning the underlying primitiveEquals,GetHashCode,ToStringdelegating to the primitive- Nested
JsonConverterfor System.Text.Json - Optional
New()factory via[NewableValueObject](for snowflake IDs onIValueObject<long>)
The interface provides:
static virtual void Validate(T value)�?override to add custom validation (default is no-op)object IValueObject.GetUnderlyingValue()�?default implementation forwarding toT GetUnderlyingValue()
[NewableValueObject]
public readonly partial struct OrderId : IValueObject<long>;
public readonly partial struct CustomerName : IValueObject<string>
{
public static void Validate(string value)
{
if (string.IsNullOrWhiteSpace(value))
throw new DomainException("Customer name cannot be empty");
}
}
// Usage
var id = OrderId.New(); // Snowflake ID
var name = CustomerName.Of("Alice"); // Validated
long raw = (long)id; // Explicit cast to primitive
long raw2 = id.GetUnderlyingValue(); // IValueObject<T> interface
The IValueObject / IValueObject<T> interfaces enable the source generator's ValueObject �?primitive conversion at compile time. See design/value-object.md for the full design rationale.
Installation
dotnet add package NOF.Domain
License
Apache-2.0
| 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
- NOF.Abstraction (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NOF.Domain:
| Package | Downloads |
|---|---|
|
NOF.Application
Application layer for the NOF Framework — request/command/notification handlers, state machines, caching, and unit of work. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0 | 151 | 4/10/2026 |
| 9.0.0-nightly.1199007.3d5befd | 52 | 4/12/2026 |
| 9.0.0-nightly.1198242.c8a3545 | 52 | 4/12/2026 |
| 9.0.0-nightly.1196197.909eb55 | 46 | 4/10/2026 |
| 8.1.0-nightly.1195804.cce016b | 49 | 4/10/2026 |
| 8.1.0-nightly.1193099.99dde3c | 53 | 4/8/2026 |
| 8.1.0-nightly.1192845.b7d8342 | 53 | 4/8/2026 |
| 8.1.0-nightly.1191847.83ab912 | 58 | 4/7/2026 |
| 8.1.0-nightly.1191516.b6ed90f | 55 | 4/7/2026 |
| 8.1.0-nightly.1190244.7e1669e | 57 | 4/6/2026 |
| 8.0.0 | 169 | 4/3/2026 |
| 8.0.0-nightly.1186048.1e888b7 | 56 | 4/3/2026 |
| 8.0.0-nightly.1184662.3649625 | 58 | 4/2/2026 |
| 8.0.0-nightly.1184610.6235e8d | 51 | 4/2/2026 |
| 8.0.0-nightly.1184586.7831d99 | 60 | 4/2/2026 |
| 8.0.0-nightly.1183027.81361be | 59 | 4/1/2026 |
| 8.0.0-nightly.1182812.d2b8f81 | 65 | 4/1/2026 |
| 8.0.0-nightly.1171454.39c8e77 | 60 | 3/24/2026 |
| 8.0.0-nightly.1171297.eb9cf82 | 57 | 3/24/2026 |
| 8.0.0-nightly.1170307.152510d | 57 | 3/23/2026 |