BindMapper 1.0.0
See the version list below for details.
dotnet add package BindMapper --version 1.0.0
NuGet\Install-Package BindMapper -Version 1.0.0
<PackageReference Include="BindMapper" Version="1.0.0" />
<PackageVersion Include="BindMapper" Version="1.0.0" />
<PackageReference Include="BindMapper" />
paket add BindMapper --version 1.0.0
#r "nuget: BindMapper, 1.0.0"
#:package BindMapper@1.0.0
#addin nuget:?package=BindMapper&version=1.0.0
#tool nuget:?package=BindMapper&version=1.0.0
BindMapper
BindMapper is a high-performance object-to-object mapper for .NET, powered by Source Generators.
It generates optimized mapping code at compile-time, eliminating reflection overhead and delivering performance comparable to hand-written code.
๐ฏ What Problem Does It Solve?
| Scenario | AutoMapper | Mapster | BindMapper |
|---|---|---|---|
| Performance | 37.8 ns | 19.2 ns | 12.0 ns โก |
| Memory | High GC pressure | Medium | Near-zero |
| Setup complexity | High (profiles, configurations) | Medium | Minimal |
| Reflection | Yes (runtime) | Yes (IL emit) | None (compile-time) |
Best for: High-scale systems, microservices, performance-critical paths, low-latency applications.
๐ฆ Installation
dotnet add package BindMapper
Supported frameworks: .NET 6, 8, 9, 10
๐ Quick Start
Step 1: Define Models
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
public class UserDto
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
Step 2: Configure Mappings (Compile-Time)
using BindMapper;
public class MappingConfiguration
{
[MapperConfiguration]
public static void ConfigureMappings()
{
MapperSetup.CreateMap<User, UserDto>();
}
}
Step 3: Use at Runtime
var user = new User { Id = 1, Name = "John", Email = "john@email.com" };
var dto = Mapper.To<UserDto>(user);
var existingDto = new UserDto();
Mapper.To(user, existingDto); // zero allocation
๐ Complete API Reference
Single Object Mapping
var dto = Mapper.To<UserDto>(user);
Mapper.To(user, existingDto); // zero allocation
Collection Mapping
var list = Mapper.ToList<UserDto>(users);
var array = Mapper.ToArray<UserDto>(users);
var enumerable = Mapper.ToEnumerable<UserDto>(users);
var collection = Mapper.ToCollection<UserDto>(users);
Span Mapping (Advanced)
ReadOnlySpan<User> source = usersArray;
Span<UserDto> destination = stackalloc UserDto[source.Length];
Mapper.ToSpan(source, destination);
โ ๏ธ Destination span must be at least the same length as source.
๐ Property Mapping Rules
Source Property Destination Property Result
โโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโ
Exists, matches by name Matches โ
Mapped
Exists, different name Uses [MapFrom] attribute โ
Mapped
Exists [IgnoreMap] on dest โ Ignored
Exists No matching dest โ
Silent ignore
Null Not nullable โ ๏ธ VMAPPER009
Read-only โ Cannot assign
๐๏ธ Benchmarks (.NET 10 โ Intel i5-14600KF)
Mapper Mean (ns)
--------------------------------
Manual mapping 11.750
BindMapper 12.030
Mapster 19.174
AutoMapper 37.854
BindMapper runs within ~2% of hand-written mapping while eliminating runtime overhead.
๐ง How It Works
- Source Generator scans
[MapperConfiguration] - Extracts
CreateMap<TSource, TDest>calls - Generates plain C# mapping code
- JIT aggressively inlines generated methods
Generated files:
bin/Debug/net8.0/BindMapper.g.cs
๐งต Thread Safety
- All generated methods are stateless
- Fully thread-safe
๐ License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net10.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.