Library.Mapping.Fody 8.2.6

Suggested Alternatives

Chd.Mapping.Fody

Additional Details

Use this package Chd.Mapping.Fody

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Library.Mapping.Fody --version 8.2.6
                    
NuGet\Install-Package Library.Mapping.Fody -Version 8.2.6
                    
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="Library.Mapping.Fody" Version="8.2.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Library.Mapping.Fody" Version="8.2.6" />
                    
Directory.Packages.props
<PackageReference Include="Library.Mapping.Fody" />
                    
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 Library.Mapping.Fody --version 8.2.6
                    
#r "nuget: Library.Mapping.Fody, 8.2.6"
                    
#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 Library.Mapping.Fody@8.2.6
                    
#: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=Library.Mapping.Fody&version=8.2.6
                    
Install as a Cake Addin
#tool nuget:?package=Library.Mapping.Fody&version=8.2.6
                    
Install as a Cake Tool

Library.Mapping

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.

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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated