JetMapper 1.2.2

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

<div align="center">

JetMapper

๐Ÿš€ JetMapper

A high-performance .NET object mapper - 2-4x faster than AutoMapper with 500%+ less memory usage.

NuGet License

</div>

โšก Why JetMapper?

  • โšก Ultra-Fast: Expression tree compilation for maximum performance - 2-4x faster than AutoMapper
  • ๐Ÿง  Memory Optimized: 500%+ savings in complex mappings
  • ๐Ÿ”’ Type Safe: Enhanced type compatibility checks
  • ๐Ÿš€ Low Allocation: Minimal memory usage
  • ๐Ÿ“ฆ Lightweight: Minimal dependencies
  • ๐ŸŒ Multi-Platform: .NET Standard 2.0/2.1, .NET Framework 4.6.2/4.7.2/4.8, .NET 6/7/8/9
  • ๐Ÿ”ง Easy to Use: Simple and intuitive API
  • โœจ Fluent API: Builder pattern for custom mappings
    • Set() - Property value assignment
    • SetIf() - Conditional value assignment
    • SetFirstIfExist() - First available property assignment
    • Ignore() - Ignore sensitive properties
    • BeforeMap()/AfterMap() - Lifecycle hooks

๐Ÿ“ฆ Installation

  dotnet add package JetMapper

๐ŸŽฏ Quick Start

Basic Mapping

The simplest way to map objects - just one line of code with zero configuration:

using JetMapper;

// Simple mapping
User user = new User { FirstName = "John", LastName = "Doe" };
UserDto dto = user.FastMapTo<UserDto>();

// Collection mapping
List<User> users = GetUsers();
List<UserDto> dtos = users.FastMapToList<User, UserDto>();

Fluent API

Build complex mappings with custom transformations and property assignments:

PersonDto dto = person.Builder()
    .MapTo<PersonDto>()
    .Set(d => d.FullName, p => $"{p.FirstName} {p.LastName}")
    .Set(d => d.Age, p => DateTime.Now.Year - p.BirthDate.Year)
    .Ignore(d => d.Password)
    .Create();

โœจ Advanced Features

Conditional Mapping

Assign values based on conditions - perfect for status fields and business logic:

AccountDto dto = account.Builder()
    .MapTo<AccountDto>()
    .SetIf(d => d.Status, a => a.IsActive, a => "Active")
    .SetIf(d => d.Status, a => !a.IsActive, a => "Inactive")
    .Create();

Priority Assignment

Choose the first available non-null value from multiple properties:

ContactDto dto = contact.Builder()
    .MapTo<ContactDto>()
    .SetFirstIfExist(d => d.PreferredContact,
        (d => d.Email, c => $"๐Ÿ“ง {c.Email}"),
        (d => d.Phone, c => $"๐Ÿ“ฑ {c.Phone}"),
        (d => d.Address, c => $"๐Ÿ  {c.Address}"))
    .Create();

Lifecycle Hooks

Execute custom logic before and after mapping - ideal for logging and validation:

OrderDto dto = order.Builder()
    .MapTo<OrderDto>()
    .BeforeMap((src, dest) => Console.WriteLine("Starting..."))
    .Set(d => d.OrderNumber, o => $"#ORD-{o.Id}")
    .AfterMap((src, dest) => Console.WriteLine("Completed!"))
    .Create();

Async Mapping

Process large datasets asynchronously with real-time progress tracking:

List<User> users = GetLargeUserList(); // 10,000+ records

Progress<AsyncMapper.MappingProgress> progress = new Progress<AsyncMapper.MappingProgress>(p =>
    Console.WriteLine($"Processing: {p.Percentage:F1}%"));

List<UserDto> dtos = await AsyncMapper.MapAsync<User, UserDto>(users, progress);

Diff Mapping

Compare two objects and detect changes automatically:

DiffResult diff = DiffMapper.FindDifferences(originalUser, updatedUser);

if (diff.HasDifferences)
{
    Console.WriteLine($"Found {diff.Differences.Count} changes");
    Console.WriteLine($"Similarity: {diff.SimilarityPercentage:F1}%");
}

Type Converters

Register custom type converters and enable automatic enum conversions:

// Register custom converters
MapperExtensions.AddTypeConverter<int, string>(n => n.ToString());
MapperExtensions.AddTypeConverter<DateTime, string>(dt => dt.ToString("yyyy-MM-dd"));

// Automatic enum conversions
ApiOrder apiOrder = new ApiOrder { Status = "processing" };
OrderDto dto = apiOrder.FastMapTo<OrderDto>(); // Status = OrderStatus.Processing

๐Ÿ“Š Performance

Benchmark Results (Apple M2, .NET 6)

Scenario JetMapper AutoMapper Speed Gain
Complex Mapping 94 ns 259 ns 2.76x faster
Bulk Mapping (1000) 73 ยตs 216 ยตs 2.97x faster
Employee Mapping 19 ยตs 84 ยตs 4.53x faster
Memory Usage JetMapper AutoMapper Savings
Complex 216 B 576 B 167%
Bulk (1000) 137 KB 593 KB 333%
Employee 49 KB 132 KB 173%

๐ŸŽฏ API Reference

Method Description
FastMapTo<T>() Simple one-line mapping
Builder() Start fluent mapping
Set() Assign property value
SetIf() Conditional assignment
SetFirstIfExist() Priority-based assignment
Ignore() Skip property
BeforeMap() / AfterMap() Lifecycle hooks
Create() Execute mapping

๐Ÿ”ง Advanced Features

MappingValidator

