Mapsicle 1.0.3

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

Mapsicle 🍦

NuGet Downloads License

Mapsicle is a high-performance, zero-dependency object mapper for .NET. It uses compiled Expression Trees to match properties at near-native speed, designed as a lightweight alternative to lightweight libraries.

Author

The Pitch

Feature Mapsicle AutoMapper
Dependencies 0 (Zero) many
Setup Instant (No Config) specific config/profiles
Performance Near Native Slower startup/first run
Case Insensitive Yes Configurable
Size ~100 Lines Large codebase

Quick Start

Install via NuGet:

dotnet add package Mapsicle

1. Simple Object Mapping

Just call .MapTo<T>() on any object. Matches properties by name (case-insensitive).

using Mapsicle;

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

// Map to UserDto
UserDto dto = user.MapTo<UserDto>();

2. List Mapping

Works seamlessly with lists and collections.

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

// Map to valid List<UserDto>
// Map to valid List<UserDto> (Returns List<T> directly)
List<UserDto> dtos = users.MapTo<UserDto>();

3. Update Existing Instance

Update a target object with values from a source. useful for database entities.

var existingUser = new UserDto { Id = 1, Name = "Old Name" };
var input = new User { Id = 1, Name = "New Name" };

// Updates existingUser in-place (ID=1, Name="New Name")
input.Map(existingUser);

Limitations

  • Circular References: Mapsicle does not support object graphs with circular references (e.g. Parent → Child → Parent). Mapping such objects will result in a StackOverflowException. Ensure your DTOs describe a Directed Acyclic Graph (DAG).
  • Complex Logic: No ForMember or custom resolvers. Strictly property-to-property mapping.

Behavior & Limitations

Mapsicle is designed to be simple and fast. It follows Strict Type Matching:

  • Property Matching: Properties are matched by name (case-insensitive).
  • Type Compatibility: Properties are only mapped if the Source type is assignable to the Destination type.
    • stringstring: ✅ Mapped
    • intint: ✅ Mapped
    • UserUser (Same Class): ✅ Mapped (Reference Copy)
    • SubClassBaseClass: ✅ Mapped
    • MapTo<T>(IEnumerable)List<T>: ✅ Mapped (Collections are automatically mapped to Lists)
    • ClassAClassB (Different Classes): ✅ Mapped (Deep Copy via Recursive Mapping)
    • intstring: ✅ Mapped (Coerced via ToString())
    • Enumint: ✅ Mapped (Coerced via Casting)
    • Enumint: ✅ Mapped (Coerced via Casting)
    • intint?: ✅ Mapped (Nullable Wrapping)
    • int?int: ✅ Mapped (Nullable Unwrapping, defaults to 0 if null)
  • Unmatched Properties: Properties in Source or Destination that do not match are simply ignored (no errors).

Constructor & Record Support

Mapsicle supports creating objects via constructors, enabling mapping to immutable Records:

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

Performance Logic

Mapsicle achieves its speed by using System.Linq.Expressions to generate and compile mapping code dynamically at runtime.

  1. First Run: When you call .MapTo<T>() for the first time on a pair of types (e.g., UserUserDto), Mapsicle inspects the properties of both types.
  2. Compilation: It builds a specialized delegate (function) that copies values from source to destination, handling type checks and assignments. This delegate is compiled into native code.
  3. Caching: This compiled delegate is stored in a ConcurrentDictionary.
  4. Subsequent Runs: Every future call fetches the compiled delegate from the cache and executes it immediately, incurring overhead comparable to writing the mapping code by hand.

License

MIT

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