PANiXiDA.Core.Domain 1.0.3

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

PANiXiDA.Core.Domain

CI NuGet NuGet downloads Target Framework License

PANiXiDA.Core.Domain provides small, reusable domain model building blocks for .NET applications that use Domain-Driven Design patterns.

The package contains base abstractions for entities, aggregate roots, domain events, value objects, and extensible enumerations. It is intentionally lightweight and does not require runtime configuration or infrastructure dependencies.

Installation

Package Manager

dotnet add package PANiXiDA.Core.Domain

PackageReference

<ItemGroup>
  <PackageReference Include="PANiXiDA.Core.Domain" Version="1.0.1" />
</ItemGroup>

Requirements

  • .NET 10
  • Nullable reference types enabled in consuming projects is recommended

Features

  • Strongly typed Entity<TId> base class and non-generic IEntity contract.
  • AggregateRoot<TId> base class and non-generic IAggregateRoot contract with domain event collection support.
  • DomainEvent base record with generated version 7 Guid identifiers and UTC timestamps.
  • ValueObject base class with component-based equality.
  • Enumeration<TEnumeration> base class for smart enum-style domain concepts.
  • Deterministic lookup behavior for enumeration values by identifier or name.

Namespaces

using PANiXiDA.Core.Domain;
using PANiXiDA.Core.Domain.AggregateRoots;
using PANiXiDA.Core.Domain.DomainEvents;
using PANiXiDA.Core.Domain.Entities;

Entity

Use Entity<TId> for domain objects identified by a stable value. The identifier type must be a value type. The IEntity contract is intentionally non-generic and does not expose identifiers; Id remains available on Entity<TId> implementations.

using PANiXiDA.Core.Domain.Entities;

public sealed class Customer(Guid id) : Entity<Guid>(id)
{
    public string Name { get; private set; } = string.Empty;

    public void Rename(string name)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(name);

        Name = name;
    }
}

Aggregate Root and Domain Events

Use AggregateRoot<TId> when an entity is the consistency boundary for a domain model and needs to collect domain events. The IAggregateRoot contract is intentionally non-generic and does not expose identifiers; Id remains available on AggregateRoot<TId> implementations.

using PANiXiDA.Core.Domain.AggregateRoots;
using PANiXiDA.Core.Domain.DomainEvents;

public sealed class Order(Guid id) : AggregateRoot<Guid>(id)
{
    public bool IsStarted { get; private set; }

    public void Start()
    {
        if (IsStarted)
        {
            return;
        }

        IsStarted = true;

        AddDomainEvent(new OrderStarted(Id));
    }
}

public sealed record OrderStarted(Guid OrderId) : DomainEvent;

Domain events are stored inside the aggregate root until the application layer reads and clears them.

Order order = new(Guid.NewGuid());
order.Start();

IReadOnlyCollection<DomainEvent> domainEvents = order.GetDomainEvents();

order.ClearDomainEvents();

DomainEvent assigns:

  • Id with Guid.CreateVersion7();
  • OccurredOnUtc with DateTimeOffset.UtcNow.

The package only stores domain events. It does not dispatch, publish, persist, or serialize them.

Value Object

Use ValueObject for immutable concepts where equality is based on values instead of identity.

using PANiXiDA.Core.Domain;

public sealed class Money(decimal amount, string currency) : ValueObject
{
    public decimal Amount { get; } = amount;

    public string Currency { get; } = currency;

    protected override IEnumerable<object?> GetEqualityComponents()
    {
        yield return Amount;
        yield return Currency;
    }
}
Money first = new(10m, "USD");
Money second = new(10m, "USD");

bool areEqual = first == second;

Value object equality uses:

  • the same runtime type;
  • the ordered sequence returned by GetEqualityComponents().

Enumeration

Use Enumeration<TEnumeration> for stable, named domain values that need behavior and lookup methods.

using PANiXiDA.Core.Domain;

public sealed class OrderStatus : Enumeration<OrderStatus>
{
    public static readonly OrderStatus Draft = new(1, "Draft");
    public static readonly OrderStatus Submitted = new(2, "Submitted");
    public static readonly OrderStatus Cancelled = new(3, "Cancelled");

    private OrderStatus(int id, string name)
        : base(id, name)
    {
    }
}
OrderStatus submitted = OrderStatus.FromId(2);
OrderStatus cancelled = OrderStatus.FromName("Cancelled");

bool found = OrderStatus.TryFromName(" Submitted ", out OrderStatus? status);
IReadOnlyList<OrderStatus> allStatuses = OrderStatus.GetAll();

Enumeration behavior:

  • GetAll() returns public static values declared on the concrete type ordered by Id.
  • FromId(int) and FromName(string) return a value or throw InvalidOperationException.
  • TryFromId(int, out TEnumeration?) returns false when no value exists.
  • TryFromName(string, out TEnumeration?) trims surrounding whitespace and returns false for empty or whitespace names.
  • Names are compared with StringComparer.Ordinal.
  • Duplicate identifiers or names throw InvalidOperationException during cache creation.
  • Equality and ordering are based on identifiers within the concrete enumeration type.

Configuration

The package does not require runtime configuration, environment variables, external services, or dependency injection registration.

Development

Restore

dotnet restore

Format

dotnet format

Build

dotnet build --configuration Release

Test

dotnet test --configuration Release

Test with Coverage

dotnet test --configuration Release --coverage --coverage-output-format xml --coverage-output coverage.xml --results-directory TestResults

Pack

dotnet pack --configuration Release

Repository Layout

.
|-- src/
|   `-- PANiXiDA.Core.Domain/
|-- tests/
|   `-- PANiXiDA.Core.Domain.UnitTests/
|-- Directory.Build.props
|-- Directory.Build.targets
|-- Directory.Packages.props
|-- global.json
|-- version.json
|-- LICENSE
`-- README.md

Package Metadata

  • Package ID: PANiXiDA.Core.Domain
  • Target framework: net10.0
  • Repository: https://github.com/panixida-dotnet-core/domain
  • License: Apache-2.0
  • Versioning: Nerdbank.GitVersioning

License

This project is licensed under the Apache-2.0 license.

See the LICENSE file for details.

Maintainers

Maintained by PANiXiDA.

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 PANiXiDA.Core.Domain:

Package Downloads
PANiXiDA.Core.Application

Core application-layer abstractions and building blocks for .NET applications, including contracts, messaging, validation, and use case orchestration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 128 4/19/2026
1.0.2 98 4/19/2026