-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to Ignore() processing and Fix MapToTarget behavior for RecordTypes #769
base: development
Are you sure you want to change the base?
Conversation
using ignore ctor param and test MapToTarget and not match value
{ | ||
var find = arg.DestinationType.GetFieldsAndProperties(arg.Settings.EnableNonPublicMembers.GetValueOrDefault()).ToArray() | ||
.Where(x => x.Name == destinationMember.Name).FirstOrDefault(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified on refactoring. Field information is already in the processing pipeline
var find = arg.DestinationType.GetFieldsAndProperties(arg.Settings.EnableNonPublicMembers.GetValueOrDefault()).ToArray() | ||
.Where(x => x.Name == member.DestinationMember.Name).FirstOrDefault(); | ||
|
||
if (find != null && destination != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is also possible, but you need to get a list of Destination fields. Not constructor parameters.
|
||
if (arg.MapType == MapType.MapToTarget && arg.DestinationType.IsRecordType()) | ||
{ | ||
var find = arg.DestinationType.GetFieldsAndProperties(arg.Settings.EnableNonPublicMembers.GetValueOrDefault()).ToArray() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is also possible, but you need to get a list of Destination fields. Not constructor parameters.
var contructorMembers = newInstance.Arguments.OfType<MemberExpression>().Select(me => me.Member).ToArray(); | ||
var contructorMembers = arg.DestinationType.GetConstructors() | ||
.OrderByDescending(it => it.GetParameters().Length).FirstOrDefault() | ||
.GetParameters().ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified. information is already transferred to installExpr
private List<MemberBinding> RecordIngnoredWithoutConditonRestore(Expression? destination, CompileArgument arg, List<ParameterInfo> contructorMembers) | ||
{ | ||
var members = arg.DestinationType | ||
.GetFieldsAndProperties(arg.Settings.EnableNonPublicMembers.GetValueOrDefault()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not possible to obtain such a data configuration in the current processing pipeline.
But it is possible to simplify it by obtaining it from a modified version of the install expression in the current solution.
@andrerav I left the comments for myself. So I wouldn't forget ) |
Fix Issue #456 #707 #723
#456 When explicitly set to ignore():
Instance of a class can be created with default values for parameters.
Explicitly set to ignore() not mark param as not matched when config RequireDestinationMemberSource = true,
#707 #723 RecordTypes and Generated Type to Interface received support Ignore() from Ctor parameters
Fix MapToTarget behavior for RecordTypes (Include using Ignore() )
before from
after
equal behavior when modified using with