FlexMapper.DependencyInjection
1.0.4
See the version list below for details.
dotnet add package FlexMapper.DependencyInjection --version 1.0.4
NuGet\Install-Package FlexMapper.DependencyInjection -Version 1.0.4
<PackageReference Include="FlexMapper.DependencyInjection" Version="1.0.4" />
<PackageVersion Include="FlexMapper.DependencyInjection" Version="1.0.4" />
<PackageReference Include="FlexMapper.DependencyInjection" />
paket add FlexMapper.DependencyInjection --version 1.0.4
#r "nuget: FlexMapper.DependencyInjection, 1.0.4"
#:package FlexMapper.DependencyInjection@1.0.4
#addin nuget:?package=FlexMapper.DependencyInjection&version=1.0.4
#tool nuget:?package=FlexMapper.DependencyInjection&version=1.0.4
FlexMapper
FlexMapper is a lightweight object-mapping library for .NET 8.
It maps objects by convention and lets you configure reverse mapping, custom members, ignored members, lists, arrays, nested objects, and type converters.
Structure
src/
FlexMapper/ Core library
FlexMapper.DependencyInjection/ ASP.NET Core DI integration
samples/
ConsoleSample/ Simple console example
tests/
FlexMapper.Tests/ Automated xUnit tests
FlexMapper.Real/ Real projects that validate NuGet usage
docs/
getting-started.md Usage guide
packaging.md Building and consuming local packages
architecture.md Architecture overview
roadmap.md Next steps
release/ Output of the generated NuGet packages
Install
Core package:
dotnet add package FlexMapper
ASP.NET Core integration:
dotnet add package FlexMapper.DependencyInjection
Basic usage
var config = new MapperConfiguration();
config.Map<Produto, ProdutoDto>()
.Reverse();
var mapper = config.Build();
var dto = mapper.To<ProdutoDto>(produto);
var domain = mapper.To<Produto>(dto);
ASP.NET Core
builder.Services.AddFlexMapper(cfg =>
{
cfg.Map<Produto, ProdutoDto>()
.Reverse();
});
Profiles (organize mappings in classes)
To avoid centralizing everything in the builder, group your mappings in classes that inherit from FlexMapperProfile and register them by scanning assemblies (the same workflow as AddAutoMapper).
public sealed class ProdutoMapping : FlexMapperProfile
{
public override void Configure(MapperConfiguration cfg)
{
cfg.Map<Produto, ProdutoDto>()
.For(dest => dest.CategoriaNome, src => src.Categoria!.Descricao)
.Reverse();
cfg.AddConverter<bool, string>(value => value ? "SIM" : "NAO");
}
}
Registration in ASP.NET Core:
// Scans the assembly and applies every FlexMapperProfile found
builder.Services.AddFlexMapper(typeof(ProdutoMapping).Assembly);
// Multiple assemblies
builder.Services.AddFlexMapper(AppDomain.CurrentDomain.GetAssemblies());
// Profiles plus additional inline configuration
builder.Services.AddFlexMapper(cfg =>
{
cfg.AddConverter<bool, string>(value => value ? "SIM" : "NAO");
}, typeof(ProdutoMapping).Assembly);
The scan skips abstract types and requires a parameterless constructor. All profiles share the same configuration, resulting in a single IFlexMapper singleton.
Custom member
cfg.Map<Pessoa, PessoaDto>()
.For(dest => dest.Nome, src => src.NomeCompleto)
.Reverse();
Ignore a member
cfg.Map<Usuario, UsuarioDto>()
.Ignore(dest => dest.SenhaHash);
Custom converter
cfg.AddConverter<string, bool>(value =>
{
if (string.IsNullOrWhiteSpace(value))
return false;
return value.Equals("SIM", StringComparison.OrdinalIgnoreCase)
|| value.Equals("S", StringComparison.OrdinalIgnoreCase)
|| value.Equals("TRUE", StringComparison.OrdinalIgnoreCase)
|| value.Equals("1");
});
Dates
FlexMapper converts strings to DateTime and DateOnly using InvariantCulture, the current culture, and pt-BR.
Accepted example:
Cadastro = "20/06/2026 14:20:38"
Build and test
build.cmd
Or manually:
dotnet restore FlexMapper.slnx
dotnet build FlexMapper.slnx --configuration Release
dotnet test tests/FlexMapper.Tests/FlexMapper.Tests.csproj --configuration Release
Generate packages
pack.cmd
The packages are generated in:
release/
The real project in tests/FlexMapper.Real has a nuget.config pointing to that folder.
Features
- Mapping by convention
- Reverse mapping
- Profiles (mappings organized in classes)
- Public properties and fields
- Custom member mapping
- Ignored members
- Lists and arrays
- Nullable
- Enum
- Guid
- DateTime
- DateOnly
- TimeOnly
- Nested objects
- Custom converters
- ASP.NET Core dependency injection integration
Version history
| Version | Highlights |
|---|---|
| 1.0.4 | Packaging fix to keep FlexMapper.DependencyInjection aligned with the matching FlexMapper package. |
| 1.0.3 | Profiles (FlexMapperProfile) with assembly scanning via AddFlexMapper(assemblies); mapping of public fields in addition to properties. |
| 1.0.2 | Multi-targeting for net8.0, net9.0 and net10.0. |
| 1.0.1 | Fixed Brazilian date-string parsing (e.g. 20/06/2026 14:20:38); version centralized in Directory.Build.props; local NuGet packaging via nuget.config. |
| 1.0.0 | Initial release: convention and reverse mapping, custom members (For), ignored members (Ignore), custom converters, lists/arrays, nested objects, nullable, enum, Guid, DateTime, DateOnly, TimeOnly, and ASP.NET Core DI integration. |
1.0.4
- Fixed package dependency resolution so
FlexMapper.DependencyInjectionis installed with the matchingFlexMapperpackage version.
1.0.3
- Added
FlexMapperProfilebase class to group mappings in dedicated classes. - Added
AddFlexMapper(params Assembly[])andAddFlexMapper(Action<MapperConfiguration>, params Assembly[])overloads that scan assemblies for profiles (AutoMapper-style workflow). - Added public field mapping — both by convention and via
For; read-only (init-only) fields are read but never assigned; properties win on name collisions.
1.0.2
- Added
net9.0andnet10.0target frameworks alongsidenet8.0.
1.0.1
- Fixed conversion of Brazilian-format date strings to
DateTime(e.g.20/06/2026 14:20:38). - Changed version centralized in
Directory.Build.props; local package restore configured throughnuget.config.
1.0.0
- Added convention mapping, reverse mapping, custom member mapping (
For), ignored members (Ignore), custom converters, lists and arrays, nested objects, nullable, enum,Guid,DateTime,DateOnly,TimeOnly, and the ASP.NET Core dependency injection package.
| Product | Versions 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 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 is compatible. 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. |
-
net10.0
- FlexMapper (= 1.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
-
net8.0
- FlexMapper (= 1.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
-
net9.0
- FlexMapper (= 1.0.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.