Skip to content

Property not Getting Mapped #771

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

Open
IPdotSetAF opened this issue Feb 2, 2025 · 3 comments · May be fixed by #774
Open

Property not Getting Mapped #771

IPdotSetAF opened this issue Feb 2, 2025 · 3 comments · May be fixed by #774
Assignees
Labels

Comments

@IPdotSetAF
Copy link

IPdotSetAF commented Feb 2, 2025

Hey, there.
I encountered an strange mapping bug, i am literally mapping from the same type to itself but an specific nested property gets null (Order.Payment.CVV)

here is the code:

public record CreateOrderRequest(OrderDTO Order);

public record CreateOrderCommand(OrderDTO Order) ;

public record OrderDTO
    (
    Guid Id,
    Guid CustomerId,
    string OrderName,
    AddressDTO ShippingAddress,
    AddressDTO BillingAddress,
    PaymentDTO Payment,
    OrderStatus Status,
    List<OrderItemDTO> OrderItems
    );

public record PaymentDTO
    (
    string CardName,
    string CardNumber,
    string Expiration,
    string CVV,
    int PaymentMethod
    );

public void test(CreateOrderRequest request)
        {
            var tmp = request.Adapt<CreateOrderCommand>();
        }

Mapster Version: 7.4.0
.Net Version: 8

PS. I have debugged the code and the CVV field does have a value before mapping

@DocSvartz DocSvartz added the bug label Feb 2, 2025
@DocSvartz
Copy link

@IPdotSetAF yes, i hope it wil be fix in the next release.
this setting should help you


 TypeAdapterConfig<PaymentDTO, PaymentDTO>
     .NewConfig()
     .NameMatchingStrategy(NameMatchingStrategy.IgnoreCase)


@DocSvartz DocSvartz self-assigned this Feb 2, 2025
@IPdotSetAF
Copy link
Author

Thanks @DocSvartz for the fast reply and recommendation.
I would also like to start contributing in the project. if there was any chance feel free to mention me.

@DocSvartz
Copy link

DocSvartz commented Feb 10, 2025

linked #746

@andrerav @stagep
This is because the Constructor Parameter Names are forced to PascalCase.
Then Name Matching Strategy is no longer able Match Parametr and Property from source , since the name does not match.

I found a solution, it will be based on #769
Since it requires an explicit definition that mapping of constructor parameters is performed.

But perhaps there is a simpler solution)

@DocSvartz DocSvartz linked a pull request Feb 11, 2025 that will close this issue
@DocSvartz DocSvartz linked a pull request Feb 11, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants