com.wiwish.library.MapSharp
0.9.0
dotnet add package com.wiwish.library.MapSharp --version 0.9.0
NuGet\Install-Package com.wiwish.library.MapSharp -Version 0.9.0
<PackageReference Include="com.wiwish.library.MapSharp" Version="0.9.0" />
<PackageVersion Include="com.wiwish.library.MapSharp" Version="0.9.0" />
<PackageReference Include="com.wiwish.library.MapSharp" />
paket add com.wiwish.library.MapSharp --version 0.9.0
#r "nuget: com.wiwish.library.MapSharp, 0.9.0"
#:package com.wiwish.library.MapSharp@0.9.0
#addin nuget:?package=com.wiwish.library.MapSharp&version=0.9.0
#tool nuget:?package=com.wiwish.library.MapSharp&version=0.9.0
MapSharp
MapSharp is a lightweight, high-performance .NET object-to-object mapper that keeps mapping configuration explicit, readable, and easy to maintain.
Current package version: 0.8.0
Quick start
var configuration = new MapperConfiguration(cfg =>
{
cfg.CreateMap<User, UserDto>()
.ForMember(d => d.DisplayName, opt => opt.MapFrom(s => s.Name));
});
configuration.AssertConfigurationIsValid();
var mapper = configuration.CreateMapper();
var dto = mapper.Map<UserDto>(new User { Name = "Alice" });
Current feature coverage
Version 0.8.0 emphasizes faster steady-state runtime mapping while preserving the existing explicit configuration model and feature set.
- Mapping configuration:
CreateMap<TSource, TDestination>()ForMember(...).MapFrom(expression)ForMember(...).MapFrom<TResolver>()ForMember(...).MapFromWithContext<TResolver>()ForMember(...).Condition(...)(runtime mapping only)Ignore(...)for destination properties, including read-only properties when you want them excluded from validation/mapping rulesForSourceMember(..., opt => opt.DoNotValidate())when source-member validation is enabledConvertUsing<TConverter>()BeforeMap<TAction>()/AfterMap<TAction>()ReverseMap()basics
- Runtime mapping:
- Typed and object-based
Map(...)overloads - Map-into-existing-instance overload:
Map<TSource, TDestination>(source, destination)- Typed options overload:
Map<TSource, TDestination>(source, Action<IMappingOperationOptions<TSource, TDestination>> options) - Automatic proxy-aware source type fallback (exact runtime source type first, then configured base types/interfaces)
- Typed options overload:
- Configuration access from mapper via
IMapper.ConfigurationProvider - Nested object mapping
- Collection mapping (arrays and common list/enumerable destinations)
- Primitive and enum conversion support
- Per-call mapping items via
IMappingOperationOptions.Items - Typed per-call option helpers via
Set<T>(...)andTryGet<T>(...)
- Typed and object-based
- Projection:
IQueryableprojection viaProjectTo- Supports convention mapping,
MapFrom(expression), andIgnore(...)
- Extensibility hooks:
ITypeConverter<TSource, TDestination>IValueResolver<TSource, TDestination, TDestMember>IValueResolverWithContext<TSource, TDestination, TDestMember>IMappingAction<TSource, TDestination>
- Configuration validation via
AssertConfigurationIsValid()- Optional relaxed validation via
AllowUnmappedDestinationMembers() - Optional strict source-member validation via
ValidateSourceMembers() - Source members consumed through custom resolvers cannot be inferred statically; mark them with
ForSourceMember(..., opt => opt.DoNotValidate())when needed
- Optional relaxed validation via
- DI integration package:
MapSharp.Extensions.Microsoft.DependencyInjectionConstructServicesUsing(Func<Type, object>)ConstructServicesUsing(IServiceProvider)
Known limitations
- Configuration API is intentionally smaller than other similar tools.
ProjectTodoes not supportConvertUsing, resolver-based members,BeforeMap/AfterMap, or conditional member mapping.- Advanced member options and naming-convention customization are not yet complete.
- Source-member validation only understands convention-based mappings and
MapFrom(expression); resolver-based source usage must be marked explicitly withForSourceMember(..., opt => opt.DoNotValidate()).
Release documentation
Benchmark baseline
A simple benchmark harness is included in benchmarks/MapSharp.Benchmarks.
It uses BenchmarkDotNet and writes reports to BenchmarkDotNet.Artifacts.
Recent benchmark work for 0.8.0 focused on improving warmed mapping throughput and reducing runtime overhead in common mapping scenarios.
Run it with:
dotnet run --project benchmarks/MapSharp.Benchmarks/MapSharp.Benchmarks.csproj -c Release
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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 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 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. |
| .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 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. 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. |
-
.NETStandard 2.0
- No dependencies.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on com.wiwish.library.MapSharp:
| Package | Downloads |
|---|---|
|
com.wiwish.library.MapSharp.Extensions.Microsoft.DependencyInjection
Dependency injection integration for MapSharp with streamlined MapperConfiguration and IMapper registration for ASP.NET Core and .NET applications, plus on-demand construction of resolvers, converters, and mapping actions through ActivatorUtilities. |
GitHub repositories
This package is not used by any popular GitHub repositories.
0.9.0: Added optional source-member validation via ValidateSourceMembers(), ForSourceMember(..., opt => opt.DoNotValidate()) for explicit source opt-outs, support for Ignore(...) on read-only destination properties, expanded regression coverage, and refreshed documentation for the new validation and DI guidance.