Chd.Mapping.Abstractions 8.0.5

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

Library.Mapping.Abstractions

Chd (Cleverly Handle Difficulty) library helps you cleverly handle difficulty, write code quickly, and keep your application stable.

This library contains abstractions for below packages

What is Library.Mapping?

Library.Mapping is a high-performance, compile-time object mapper for .NET applications. It generates mapping code during your build, eliminating both the runtime reflection overhead and common type-safety pitfalls of traditional mappers.

Why Compile-time Mapping?

  • Performance: Mapping logic is generated and inlined during compilation. No reflection or emitted code at runtime.
  • Type Safety: Catches potential mapping errors during build instead of at runtime.
  • IDE Support: Full access to code analysis, refactoring tools, and intellisense.
  • Debuggability: Trace actual mapping logic in code, set breakpoints, and step through mappings.

Compile-time vs Runtime Mapping

Feature Compile-time Mapping (Library.Mapping) Runtime Mapping (AutoMapper/Mapster)
Performance Fastest (Ahead-of-Time, no reflection) Slower (Reflection/Emission)
Type Safety Compile-time error detection Runtime errors possible
Refactoring IDE-friendly, easy renaming Mapping config requires manual update
Debugging Set breakpoints, step over code Hard to debug, dynamic code
Deployment No mapper runtime dependency Needs mapping lib at runtime

.NET Benchmark Results

Scenario AutoMapper (ms) Mapster (ms) Library.Mapping (ms)
1M DTO→Entity Map (Release x64) 980 410 180
100K Entity→DTO Map with Nesting 180 74 34
Flat object, assign all properties 22 10 4

Benchmark code in /benchmarks/Mapping.Benchmark.

Installation

1. Install NuGet package:

Install-Package Library.Mapping.Fody

2. Add FodyWeavers.xml: In the root of your project, add or update:

<Weavers>
  <Library.Mapping/>
</Weavers>

3. Build project:

  • The weaver will generate mapper implementations during build.

Code Samples: Modern DTO-Entity Mapping

Define DTO and Entity:

using Library.Mapping;

public class UserDto {
    [MapTo(typeof(UserEntity))]
    public int Id { get; set; }
    public string Name { get; set; }
}

public class UserEntity {
    [MapFrom(typeof(UserDto))]
    public int Id { get; set; }
    public string Name { get; set; }
}

Operator Injection

Both source and target can define implicit/explicit conversion operators, or use provided extension methods:

var entity = userDto.MapTo<UserEntity>(); // Extension method
UserEntity entity2 = userDto; // Operator overload (if injected by mapping)

Usage

After building, mapping methods and conversions are generated. Example usage:

var dto = new UserDto { Id = 1, Name = "Alice" };
UserEntity entity = dto; // Implicitly mapped
var dto2 = entity.MapTo<UserDto>(); // Back to DTO
  • All mappings are validated at compile-time.
  • Customization via mapping attributes available (see wiki).

Build & Integration Tips

  • Confirm Fody packages are installed and correct FodyWeavers.xml exists.
  • Clean & rebuild if generated code isn't appearing.
  • Compatible with .NET Core, .NET Framework, and SDK-style projects.
  • No runtime dependency except standard BCL.

Test & Benchmark

  • See /benchmarks/Mapping.Benchmark project for reproducible performance data.
  • CI runs mapping integration tests on PRs.

Test Repository For Usage

This repository contains examples of how to use the Library.Mapping package in different scenarios, including DTO-Entity mapping, operator injection, and performance benchmarks.

Authors

Acknowledgements

  • Inspired by Fody community and .NET performance advocates.
  • Thanks to users reporting issues and requesting features.
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 (3)

Showing the top 3 NuGet packages that depend on Chd.Mapping.Abstractions:

Package Downloads
Chd.Mapping.Roslyn

Chd (Cleverly Handle Difficulty) packages are easy to use. Automatically maps DTO and Entity classes without any configuration, generating implicit mapping operators at compile time using [MapTo] and optional property-level mapping via [MapProperty].

Chd.Mapping.Roslyn.Advanced

Chd (Cleverly Handle Difficulty) packages are easy to use. Automatically maps DTO and Entity classes without any configuration. Now supports advanced mapping scenarios, custom value converters, nested object mapping, and improved performance for large projects.

Chd.Mapping.Fody

Chd (Cleverly Handle Difficulty) packages are easy to use. High-performance, compile-time object mapping for .NET. Chd.Mapping.Fody generates type-safe, zero-reflection mapping code between DTOs and entities using simple attributes. All mapping logic is injected at build time for maximum speed and no runtime dependency. Supports property renaming, nested mapping, and implicit/explicit

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.5 286 2/19/2026
8.0.4 367 1/23/2026
8.0.3 250 1/20/2026
8.0.2 496 1/19/2026
8.0.1 679 1/15/2026