SwiftMapper 1.0.1

dotnet add package SwiftMapper --version 1.0.1
                    
NuGet\Install-Package SwiftMapper -Version 1.0.1
                    
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="SwiftMapper" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SwiftMapper" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="SwiftMapper" />
                    
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 SwiftMapper --version 1.0.1
                    
#r "nuget: SwiftMapper, 1.0.1"
                    
#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 SwiftMapper@1.0.1
                    
#: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=SwiftMapper&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=SwiftMapper&version=1.0.1
                    
Install as a Cake Tool

⚡ SwiftMapper

SwiftMapper

NuGet License: MIT Build

SwiftMapper is a fast, lightweight object-to-object mapper for .NET.
Inspired by AutoMapper, but optimized for simplicity and speed.


✨ Features

  • 🚀 High-performance property mapping
  • 🔹 Maps by matching property names
  • 🔹 Supports nested object mapping
  • 🔹 Maps lists and collections
  • 🔹 Converts enums to/from underlying ints or names
  • 🔹 Allows injecting sub-objects not present in the source

📦 Install

From your project directory:

dotnet add package SwiftMapper

Or via Package Manager:

Install-Package SwiftMapper

⚡ Quick Start

1) Flat + nested mapping

using SwiftMapper;

var user = new User
{
    Id = 42,
    Name = "Ada",
    Status = UserStatus.Active,
    Address = new Address { Street = "123 Main", City = "London" }
};

var userDto = Mapper.Map<User, UserDto>(user);
// userDto.Id == 42
// userDto.Name == "Ada"
// userDto.Status == 1           // enum -> underlying int
// userDto.Address != null       // nested object mapped by name

2) List mapping

var order = new Order
{
    OrderId = 1001,
    Items = new List<OrderItem>
    {
        new OrderItem { Sku = "ABC", Quantity = 2 },
        new OrderItem { Sku = "XYZ", Quantity = 5 }
    }
};

var orderDto = Mapper.Map<Order, OrderDto>(order);
// orderDto.Items.Count == 2

3) Inject a sub-object

var withProfile = new WithProfile { Id = "p-123" };
var injectedProfile = new ProfileDto { DisplayName = "Ada Lovelace", Email = "ada@example.com" };

var withProfileDto = Mapper.Map<WithProfile, WithProfileDto>(withProfile, ("Profile", injectedProfile));
// withProfileDto.Profile references injectedProfile

🛠 API

TDestination Mapper.Map<TSource, TDestination>(
    TSource source,
    params (string SubPropertyName, object PropertyValue)[] subObjectValues)
    where TSource : class
    where TDestination : class, new();
  • Maps writable destination properties by name from the source
  • Nested objects and lists are mapped recursively
  • Enums convert to underlying ints (and strings parse into enums)
  • subObjectValues lets you inject destination sub-objects by name

📌 Notes

  • Source must be non-null.
  • Read-only destination properties are skipped.
  • Mapping uses reflection. For performance-sensitive paths, consider caching or limiting excessive allocations.

🤝 Contributing

Contributions are welcome! 🎉

  • Open an issue for bugs or feature requests
  • Submit PRs with tests for new features or fixes

📜 License

MIT License – see LICENSE.txt.


Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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 137 9/3/2025
1.0.0 144 8/31/2025