Skip to content
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

Open
wants to merge 19 commits into
base: development
Choose a base branch
from

Conversation

DocSvartz
Copy link

@DocSvartz DocSvartz commented Jan 25, 2025

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

record TestRecord()
{
    public int X { set; get; }
}
record TestRecordY() 
{
    public int X { set; get; }
    public int Y { set; get; }
}

var source = new TestRecord() { X= 200};
var dest = new TestRecordY() {X = 100, Y= 500}

var adapt = source.Adapt(dest)  // always adapt == { X=200, Y=0}

after

var adapt = source.Adapt(dest)  // adapt == { X=200, Y=500}  Correct MapTotarget

equal behavior when modified using with

var adapt = dest with {X=source.X};

add Support from RecordType

  • IgnoreNullValues()
  • UseDestinationValue
  • UseDestination value from Primitive type (and RecordType) AutoProperty

@DocSvartz DocSvartz marked this pull request as ready for review January 25, 2025 11:43
@DocSvartz DocSvartz requested a review from andrerav January 25, 2025 11:43
@DocSvartz

This comment was marked as resolved.

@DocSvartz

This comment was marked as resolved.

DocSvartz and others added 5 commits February 2, 2025 08:24
IgnoreNullValue
UseDestinationValue
Use Destination value from Primitive type AutoProperty
IgnoreNullValue
UseDestinationValue
Use Destination value from Primitive type AutoProperty
@DocSvartz
Copy link
Author

@andrerav It turned out to be much more difficult than I thought.
But it looks like I managed to add almost all features from Classes to Record :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant