Mapsicle 1.0.0
See the version list below for details.
dotnet add package Mapsicle --version 1.0.0
NuGet\Install-Package Mapsicle -Version 1.0.0
<PackageReference Include="Mapsicle" Version="1.0.0" />
<PackageVersion Include="Mapsicle" Version="1.0.0" />
<PackageReference Include="Mapsicle" />
paket add Mapsicle --version 1.0.0
#r "nuget: Mapsicle, 1.0.0"
#:package Mapsicle@1.0.0
#addin nuget:?package=Mapsicle&version=1.0.0
#tool nuget:?package=Mapsicle&version=1.0.0
Mapsicle 🍦
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>
List<UserDto> dtos = users.MapTo<UserDto>().ToList();
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
ForMemberor 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.
string→string: ✅ Mappedint→int: ✅ MappedUser→User(Same Class): ✅ Mapped (Reference Copy)SubClass→BaseClass: ✅ MappedClassA→ClassB(Different Classes): ✅ Mapped (Deep Copy via Recursive Mapping)int→string: ✅ Mapped (Coerced viaToString())Enum→int: ✅ Mapped (Coerced via Casting)Enum→int: ✅ Mapped (Coerced via Casting)int→int?: ✅ 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.
- First Run: When you call
.MapTo<T>()for the first time on a pair of types (e.g.,User→UserDto), Mapsicle inspects the properties of both types. - 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.
- Caching: This compiled delegate is stored in a
ConcurrentDictionary. - 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 | Versions 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. |
-
.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.