NOF.Domain 9.0.0

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

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 calls Validate(T)
  • Explicit cast to the primitive type
  • GetUnderlyingValue() returning the underlying primitive
  • Equals, GetHashCode, ToString delegating to the primitive
  • Nested JsonConverter for System.Text.Json
  • Optional New() factory via [NewableValueObject] (for snowflake IDs on IValueObject<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 to T 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 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 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.