From 4414d90ab09d192d65a1408571641f46fa8b6825 Mon Sep 17 00:00:00 2001 From: DocSvartz Date: Thu, 26 Mar 2026 05:59:35 +0500 Subject: [PATCH 1/4] Bump version to 10.0.6 --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 3efb4b24..199c084e 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ false - 10.0.5 + 10.0.6 netstandard2.0;net10.0;net9.0;net8.0 netstandard2.0;net10.0;net9.0;net8.0 net10.0;net9.0;net8.0 From 7d452707110376dab87f51ead2e3fc307eaffb10 Mon Sep 17 00:00:00 2001 From: DocSvartz Date: Fri, 27 Mar 2026 09:28:38 +0500 Subject: [PATCH 2/4] fix(test): fix RequiredProperty test --- src/Mapster.Tests/WhenMappingRecordRegression.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Mapster.Tests/WhenMappingRecordRegression.cs b/src/Mapster.Tests/WhenMappingRecordRegression.cs index c1bb9dad..85d291e8 100644 --- a/src/Mapster.Tests/WhenMappingRecordRegression.cs +++ b/src/Mapster.Tests/WhenMappingRecordRegression.cs @@ -449,11 +449,7 @@ public void RequiredProperty() { var source = new Person553 { FirstMidName = "John", LastName = "Dow" }; var destination = new Person554 { ID = 245, FirstMidName = "Mary", LastName = "Dow" }; - - TypeAdapterConfig.NewConfig() - //.Map(dest => dest.ID, source => 0) - .Ignore(x => x.ID); - + var s = source.BuildAdapter().CreateMapToTargetExpression(); var result = source.Adapt(destination); From 29b8b82aa2dc9839af91240e895f58d6c8ef5b21 Mon Sep 17 00:00:00 2001 From: DocSvartz Date: Fri, 27 Mar 2026 09:51:40 +0500 Subject: [PATCH 3/4] fix: Regression in v10 - Forced Update of Required Property #899 --- src/Mapster.Core/Enums/MapType.cs | 1 + src/Mapster/Adapters/BaseAdapter.cs | 2 +- src/Mapster/Adapters/BaseClassAdapter.cs | 3 ++- src/Mapster/Compile/CompileArgument.cs | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Mapster.Core/Enums/MapType.cs b/src/Mapster.Core/Enums/MapType.cs index 420cc812..fa8762f1 100644 --- a/src/Mapster.Core/Enums/MapType.cs +++ b/src/Mapster.Core/Enums/MapType.cs @@ -8,5 +8,6 @@ public enum MapType Map = 1, MapToTarget = 2, Projection = 4, + ApplyNullPropagation = 8, } } \ No newline at end of file diff --git a/src/Mapster/Adapters/BaseAdapter.cs b/src/Mapster/Adapters/BaseAdapter.cs index b519a334..65c9d0f9 100644 --- a/src/Mapster/Adapters/BaseAdapter.cs +++ b/src/Mapster/Adapters/BaseAdapter.cs @@ -220,7 +220,7 @@ protected Expression CreateBlockExpressionBody(Expression source, Expression? de .Any(y => y.GetType().FullName == "System.Runtime.CompilerServices.RequiredMemberAttribute")); if (requiremembers.Count() != 0) - set = CreateInlineExpression(source, arg, true); + set = CreateInlineExpression(source, arg.CloneWith(MapType.ApplyNullPropagation), true); else set = CreateInstantiationExpression(transformedSource, destination, arg); diff --git a/src/Mapster/Adapters/BaseClassAdapter.cs b/src/Mapster/Adapters/BaseClassAdapter.cs index e46c287a..f092c3ab 100644 --- a/src/Mapster/Adapters/BaseClassAdapter.cs +++ b/src/Mapster/Adapters/BaseClassAdapter.cs @@ -113,7 +113,8 @@ select fn(src, destinationMember, arg)) Destination = (ParameterExpression?)destination, UseDestinationValue = IsCanUsingDestinationValue(arg, destinationMember), }; - if(getter == null && !arg.DestinationType.IsRecordType() + if(arg.MapType == MapType.ApplyNullPropagation && + getter == null && !arg.DestinationType.IsRecordType() && destinationMember.Info is PropertyInfo propinfo) { if (propinfo.GetCustomAttributes() diff --git a/src/Mapster/Compile/CompileArgument.cs b/src/Mapster/Compile/CompileArgument.cs index d324661d..c2825b31 100644 --- a/src/Mapster/Compile/CompileArgument.cs +++ b/src/Mapster/Compile/CompileArgument.cs @@ -48,5 +48,20 @@ select split _fetchConstructUsing = true; return _constructUsing; } + + public CompileArgument CloneWith(MapType? mapType = null) + { + var config = new TypeAdapterConfig(); + config.Default.EnableNonPublicMembers(true); + config.Default.ShallowCopyForSameType(true); + + var str = this.BuildAdapter(config).CreateMapExpression(); + CompileArgument result = this.Adapt(config); + + if (mapType != null) + result.MapType = mapType.Value; + + return result; + } } } From a8e1cb6f9c4dc606176a04137c95d672655eaedd Mon Sep 17 00:00:00 2001 From: DocSvartz Date: Sun, 29 Mar 2026 10:41:29 +0500 Subject: [PATCH 4/4] fix: drop mapping using --- src/Mapster/Compile/CompileArgument.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Mapster/Compile/CompileArgument.cs b/src/Mapster/Compile/CompileArgument.cs index c2825b31..827c1d13 100644 --- a/src/Mapster/Compile/CompileArgument.cs +++ b/src/Mapster/Compile/CompileArgument.cs @@ -51,16 +51,25 @@ select split public CompileArgument CloneWith(MapType? mapType = null) { - var config = new TypeAdapterConfig(); - config.Default.EnableNonPublicMembers(true); - config.Default.ShallowCopyForSameType(true); - - var str = this.BuildAdapter(config).CreateMapExpression(); - CompileArgument result = this.Adapt(config); + var result = new CompileArgument() + { + SourceType = this.SourceType, + DestinationType = this.DestinationType, + MapType = this.MapType, + ExplicitMapping = this.ExplicitMapping, + Settings = this.Settings, + Context = this.Context, + UseDestinationValue = this.UseDestinationValue, + ConstructorMapping = this.ConstructorMapping, + _srcNames = this._srcNames, + _destNames = this._destNames, + _fetchConstructUsing = this._fetchConstructUsing, + _constructUsing = this._constructUsing + }; if (mapType != null) - result.MapType = mapType.Value; - + result.MapType = mapType.Value; + return result; } }