SparkyTools.AutoMapper
1.3.0
See the version list below for details.
dotnet add package SparkyTools.AutoMapper --version 1.3.0
NuGet\Install-Package SparkyTools.AutoMapper -Version 1.3.0
<PackageReference Include="SparkyTools.AutoMapper" Version="1.3.0" />
paket add SparkyTools.AutoMapper --version 1.3.0
#r "nuget: SparkyTools.AutoMapper, 1.3.0"
// Install SparkyTools.AutoMapper as a Cake Addin #addin nuget:?package=SparkyTools.AutoMapper&version=1.3.0 // Install SparkyTools.AutoMapper as a Cake Tool #tool nuget:?package=SparkyTools.AutoMapper&version=1.3.0
see also:
- SparkyTestHelpers.Mapping: Helpers for testing properties "mapped" from one type to another
- SparkyTestHelpers.AutoMapper: Extends SparkyTestHelpers.Mapping with with additional extension methods specifically for use with AutoMapper.
- the rest of the "Sparky suite" of .NET utilities and test helpers
This package enables an alternate, less verbose syntax for some of the functions that "dot on" to AutoMapper "ForMember" functions, including .MapFrom, .NullSubstitute, .UseValue and .Ignore.
Without SparkyTools.AutoMapper:
Mapper.Initialize(cfg =>
cfg.CreateMap<Foo, Bar>()
.ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.StatusCode))
.ForMember(dest => dest.Comments, opt => opt.NullSubstitute("(none)"))
.ForMember(dest => dest.IsImportant, opt => opt.UseValue(true))
.ForMember(dest => dest.UniqueId, opt => opt.UseValue(Guid.NewGuid()))
.ForMember(dest => dest.Useless, opt => opt.Ignore());
With SparkyTools.AutoMapper:
using SparkyTools.AutoMapper;
Mapper.Initialize(cfg =>
cfg.CreateMap<Foo, Bar>()
.ForMember(dest => dest.Status).MapFrom(src => src.StatusCode)
.ForMember(dest => dest.Comments).NullSubstitute("(none)")
.ForMember(dest => dest.IsImportant).UseValue(true)
.ForMember(dest => dest.UniqueId).UseValue(Guid.NewGuid())
.ForMember(dest => dest.Useless).Ignore();
Ignoring members can be simplified even further.
.ForMember(dest => dest.Useless).Ignore()
can be coded as:
.IgnoreMember(dest => dest.Useless)
...or, to ignore multiple members:
.IgnoringMembers(dest => dest.Useless, dest => dest.Useless2, dest => dest.Useless3)
MappedTo extension methods
The package also contains an extension method that allows you to replace
Bar bar = Mapper.Map<Foo, Bar>(foo); // with static Mapper
Bar bar = mapper.Map<foo, Bar>(foo): // with IMapper instance
with:
Bar bar = foo.MappedTo<Bar>(); // with static Mapper
Bar bar = foo.MappedTo<Bar>(mapper); // with IMapper instance
AutoMapperConfigurationValidity
The Assert methods in this static class wrap Mapper.AssertConfigurationIsValid and IConfigurationProvider.AssertConfigurationIsValid with an exception handler that provides suggestions for dealing with unmapped properties.
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 was computed. 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. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.1 is compatible. netstandard1.2 was computed. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. 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 | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 1.1
- AutoMapper (>= 6.2.2)
- NETStandard.Library (>= 1.6.1)
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 |
---|---|---|
2.0.4 | 700 | 7/27/2019 |
2.0.3 | 581 | 5/12/2019 |
2.0.2 | 589 | 4/11/2019 |
2.0.1 | 717 | 11/22/2018 |
2.0.0 | 687 | 11/22/2018 |
1.5.3 | 588 | 7/27/2019 |
1.5.2 | 603 | 5/12/2019 |
1.5.1 | 562 | 4/13/2019 |
1.5.0 | 720 | 4/11/2019 |
1.4.0 | 723 | 10/31/2018 |
1.3.0 | 913 | 5/12/2018 |
1.2.0 | 1,050 | 4/27/2018 |
1.1.0 | 1,061 | 4/22/2018 |
1.0.1 | 1,011 | 4/12/2018 |
1.0.0 | 859 | 2/16/2018 |
v1.3 - Added AutoMapperConfigurationValidity.Assert methods