Validate mappings at compile-time to catch errors early:

ValidationResult result = MappingValidator.ValidateMapping<Person, PersonDto>();
if (!result.IsValid)
{
    foreach (ValidationError error in result.Errors)
        Console.WriteLine($"โŒ {error.PropertyName}: {error.Message}");
}

Snapshot & Restore

Save and restore object states for undo/redo functionality:

Snapshot snapshot = AsyncMapper.CreateSnapshot(user);
// Make changes...
User restored = AsyncMapper.RestoreFromSnapshot<User>(snapshot.Id);

Diagnostic Mapper

Profile performance and track metrics:

PerformanceProfile profile = DiagnosticMapper.StartPerformanceProfile("UserMapping");
// Perform mappings...
PerformanceResult result = DiagnosticMapper.EndPerformanceProfile("UserMapping");
Console.WriteLine($"Average: {result.AverageMappingTime.TotalMicroseconds:F2}ยตs");

Partial Merge

Merge specific properties from source to target:

MergeResult result = MergeMapper.PartialMerge(targetUser, sourceUser, "FirstName", "LastName");

๐ŸŒ Platform Support

  • .NET Standard 2.0, 2.1
  • .NET Framework 4.6.2, 4.7.2, 4.8
  • .NET 6.0, 7.0, 8.0, 9.0

๐Ÿ’ก Real-World Example

E-Commerce Order Processing - Transform database entities to view models with complex business logic:

public class OrderEntity
{
    public int Id { get; set; }
    public decimal Amount { get; set; }
    public decimal Tax { get; set; }
    public bool IsPaid { get; set; }
    public bool IsShipped { get; set; }
    public string CustomerEmail { get; set; }
    public DateTime CreatedAt { get; set; }
}

public class OrderViewModel
{
    public string OrderNumber { get; set; }
    public string TotalPrice { get; set; }
    public string Status { get; set; }
    public string ContactInfo { get; set; }
}

OrderEntity order = new OrderEntity
{
    Id = 12345,
    Amount = 500m,
    Tax = 90m,
    IsPaid = true,
    IsShipped = false,
    CustomerEmail = "customer@example.com",
    CreatedAt = DateTime.Now.AddDays(-2)
};

OrderViewModel viewModel = order.Builder()
    .MapTo<OrderViewModel>()
    .Set(vm => vm.OrderNumber, o => $"#ORD-{o.Id}")
    .Set(vm => vm.TotalPrice, o => $"${(o.Amount + o.Tax):F2}")
    .SetIf(vm => vm.Status, o => o.IsPaid && o.IsShipped, o => "โœ… Delivered")
    .SetIf(vm => vm.Status, o => o.IsPaid && !o.IsShipped, o => "๐Ÿšš In Transit")
    .SetIf(vm => vm.Status, o => !o.IsPaid, o => "โณ Awaiting Payment")
    .Set(vm => vm.ContactInfo, o => $"๐Ÿ“ง {o.CustomerEmail}")
    .Create();

// Result:
// OrderNumber = "#ORD-12345"
// TotalPrice = "$590.00"
// Status = "๐Ÿšš In Transit"
// ContactInfo = "๐Ÿ“ง customer@example.com"

๐Ÿ“š Documentation

For detailed examples and advanced usage:

  • Run benchmarks: dotnet run -c Release in benchmarks/JetMapper.Benchmarks
  • View examples: Check JetMapper.Console/Program.cs

๐Ÿค Contributing

Contributions are welcome! Feel free to:

  • Report bugs via GitHub Issues
  • Submit pull requests
  • Suggest new features

๐Ÿ“„ License

MIT License - See LICENSE file for details.


Made with โค๏ธ for the .NET community

Mennan Sevim

GitHub โ€ข NuGet โ€ข Report Issue

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 is compatible.  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 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 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  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.

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.2.3 92 10/25/2025
1.2.2 89 10/25/2025
1.2.0 86 10/25/2025
1.0.0 90 10/24/2025

v1.2.2: NuGet Compatibility Fix
     - 📝 Converted README from HTML to Markdown for better NuGet.org rendering
     - 🎨 Improved documentation display across all platforms
     
     v1.2.1: Documentation Fix
     - 🖼๏ธ Fixed README image display on NuGet and GitHub
     - 📝 Updated image paths to use GitHub raw URLs
     
     v1.2.0: Quality & Performance Release
     - 🐛 Fixed compiler warnings for cleaner builds
     - 📝 Enhanced documentation with social links
     - โœจ Code quality improvements
     
     v1.1.0: Multi-Platform Support Release
     - 🎯 Extended platform support: .NET Standard 2.0/2.1, .NET Framework 4.6.2/4.7.2/4.8, .NET 6/7/8/9
     - 🌐 Cross-platform compatibility for maximum reach
     
     v1.0.0: Initial Release - JetMapper - Lightning-Fast Object Mapper
     - โšก 2-4x faster than AutoMapper
     - 🧠 500%+ memory savings in complex scenarios
     - โœจ Fluent API with Builder Pattern (Set, SetIf, SetFirstIfExist, Ignore, Hooks)
     - โšก Async Mapping with progress tracking
     - 🔍 Diff Mapping for object comparison
     - 💾 Snapshot & Restore for undo/redo
     - โœ… Mapping Validator for compile-time validation
     - 🔧 Enhanced Type Converters and Custom Mapping
     - 📊 Diagnostic & Profiling tools
     - 🔄 Partial Merge strategies
     - 📚 Comprehensive documentation (English & Turkish)
     - 🎯 Zero configuration required
     - 🚀 Production ready