DomainMapper 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DomainMapper --version 1.0.0
                    
NuGet\Install-Package DomainMapper -Version 1.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="DomainMapper" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DomainMapper" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DomainMapper" />
                    
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 DomainMapper --version 1.0.0
                    
#r "nuget: DomainMapper, 1.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 DomainMapper@1.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=DomainMapper&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DomainMapper&version=1.0.0
                    
Install as a Cake Tool

DomainMapper

Map data. Preserve invariants.

DomainMapper is a small compile-time mapper for .NET with a domain-driven design bias. Its source generator emits direct C# and does not use runtime reflection. Version 1.0.0 focuses on an explicit API for mapping data through domain-owned constructors and factories.

Version 1.0.0

v1.0.0 is the first public release of DomainMapper. Install it from NuGet with:

dotnet add package DomainMapper --version 1.0.0

Domain-first mapping

using DomainMapper.Abstractions;

[DomainMapper]
public static partial class OrderMapper
{
    [DomainFactory(Input = DomainFactoryInput.Source)]
    private static OrderId ToOrderId(int value) => new(value);

    [MapToFactory(nameof(Order.Place))]
    public static partial Order Place(OrderDraft source);
}

[MapToFactory] makes the target-owned factory mandatory. DomainMapper binds source properties and additional mapping parameters to factory parameters by name and applies mapper-owned [DomainFactory] conversions where their source and target types match. Explicit mapping parameters take precedence over same-named root source properties. If the target cannot be constructed completely, generation fails instead of bypassing the domain boundary or silently dropping state.

Supported mappings

DomainMapper 1.0.0 supports:

  • mutable targets with accessible parameterless constructors;
  • immutable targets and records with accessible constructors;
  • target-owned static factories through [MapToFactory];
  • mapper-owned source-value and member-bound conversions through [DomainFactory];
  • nested objects, arrays, lists, read-only collection targets, and mutable or read-only dictionary interfaces;
  • existing-target property updates;
  • nested and generic mapper types and generic mapping methods;
  • direct generated code that enumerates general sequences and preallocates only when the source exposes a count.

Construction is fail-closed: every accessible writable target member must be mapped, and source-matched target state that is not writable from the generated mapper is rejected with DMPR101.

Configuration-heavy mapping, private-member mutation, projections, reference preservation, and derived-type dispatch are intentionally outside the 1.0.0 contract.

Build and test

dotnet restore DomainMapper.slnx -p:HUSKY=0
dotnet build DomainMapper.slnx --configuration Release --no-restore -p:HUSKY=0
dotnet test test/DomainMapper.Tests/DomainMapper.Tests.csproj --configuration Release --no-build -p:HUSKY=0

Run the sample with:

dotnet run --project samples/DomainMapper.Sample/DomainMapper.Sample.csproj

Benchmarks

The comparison suite pins Mapperly 4.3.1 and measures both generated runtime mappings and cold source generation in balanced execution orders.

DOMAINMAPPER_BENCHMARK_PAIRS=6 ./scripts/run-stable-benchmarks.sh

See the benchmark methodology.

Project layout

  • src/DomainMapper.Abstractions — four public, DDD-facing API types.
  • src/DomainMapper/Engine — contract discovery, semantic planning, conversion policy, and C# emission.
  • test/DomainMapper.Tests — engine contract and performance-gate tests.
  • benchmarks/DomainMapper.Benchmarks — balanced DomainMapper-versus-Mapperly evidence.
  • samples/DomainMapper.Sample — aggregate construction through a domain factory.

License

DomainMapper is licensed under Apache-2.0. Third-party attribution is retained in NOTICE.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DomainMapper:

Package Downloads
DomainMapper.Projections

Provider-neutral expression-tree projections for DomainMapper.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 98 8/20/2026
1.2.0 102 8/15/2026
1.1.0 292 8/15/2026
1.0.0 134 8/13/2026

DomainMapper 1.0.0

The first public release of DomainMapper, a compile-time .NET mapper with a domain-driven design bias.

Highlights

Direct generated C# with no runtime reflection.

Domain-owned constructors and static factories for invariant-preserving mappings.

Mutable and immutable targets, records, nested objects, collections, and dictionaries.

Existing-target updates plus nested and generic mapper support.

Fail-closed diagnostics when a target cannot be mapped completely.

Multi-Roslyn packaging for supported .NET compiler versions.

Install

Validation

57 unit and repository tests passed locally.

Hosted build, test, package validation, integration tests for .NET 8, 9, 10 and .NET Framework, lint, CodeQL, and static analysis passed.

The final NuGet artifact passed package validation before publication.