-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Martin Zahálka edited this page Feb 18, 2026
·
3 revisions
High-Performance Object Mapping for .NET
AutoMapper's fluent API + Mapperly's compile-time source generation = ZMapper
ZMapper is a high-performance .NET object mapping library that combines the best of both worlds:
-
AutoMapper's familiar fluent configuration API (
CreateMap,ForMember,MapFrom) - Mapperly's compile-time source generation for near-zero runtime overhead
All mapping code is generated at build time by a Roslyn source generator, resulting in ~17 ns per object mapping — on par with hand-written mapping code and 3x faster than AutoMapper.
| Feature | Description |
|---|---|
| Performance | ~17 ns per mapping, 3x faster than AutoMapper |
| Compile-Time Safety | No runtime reflection, all code generated at build time |
| Familiar API | AutoMapper-style fluent configuration |
| Zero Config | Single NuGet package, no separate analyzer needed |
| Modern .NET | Supports .NET 10 and netstandard2.0 (.NET Framework 4.6.1+) |
using ZMapper;
// 1. Define a mapping profile
public partial class UserProfile : IMapperProfile
{
public void Configure(MapperConfiguration config)
{
config.CreateMap<UserDto, User>()
.ForMember(dest => dest.FullName,
opt => opt.MapFrom(src => $"{src.FirstName} {src.LastName}"))
.ForMember(dest => dest.ContactEmail,
opt => opt.MapFrom(src => src.Email));
}
}
// 2. Use the mapper
IMapper mapper = Mapper.Create();
var user = mapper.Map<UserDto, User>(dto);
// Or use the auto-generated extension method
var user = dto.ToUser();- Getting Started — Installation, first mapping, profiles
- Configuration — CreateMap, ForMember, Ignore, and all fluent options
- Profiles and Dependency Injection — Organizing mappings, DI integration
- Collections and Batch Mapping — Arrays, lists, Span, IEnumerable
- Advanced Features — Hooks, conditional mapping, reverse mapping, nested objects
- API Reference — Complete interface and method reference
- Performance — Benchmarks, why ZMapper is fast
- Architecture — How the source generator works
- Supported Types — All supported .NET types
- Troubleshooting — Common issues and solutions
- Known Limitations — Current limitations and workarounds
- Examples — Full working examples
| Version | 1.2.1 |
| License | MIT |
| Author | Martin Zahalka |
| Repository | github.com/zcloudcz/ZMapper |
| NuGet | dotnet add package ZMapper |
| Frameworks | net10.0, netstandard2.0 |
ZMapper v1.2.1 | GitHub Repository | Report an Issue | MIT License