Mapperly
Mapperly is a high-performance, compile-time object mapping library for .NET, developed by Riok. It leverages .NET Source Generators to automate the creation of object-to-object mappings, eliminating the need for runtime reflection and reducing boilerplate code.(mapperly.riok.app, mapperly.riok.app)
🔧 Key Features
-
Compile-Time Code Generation: Mapperly generates mapping code during the build process, ensuring minimal runtime overhead and enhancing performance. (Mohamad Dbouk)
-
No Runtime Reflection: By avoiding runtime reflection, Mapperly is trimming-safe and Ahead-of-Time (AOT) compilation friendly. (mapperly.riok.app)
-
Readable and Debuggable Code: The generated mapping code is clean and easy to understand, facilitating debugging and maintenance. (GitHub)
-
Customizable Mapping Strategies: Developers can configure how null values are handled and define property name mapping strategies, such as case-insensitive matching. (mapperly.riok.app)
-
Performance Benchmarks: In benchmarks, Mapperly has demonstrated superior performance over traditional mappers like AutoMapper, with faster execution times and lower memory usage. (Logiwa Tech)
🚀 Getting Started
-
Installation: To add Mapperly to your project, run the following command:
dotnet add package Riok.Mapperly -
Define a Mapper: Create a partial class and apply the
[Mapper]attribute to define your mapping methods.using Riok.Mapperly.Abstractions; [Mapper] public partial class CarMapper { public partial CarDto CarToCarDto(Car car); } -
Use the Mapper: Instantiate the mapper and perform the mapping.
var mapper = new CarMapper(); var car = new Car { NumberOfSeats = 10 }; var dto = mapper.CarToCarDto(car);
📚 Learn More
-
Documentation: Explore the official documentation for detailed guidance. (mapperly.riok.app)(NuGet)
-
GitHub Repository: Access the source code and contribute to the project. (GitHub)
-
NuGet Package: Download the latest version of Mapperly. (NuGet)
Mapperly is an excellent choice for .NET developers seeking a fast, efficient, and maintainable solution for object mapping. Its compile-time code generation and absence of runtime reflection make it a modern alternative to traditional mapping libraries.(Mohamad Dbouk)
Created on: 2025-08-27