MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.29k stars 327 forks source link

Mapster mapping fail between parameters if the first 2 Letters are capital letters ? #577

Closed rizkengin closed 1 year ago

rizkengin commented 1 year ago

Hello Everyone, so I happen to came across a very strange bug, I was trying to map between two records and the mapping won't work even with explicit configuration between the two records. After some debugging I discovered that the mapping fails if the parameters names start with 2 capital letters.

For simplicity here is a snippet if how you can produce this bug

var firstObject = new FirstObject("xxASqwqs");
var secondObject = FirstObject.Adapt<SecondObject>();

public record FirstObject(string QRUrl);
public record SecondObject(string QRUrl);

The secondObject QRUrl variable will contain a null string after mapping, and if you try to to explicitly add a config like this

var config = new TypeAdapterConfig();
        config.NewConfig<FirstObject, SecondObject>()
            .Map(dest => dest.QRUrl, src => src.QRUrl);
        var firstObject = new FirstObject("xxASqwqs");
        var secondObject = firstObject.Adapt<SecondObject>(config); 

It will also fail and the QRUrl will be populated as null, The only thing that worked for me after debugging is to the change the QRUrl paramater to QrUrl and then the mapping worked.

Is this behavior normal ?

andrerav commented 1 year ago

Fixed in #590