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

Mapping fails when a record property is Ignored #456

Open
amantinband opened this issue Jul 22, 2022 · 6 comments
Open

Mapping fails when a record property is Ignored #456

amantinband opened this issue Jul 22, 2022 · 6 comments

Comments

@amantinband
Copy link

The following will throw an exception:

public record User(string Name);
public record UserDto(string Name);
TypeAdapterConfig<User, UserDto>.NewConfig()
    .Ignore(dest => dest.Name);

var user = new User("Amichai");
var userDto = user.Adapt<UserDto>(); // <-- throws Mapster.CompileException: Error while compiling, with inner exception: System.ArgumentException: Incorrect number of arguments for constructor

Is this by design? Didn't see this documented

@skuirrels
Copy link

This needs to be solved. It precludes the use of Mapster.

@stagep
Copy link

stagep commented Jan 7, 2025

In order to identify issues that are still active, we are closing issues that we believe are either resolved or are dormant. If your issue is still active then please reopen. Thanks.

@stagep stagep closed this as completed Jan 7, 2025
@DocSvartz DocSvartz self-assigned this Jan 15, 2025
@DocSvartz DocSvartz reopened this Jan 15, 2025
@DocSvartz
Copy link

DocSvartz commented Jan 15, 2025

@amantinband @andrerav Yes, it not supported in origin design.

I hope add this :)

But for the current example this doesn't make sense. instance of UserDto in this case it cannot be created.

I don't think your goal is to always get null or String.Empty in this property ?

@DocSvartz
Copy link

linked #707
@andrerav ignoring works too well :)
To create a construct, data about the presence of such a variable is not received at all.
fix is almost complete :)

@DocSvartz
Copy link

linked #723

@DocSvartz
Copy link

linked #458

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

No branches or pull requests

4 participants