BindMapper 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BindMapper --version 1.0.0
                    
NuGet\Install-Package BindMapper -Version 1.0.0
                    
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="BindMapper" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BindMapper" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BindMapper" />
                    
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 BindMapper --version 1.0.0
                    
#r "nuget: BindMapper, 1.0.0"
                    
#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 BindMapper@1.0.0
                    
#: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=BindMapper&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BindMapper&version=1.0.0
                    
Install as a Cake Tool

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.

License: MIT NuGet NuGet Downloads .NET


๐ŸŽฏ 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.0.1 89 2/18/2026
1.0.0 96 2/8/2026