From 965fc2336ebeb0daa0c596301179943af74b36ab Mon Sep 17 00:00:00 2001 From: DocSvartz Date: Thu, 10 Jul 2025 07:31:20 +0500 Subject: [PATCH] fix class SetValueByReflection --- src/Mapster/Adapters/ClassAdapter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mapster/Adapters/ClassAdapter.cs b/src/Mapster/Adapters/ClassAdapter.cs index 407c5a5..6d12e57 100644 --- a/src/Mapster/Adapters/ClassAdapter.cs +++ b/src/Mapster/Adapters/ClassAdapter.cs @@ -181,9 +181,9 @@ protected override Expression CreateBlockExpression(Expression source, Expressio private static Expression SetValueByReflection(MemberMapping member, MemberExpression adapt) { var typeofExpression = Expression.Constant(member.Destination!.Type); - var getPropertyMethod = typeof(Type).GetMethod("GetProperty", new[] { typeof(string) })!; + var getPropertyMethod = typeof(Type).GetMethod("GetProperty", new[] { typeof(string), typeof(Type) })!; var getPropertyExpression = Expression.Call(typeofExpression, getPropertyMethod, - Expression.Constant(member.DestinationMember.Name, member.DestinationMember.Type)); + new[] { Expression.Constant(member.DestinationMember.Name), Expression.Constant(member.DestinationMember.Type) }); var setValueMethod = typeof(PropertyInfo).GetMethod("SetValue", new[] { typeof(object), typeof(object) })!; var memberAsObject = adapt.To(typeof(object));