ForgeSharp.Mapper 1.0.0

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

ForgeSharp.Mapper

ForgeSharp.Mapper is a high-performance, type-safe, and extensible object mapping library for .NET. It enables you to define, configure, and execute mappings between different object types using a fluent, strongly-typed API. The library is designed for speed, maintainability, and ease of integration with modern .NET applications.


Features

  • Fluent, Type-Safe API:
    Define mappings using expressive, chainable syntax with full compile-time safety.
  • Reflection-Free Runtime Mapping:
    Mappings are compiled to delegates for maximum performance and Native AOT.
  • Extensible Builder Pattern:
    Easily register and configure mappings for any type combination.
  • Validation Tools:
    Built-in utilities to detect unmapped properties and validate mapping completeness.
  • Dependency Injection Ready:
    Seamless integration with Microsoft.Extensions.DependencyInjection.
  • Advanced Scenarios:
    Supports custom mapping logic, property transformations, and cloning.

Installation

Add the NuGet package to your project:

dotnet add package ForgeSharp.Mapper

Quick Start

1. Define a Mapper Builder

public class MyMapperBuilder : MapperBuilder
{
    public MyMapperBuilder()
    {
        Register<Source, Destination>()
            .To(d => d.Name).From(s => s.SourceName)
            .To(d => d.Age).From((s, d) => s.Years + 1);
    }
}

2. Register the Mapper in DI

services.AddMapper<MyMapperBuilder>();

3. Use the Mapper

var mapper = serviceProvider.GetRequiredService<IMapperService>();
var destination = mapper.Map<Source, Destination>(sourceObject);

Advanced Usage

Cloning

Register<MyType, MyType>().UseReflectionToClone();

Validation

var tester = serviceProvider.GetRequiredService<IMapperTester>();
foreach (var result in tester.ValidateMissingProperties())
{
    Console.WriteLine(result);
}

Custom Reflection-Based Mapping

register.AddAssignment(
    typeof(Destination).GetProperty(nameof(Destination.SomeProperty)),
    (Expression<Func<Source, string>>)(s => s.SomeSourceProperty)
);

API Overview

  • IMapperService: Main entry point for mapping operations.
  • MapperBuilder: Base class for registering and configuring mappings.
  • IMapperRegister: Fluent interface for mapping configuration.
  • IMapperTester: Utility for validating mapping completeness.
  • ReflectionExtension / ConfigureExtension / CloneExtension: Helpers for advanced and reflection-based mapping scenarios.

Project Structure

  • MapperRegistry.cs – Core fluent mapping API and registry.
  • MapperService.cs – Service and DI integration.
  • MapperTester.cs – Validation and diagnostics.
  • Reflection/ – Extensions for reflection-based and advanced mapping.

Requirements

  • .NET 8.0 or later

Contributing

Contributions are welcome! Please open issues or submit pull requests for bug fixes, improvements, or new features.


License

MIT License


Acknowledgements

  • Inspired by AutoMapper and other mapping libraries, but designed for maximum performance, type safety and zero reflection.
  • Built with modern C# features and best practices.

Contact

For questions, suggestions, or support, please open an issue on GitHub.


ForgeSharp.Mapper – Fast, type-safe, and extensible mapping for .NET.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ForgeSharp.Mapper:

Package Downloads
ForgeSharp.Mapper.DependencyInjection

Dependancy Injection extension for ForgeSharp.Mapper

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.2 311 12/13/2025
1.2.1 225 7/10/2025
1.2.0 217 7/9/2025
1.1.0 284 7/2/2025
1.0.0 180 6/28/2025