Releases: MapsterMapper/Mapster
Release list
v10.1.0-pre01
New features
DefaultValue() - Custom default value for Destination type
config.ForDestinationType<int>()
.DefaultValue(x => 42);
int? src = null;
var result = src.Adapt<int>(config); // result == 42
var result = src.Adapt<int>(); // By default result will be equal to 0 - the default value for type Int
MapUsing() - Map Property/Field with using Override type mapping settings
Unlike Map(), which is designed to specify an alternative source for a Property/Field, using MapUsing() you can set unique settings for mapping types for the specified Property/Field:
int? src = null;
var srcData = new NullablIData() { Data = null };
config.
NewConfig<NullablIData, NullablIData>()
.MapUsing(dest => dest.Data, src => src.Data, cfg =>
{
cfg.ReConfigurate()
.DefaultValue(x => 42);
});
var resultData = srcData.Adapt<NullableData>(config); // result.Data == 42
var result = src.Adapt<int?>(config); // result == null
Implementation Features
-
Does not support ExtraSource/Flattening mapping -
.Map(dest => dest, src => src.Props) -
By default Override type mapping settings has will contain all the settings, which are installed in the settings setter pipeline (merge default settings for a type and specific settings.)
// default settings setter
config.Default
config.ForDestinationType<TDestination>()
// specific settings setter
config.ForType<TSource,TDestination>()
config.NewConfig<TSource,TSource>()
2.1) Additional behavior for Override type mapping settings
2.1.1) .ReConfigurate() - Allows you to set or override existing settings.
.MapUsing(dest => dest.Data, src => src.Data, cfg =>
{
cfg.ReConfigurate()
.DefaultValue(x => 42);
});
Note
Some settings cannot be overridden due to the way it is stored.
2.1.2) .SkipAllSettings(true) - create new config like using .NewConfig<TSource,TSource>() In this case, no default settings are applied.
.MapUsing(src => src.Data, dest => dest.Data,
cfg =>
{
cfg.SkipAllSettings(true);
})
2.1.3) .SkipSettings() - Prevents the application of the selected settings
Caution
This setter will be removed in release.
If you need Skip the settings that can be accessed using this method, please leave a comment in this release discussion or submit a PR. Thanks!
.MapUsing(src => src.ArrayData, dest => dest.ListData,
cfg =>
{
cfg.SkipSettings(x=>x.DestinationTransforms);
})
What's Changed
- MapUsing override Type mapping setting by @DocSvartz in #985
- feat: add Custom Default Value for destination Type by @DocSvartz in #1001
Full Changelog: v10.0.11...v10.1.0-pre01
v10.0.11
What's Changed
- fix: fall back to src-relative snk when SolutionDir is unset (#848) by @DocSvartz in #997
- Detecting a type without public constructors as NotSelfCreation by @DocSvartz in #998
- fix #992 and fix #996 by @DocSvartz in #999
Full Changelog: v10.0.10...v10.0.11
v10.0.9
What's Changed
- test: ensure Compile skips open generic mapping rules (#925) by @wyf027 in #965
- fix: ProjectToType nullable navigation to record DTO ctor (#898) by @wyf027 in #971
- fix: support CompileProjection with Include on abstract types (#801) by @wyf027 in #977
- PR #976 + Update + Fix mapping NonNullable ValueType to NullableValueType by @wyf027 and @DocSvartz in #986
- fix: cast inherited MapWith results to derived destinations (#947) by @wyf027 in #976
- fix: drop null check by @DocSvartz in #989
- Fix dependency for Mapster.EFCore TFM Net 8.0 by @DocSvartz in #988
Full Changelog: v10.0.8...v10.0.9
v10.0.8
What's Changed
- feat: add Flattening mapping for all source type by @DocSvartz in #916
- fix IsNotSelfCreation detect by @DocSvartz in #919
- fix race condition when mapping to Record used IgnoreNullValues by @DocSvartz in #923
- fix IgnoreNonMapped member collector #924 by @DocSvartz in #929
- Fix: #928 - not creation abstract destination if souce is null by @DocSvartz in #933
- fix: #927 add skip if destination member is not setter by @DocSvartz in #934
- fix: #925 - Compile config with open generic is not throw exception by @DocSvartz in #935
- feat: #938 - Add DirectAssignmentForSameType() by @DocSvartz in #941
- fix: #925 disable Compile check for open generic configs by @DocSvartz in #942
- Refactoring fix #903 and fix #943 by @DocSvartz in #945
- Actualize benchmark by @Qyperion in #946
- Fix docs: split datatype.md to specific types of topics by @DocSvartz in #914
- [Go to v10.0.8] - update Docs by @DocSvartz in #948
- [Go to v10.0.8] - fix mapster version in benchmark result by @DocSvartz in #949
- feat - add Ignored Remove by @DocSvartz in #956
- fix: #954 fix mapping optional ValueType params by @DocSvartz in #957
- test: cover MapToTarget for types with read-only base properties (#918) by @leno23 in #972
- feat: add CustomResolvers support from Custom Source by @DocSvartz in #981
New Contributors
Full Changelog: 10.0.7...v10.0.8
v10.0.8-pre07
What's Changed
- Actualize benchmark by @Qyperion in #946
- Fix docs: split datatype.md to specific types of topics by @DocSvartz in #914
- [Go to v10.0.8] - update Docs by @DocSvartz in #948
- [Go to v10.0.8] - fix mapster version in benchmark result by @DocSvartz in #949
- feat - add Ignored Remove by @DocSvartz in #956
- fix: #954 fix mapping optional ValueType params by @DocSvartz in #957
- test: cover MapToTarget for types with read-only base properties (#918) by @leno23 in #972
- feat: add CustomResolvers support from Custom Source by @DocSvartz in #981
New Contributors
Full Changelog: v10.0.8-pre06...v10.0.8-pre07
v10.0.8-pre06
What's Changed
- Refactoring fix #903 and fix #943 by @DocSvartz in #945
Full Changelog: v10.0.8-pre05...v10.0.8-pre06
v10.0.8-pre05
What's Changed
- feat: #938 - Add DirectAssignmentForSameType() by @DocSvartz in #941
- fix: #925 disable Compile check for open generic configs by @DocSvartz in #942
Full Changelog: v10.0.8-pre04...v10.0.8-pre05
v10.0.8-pre04
What's Changed
- fix IgnoreNonMapped member collector #924 by @DocSvartz in #929
- Fix: #928 - not creation abstract destination if souce is null by @DocSvartz in #933
- fix: #927 add skip if destination member is not setter by @DocSvartz in #934
- fix: #925 - Compile config with open generic is not throw exception by @DocSvartz in #935
Full Changelog: v10.0.8-pre03...v10.0.8-pre04
v10.0.8-pre03
What's Changed
- fix race condition when mapping to Record used IgnoreNullValues by @DocSvartz in #923
Full Changelog: v10.0.8-pre02...v10.0.8-pre03
v10.0.8-pre02
What's Changed
- fix IsNotSelfCreation detect by @DocSvartz in #919
Full Changelog: v10.0.8-pre01...v10.0.8-pre02