XForge.AutoMapper.Testing
0.16.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package XForge.AutoMapper.Testing --version 0.16.0
NuGet\Install-Package XForge.AutoMapper.Testing -Version 0.16.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="XForge.AutoMapper.Testing" Version="0.16.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XForge.AutoMapper.Testing" Version="0.16.0" />
<PackageReference Include="XForge.AutoMapper.Testing" />
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 XForge.AutoMapper.Testing --version 0.16.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XForge.AutoMapper.Testing, 0.16.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 XForge.AutoMapper.Testing@0.16.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=XForge.AutoMapper.Testing&version=0.16.0
#tool nuget:?package=XForge.AutoMapper.Testing&version=0.16.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XForge.AutoMapper
<p align="center"> <img src="manual/assets/XForge.png" alt="XForge.AutoMapper" width="128" height="128" /> </p>
Source-generator-first .NET object mapping library — zero reflection, NativeAOT safe, Blazor WASM friendly.
Quick Start
using XForge.AutoMapper;
// Option A: Explicit partial methods
[Mapper]
public partial class CustomerMapper
{
public partial CustomerDto ToDto(Customer source);
}
// Option B: AutoMapper-style
[Mapper]
[Map(typeof(Customer), typeof(CustomerDto))]
[Map(typeof(Order), typeof(OrderDto))]
public partial class AppMapper { }
// Usage:
var mapper = new AppMapper();
CustomerDto dto = mapper.Map<CustomerDto>(customer);
// Via strongly-typed interface:
IMapper<Customer, CustomerDto> iMapper = mapper;
CustomerDto dto2 = iMapper.Map(customer);
Features
- Source Generation — Primary code generation path, zero reflection on critical path
- NativeAOT & Trimming — Fully compatible with AOT compilation and IL trimming
- Blazor WASM — First-class support for WebAssembly scenarios
- Compile-time Diagnostics — XAM-prefixed warnings and errors before runtime
- AutoMapper-style API —
[Map<S,D>]attribute for class-level declarations - Multi-Source Mapping —
[MapFrom]for merging multiple sources into one destination - Reverse Mapping —
[MapReverse]andGenerateReversefor bidirectional mapping - Value Converters —
[ValueConverter]for property transformation during mapping - Conditional Mapping —
[MapWhen]to map only when source property is non-null - Null Substitution —
[NullSubstitute]for fallback values on null source properties - Before/After Hooks —
[BeforeMap]/[AfterMap]for side effects and auditing - LINQ Projection —
ProjectToforIQueryable/EF Core-safe expression trees - Flattening — Automatic nested-to-flat property mapping via PascalCase matching
- Unflattening — Automatic nested object construction from flat source properties (reverse of flattening)
- Records & Init-only — Full support for C# records and init-only properties
- Collections — Automatic collection iteration and element mapping
- DI Integration — Optional
IServiceCollectionregistration via assembly scanning - Testable —
MapperAsserthelpers for unit testing without DI container
Packages
Installation
dotnet add package XForge.AutoMapper
dotnet add package XForge.AutoMapper.SourceGeneration
Optional packages:
dotnet add package XForge.AutoMapper.Extensions.DependencyInjection
dotnet add package XForge.AutoMapper.Queryable
dotnet add package XForge.AutoMapper.Testing
Diagnostics
Compile-time diagnostics with the XAM prefix:
| ID | Severity | Description |
|---|---|---|
| XAM001 | Warning | Target property has no matching source property |
| XAM002 | Info | Source property is not mapped to any target property |
| XAM003 | Warning | Cyclic mapping detected (A→B and B→A in same mapper) |
| XAM004 | Error | Invalid value converter type |
| XAM005 | Error | Ambiguous mapping hook (MapMethodName required) |
| XAM006 | Error | Invalid [MapWhen] source property |
| XAM007 | Error | Invalid [MapReverse] method reference |
| XAM008 | Error | [Map] attribute conflicts with existing partial method |
| XAM009 | Warning | Multi-source property conflict (incompatible types across sources) |
| XAM010 | Error | [Mapper] class must be partial |
| XAM011 | Error | Mapper method must be partial |
| XAM012 | Warning | Duplicate [MapProperty] target |
Documentation
Complete enterprise-grade manual with examples from basic to advanced:
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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 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
- XForge.AutoMapper (>= 0.16.0)
- XForge.AutoMapper.Abstractions (>= 0.16.0)
-
net8.0
- XForge.AutoMapper (>= 0.16.0)
- XForge.AutoMapper.Abstractions (>= 0.16.0)
-
net9.0
- XForge.AutoMapper (>= 0.16.0)
- XForge.AutoMapper.Abstractions (>= 0.16.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.