WMapper.Generic 1.0.0

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

🧠 AutoMapper Genérico

Este projeto é uma biblioteca de mapeamento objeto-para-objeto desenvolvida em .NET, com o objetivo de realizar cópias profundas (deep copy) entre objetos complexos — sem depender de bibliotecas de terceiros como AutoMapper.

✨ Funcionalidades

  • 🔁 Mapeamento de propriedades simples
  • 🧩 Suporte a objetos aninhados e grafos complexos
  • 📚 Mapeamento de listas e coleções aninhadas
  • 🚫 Ignorar propriedades com atributo [IgnoreMap]
  • 🔄 Atualização de objetos existentes (map de source em um destination já instanciado)
  • ⚡ Alto desempenho com uso de Expression Trees e cache de delegates

📁 Estrutura da Solução

/AutoMapper → Biblioteca principal com mapeadores e interfaces /Tests → Testes unitários com xUnit /Benchmarker → Projeto de benchmark com BenchmarkDotNet

🧪 Testes

A solução possui uma suíte de testes automatizados com xUnit:

dotnet test

🚀 Benchmarks

Benchmarks de performance com BenchmarkDotNet, comparando o mapper manual com um mapper externo ou de sua preferência:

cd Benchmarker
dotnet run -c Release

📌 Exemplos de Uso

using WMapper.Interfaces;

class Servico 
{
    private readonly IMapper _mapper;

    public Servico(IMapper mapper)
    {
        _mapper = mapper;
    }

    public void Handler()
    {
        // Mapeando para novo objeto
        var dto = _mapper.Map<Person, PersonDto>(pessoa);

        // Atualizando objeto existente
        _mapper.Map(pessoa, pessoaDtoExistente);

        // Mapeando lista
        var listaPessoas = new List<listaDto>();
        List<listaDto> result = _mapper.Map<Person, PersonDto>(listaPessoas);

        // Mapeando lista de listas
        var listaPessoas = new List<List<listaDto>>();
        List<List<listaDto>> result = _mapper.Map<Person, PersonDto>(listaPessoas);
    }
}

✅ Requisitos

  • .NET 6.0 ou superior

📦 NuGet

dotnet add package WMapper.Generic
// Recomenda-se injetar no conteiner DI da aplicação e utilziar-lo ia injeção de dependência.
// Opções de escopo: Scoped, Transient, Singleton
using WMapper;

builder.Services.AddAutoMapper() //Scoped
builder.Services.AddAutoMapperSingleton() //Singleton
builder.Services.AddAutoMapperTransient() //Transient

// Você também pode instanciar manualmente a classe concreta:
var mapper = new Mapper();

📝 Licença

Este projeto está licenciado sob a MIT License.

📊 Benchmarks

Você pode consultar os resultados dos benchmarks na pasta BenchmarkDotNet.Artifacts gerada após rodar os testes de performance.

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.

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.0 188 4/5/2025