DomainMapper 1.1.0
See the version list below for details.
dotnet add package DomainMapper --version 1.1.0
NuGet\Install-Package DomainMapper -Version 1.1.0
<PackageReference Include="DomainMapper" Version="1.1.0" />
<PackageVersion Include="DomainMapper" Version="1.1.0" />
<PackageReference Include="DomainMapper" />
paket add DomainMapper --version 1.1.0
#r "nuget: DomainMapper, 1.1.0"
#:package DomainMapper@1.1.0
#addin nuget:?package=DomainMapper&version=1.1.0
#tool nuget:?package=DomainMapper&version=1.1.0
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.1.0 adds explicit mapping contracts while retaining domain-owned constructors and factories.
Version 1.1.0
Install DomainMapper from NuGet with:
dotnet add package DomainMapper --version 1.1.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.1.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;
- explicit property and field renames, including nested source paths;
- typed computed target members and additional mapping parameters;
- target/source completeness, typed ignores, and allow-listed partial updates;
- conditional and null-aware assignments with constant substitution;
- typed completion hooks, mapping composition, and bounded recursion;
- 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.
Fields participate when they are named by an explicit mapping contract; convention mapping remains property-only for compatibility. See the authoritative capabilities and limitations and versioned changelog.
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.
Query projections, a generated runtime registry, private-member mutation, reference preservation, and derived-type dispatch remain unsupported.
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— public, compile-time mapping attributes and policy 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 | Versions 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. |
-
.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.
Features
Add explicit property and field bindings with validated nested source paths.
Add computed target members, typed conditions, ordered completion hooks, and additional mapping parameters.
Add target and source ignores, target allow-lists for updates, and configurable completeness policies.
Add per-member null behavior and constant substitution.
Add reusable mapping includes and bounded recursive mapping with generated depth guards.
Compatibility and performance
Keep convention mapping property-only and compatible with DomainMapper 1.0; fields participate only when explicitly configured.
Preserve the fast convention-only compiler path and cache Roslyn member metadata per compilation.
Add diagnostics DMPR102 through DMPR104 for invalid configuration and completeness enforcement.
Full changelog: https://github.com/skuirrels/DomainMapper/compare/v1.0.0...v1.1.0