You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mapster mapping fail between parameters if the first 2 Letters are capital letters ? #577
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.
Activity
andrerav commentedon May 29, 2023
Fixed in #590