Mapsicle 1.0.4

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

Mapsicle 🍦

NuGet Downloads License: MIT

ko-fi

Mapsicle is a high-performance, zero-dependency object mapper for .NET. It uses compiled Expression Trees to achieve near-native mapping speed with zero configuration required.

"The fastest mapping is the one you don't have to configure."


πŸš€ Why Switch from AutoMapper?

⚠️ AutoMapper is now commercial software. As of version 13+, AutoMapper requires a paid license for commercial use. Mapsicle remains 100% free and MIT licensed forever.

Feature Mapsicle AutoMapper
License MIT (Free Forever) Commercial (Paid)
Dependencies 0 (Zero) 5+ packages
Setup Required None Profiles, CreateMap, DI
Binary Size ~15KB ~500KB+
Flattening Built-in by convention Requires ForMember config
Case Sensitivity Case-insensitive Configurable

Real Talk: When to Use What

βœ… Use Mapsicle when:

  • You want zero configuration complexity
  • You want to avoid commercial licensing fees
  • Performance matters (APIs, high-throughput services)
  • You're mapping simple-to-moderate object graphs
  • You hate NuGet dependency bloat

⚠️ Use AutoMapper when:

  • You need complex ForMember logic with external dependencies
  • You're deeply invested in AutoMapper's ecosystem and have a commercial license

πŸ“Š Benchmark Results

Real benchmarks using BenchmarkDotNet on Apple M1, .NET 8.0:

Scenario Manual Mapsicle AutoMapper Winner
Single Object 31 ns 59 ns 72 ns πŸ₯‡ Mapsicle
Flattening 14 ns 29 ns 56 ns πŸ₯‡ Mapsicle (2x faster!)
Collection (100) 3.5 ΞΌs 7.0 ΞΌs 4.0 ΞΌs AutoMapper

Key Insights:

  • Single object mapping: Mapsicle is 22% faster than AutoMapper
  • Flattening: Mapsicle is 48% faster than AutoMapper (no config needed!)
  • Cold start: ~284ΞΌs for first mapping (expression compilation)
  • Memory: Same allocation as AutoMapper (120 bytes for single object)

Run benchmarks yourself:

cd tests/Mapsicle.Benchmarks
dotnet run -c Release

πŸ“¦ Installation

dotnet add package Mapsicle

That's it. No DI registration, no profiles, no configuration.


⚑ Quick Start

Basic Mapping

using Mapsicle;

var user = new User { Id = 1, Name = "Alice", Email = "alice@mail.com" };

// One line. That's it.
UserDto dto = user.MapTo<UserDto>();

Collection Mapping

var users = new List<User> { new() { Name = "Alice" }, new() { Name = "Bob" } };

// Direct List<T> result
List<UserDto> dtos = users.MapTo<UserDto>();

// Or as an array
UserDto[] array = users.MapToArray<UserDto>();

Map to Existing Object

var existing = new UserDto { Id = 1, Name = "Old", Email = "keep@me.com" };
var source = new User { Id = 1, Name = "New" };

source.Map(existing);
// existing.Name = "New", existing.Email = "keep@me.com" (preserved)

🌟 Features

1. Automatic Flattening

No configuration needed. Just follow the naming convention:

public class Order { public Customer Customer { get; set; } }
public class Customer { public string Email { get; set; } }

// Destination DTO
public class OrderDto
{
    public string CustomerEmail { get; set; }  // Auto-mapped from Customer.Email!
}

var dto = order.MapTo<OrderDto>();  // CustomerEmail is populated automatically

2. Attribute-Based Configuration

public class UserDto
{
    [MapFrom("UserName")]           // Map from different property name
    public string Name { get; set; }

    [IgnoreMap]                      // Never mapped
    public string Password { get; set; } = "NOT_MAPPED";
}

3. Dictionary Mapping

// Object to Dictionary
var dict = user.ToDictionary();
// { "Id": 1, "Name": "Alice", "Email": "alice@mail.com" }

// Dictionary to Object
var restored = dict.MapTo<User>();

4. Smart Type Coercion

Source β†’ Destination Supported
string β†’ string βœ…
int β†’ string βœ… (via ToString)
Enum β†’ int βœ…
int β†’ int? βœ…
int? β†’ int βœ… (default if null)
ClassA β†’ ClassB βœ… (recursive mapping)
List<A> β†’ List<B> βœ…
IEnumerable β†’ T[] βœ…

5. Record & Immutable Type Support

public record UserRecord(int Id, string Name);
var rec = source.MapTo<UserRecord>();  // Works via constructor

6. Cache Management

var info = Mapper.CacheInfo();  // { MapToEntries: 5, Total: 5 }
Mapper.ClearCache();            // Reset for testing

πŸ”§ Migration from AutoMapper

Before (AutoMapper)

// Startup.cs
services.AddAutoMapper(typeof(MappingProfile));

// MappingProfile.cs
public class MappingProfile : Profile
{
    public MappingProfile()
    {
        CreateMap<User, UserDto>();
        CreateMap<Order, OrderDto>()
            .ForMember(d => d.CustomerEmail, opt => opt.MapFrom(s => s.Customer.Email));
    }
}

// Usage
var dto = _mapper.Map<UserDto>(user);

After (Mapsicle)

// No startup config needed!

// Usage
var dto = user.MapTo<UserDto>();

// Flattening works automatically with naming convention
// Order.Customer.Email β†’ OrderDto.CustomerEmail βœ…

⚠️ Limitations

  • Circular References: Not supported (will cause StackOverflowException)
  • Complex Resolvers: No ForMember with custom logicβ€”use [MapFrom] for simple cases
  • Deep Customization: If you need per-field transformation logic, write it manually

πŸ“ Project Structure

Mapsicle/
β”œβ”€β”€ src/Mapsicle/           # Core library (~400 lines)
└── tests/
    β”œβ”€β”€ Mapsicle.Tests/     # 56+ unit tests
    └── Mapsicle.Benchmarks/ # Performance benchmarks

🀝 Contributing

PRs welcome! Areas for contribution:

  • Performance optimizations
  • Additional type coercion scenarios
  • Documentation improvements

πŸ“„ License

MIT License Β© Arnel Isiderio Robles


<p align="center"> <strong>Stop configuring. Start mapping.</strong><br> <em>Free forever. Zero dependencies. Pure performance.</em> </p>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Mapsicle:

Package Downloads
Mapsicle.Fluent

Fluent configuration API for Mapsicle. Adds expression-based mapping, ForMember, Ignore, Condition, and configuration validation.

Mapsicle.EntityFramework

Entity Framework Core integration for Mapsicle. Adds ProjectTo<T>() for IQueryable projections that translate to SQL.

Mapsicle.Dapper

Dapper integration for Mapsicle - Bridge Dapper query results to mapped DTOs with fluent extensions

Mapsicle.Serilog

Serilog integration for Mapsicle - Structured logging for mapping operations with performance tracking

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.2 426 3/3/2026
1.2.0 254 1/23/2026
1.1.0 237 1/19/2026
1.0.8 234 12/26/2025
1.0.6 242 12/24/2025
1.0.4 251 12/23/2025
1.0.3 290 12/19/2025
1.0.1 155 12/27/2025
1.0.0 424 12/11/2025