Skip to main content

Introduction

Nuget Nuget GitHub

Mapperly is a .NET source generator for generating object mappings. Inspired by MapStruct. It drastically simplifies the implementation of object to object mappings. One only needs to define the mapping methods signature. The implementation is provided by Mapperly.

Because Mapperly creates the mapping code at build time, there is minimal overhead at runtime. Even better, the generated code is perfectly readable, allowing you to verify the generated mapping code easily.

Mapperly works by using .NET Source Generators. Since no reflection is used at runtime, the generated code is completely trimming save and AOT friendly.

Mapperly is one of the fastest .NET object mapper out there, surpassing even the naive manual mapping approach! The benchmark was generated with Benchmark.netCoreMappers.

MethodMeanErrorStdDevGen 0Allocated
AgileMapper1,523.8 ns3.90 ns3.25 ns1.51063,160 B
TinyMapper4,094.3 ns3.90 ns3.05 ns1.03002,160 B
ExpressMapper2,595.8 ns5.49 ns5.14 ns2.34224,904 B
AutoMapper1,203.9 ns2.30 ns2.15 ns0.90981,904 B
ManualMapping529.6 ns0.52 ns0.44 ns0.55411,160 B
Mapster562.1 ns1.14 ns0.89 ns0.90981,904 B
Mapperly338.5 ns0.95 ns0.84 ns0.4396920 B

Requirements‚Äč

Mapperly supports .NET 5+ and .NET Framework 4.x. Mapperly requires at least C# language version 9.