Transformations.Mapping 2.0.4.2

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

Transformations.Mapping

Zero-reflection, NativeAOT-safe object mapper powered by Roslyn source generators. Annotate your partial class and the compiler generates typed To{Target}(), From{Target}(), MapTo(), ToList(), and ProjectTo() methods — no runtime reflection, no IoC wiring.

NuGet .NET 8 | 9 | 10

📖 Overview

Transformations.Mapping replaces runtime reflection mappers with compile-time Roslyn source generators. Annotate your partial class once; the compiler emits typed mapping methods directly into your assembly — no runtime cost, no IoC wiring, no cold-start overhead.

🚀 Why Transformations.Mapping?

Runtime mappers like AutoMapper resolve mappings through reflection at startup: slow on first use, incompatible with NativeAOT/trimming, and silent about broken mappings until production. By shifting all mapping work to the compiler, Transformations.Mapping gives you zero runtime overhead, build-time errors when types fall out of sync, and generated .g.cs files you can actually inspect and debug. The generated code is plain C# — no proxies, no expression trees, nothing magic.

📦 Install

<PackageReference Include="Transformations.Mapping" Version="2.0.4.2" />

The source generator (Transformations.Mapping.Generator) is bundled in the package and activated automatically — no separate installation needed.


🚀 Quick Start

[MapTo<UserDto>]
public partial class User
{
    public int    Id       { get; set; }
    public string Name     { get; set; }
    public DateTime Birthday { get; set; }  // auto-converted to string

    [IgnoreMap]
    public string PasswordHash { get; set; }
}

// Generated at compile time — no reflection, no runtime cost:
UserDto dto        = user.ToUserDto();          // map to new instance
user.MapTo(dto);                                 // update existing instance
User back          = User.FromUserDto(dto);      // reverse map
List<UserDto> dtos = users.ToUserDtoList();      // map a collection
IQueryable<UserDto> q = db.Users.ProjectToUserDto(); // server-side projection

💡 Attributes

Attribute Purpose
[MapTo<TTarget>] Marks a partial class for mapping; generates all mapping methods
[IgnoreMap] Excludes a source property from all generated mappings
[MapProperty("TargetName")] Maps to a differently-named target property
[MapProperty("TargetName", SourcePath = "Address.City")] Flattens a nested source property path
[MapProperty("TargetName", Converter = nameof(MyConvert))] Uses a compile-time-validated static converter method

Rename example

public partial class User
{
    [MapProperty("DisplayName")]
    public string GlobalName { get; set; }

    [MapProperty("CityName", SourcePath = "Address.City")]
    public Address Address { get; set; }
}

Custom converter example

public partial class User
{
    [MapProperty("StatusLabel", Converter = nameof(FormatStatus))]
    public UserStatus Status { get; set; }

    private static string FormatStatus(UserStatus s) => s.GetEnumDescription();
}

🛠 Diagnostics

The bundled Roslyn analyzer runs at build time and flags mapping problems before they reach production:

Code When emitted
TXMAP001 A target member has no mapping from source
TXMAP002 Unsupported type conversion between source and target properties
TXMAP003 Source class is not partial
TXMAP004 Ambiguous mapping — multiple sources match the same target
TXMAP005 Nullable source mapped to non-nullable target without a converter
TXMAP006 Invalid SourcePath — path segment not found on source type
TXMAP007 Invalid Converter — method not found or wrong signature
TXMAP008 Circular mapping reference detected

Escalate TXMAP001 from warning to build error via MSBuild:

<PropertyGroup>
  <TransformationsMappingUnmappedMembersAsErrors>true</TransformationsMappingUnmappedMembersAsErrors>
</PropertyGroup>

Why Not AutoMapper?

AutoMapper Transformations.Mapping
Reflection Runtime None — compile-time
NativeAOT / Trimming Not supported Fully supported
Configuration Fluent profiles Attributes on source class
Errors caught at Runtime Build time
Generated code visible No Yes — inspectable .g.cs
Collection mapping Manual Auto-generated
Reverse mapping Manual Auto-generated

See MAPPING_GUIDE.md for flattening, converters, query projection, and AutoMapper migration notes.
See MAPPING_BENCHMARKS.md for BenchmarkDotNet comparisons.


📦 Dependencies

  • Transformations.Core
  • Transformations.Mapping.Generator (source generator — bundled, not a runtime dependency)

License

MIT — Copyright © 2026 opentail.net

Product 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Transformations.Mapping:

Package Downloads
Transformations

Modern .NET transformation helpers for conversion, strings, collections, data, web, diagnostics, batching, and resilience.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.4.2 92 7/7/2026
2.0.4.1 105 7/7/2026
2.0.0 121 4/10/2026