MapsterMapper / Mapster

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

Attribute based CodeGeneration RequireDestinationMemberSource propagate to dependents #541

Open EniacMlezi opened 1 year ago

EniacMlezi commented 1 year ago

I Expected RequireDestinationMemberSource to propagate to dependent child classes.

[AdaptFrom(typeof(A), RequireDestinationMemberSource = true), GenerateMapper]
public class ADto
{
    public string NonExistentInSource { get; set; }   /* Failure */
    public BDto TheB { get; set; }
}

public class BDto
{
    public string NonExistentInSource { get; set; } /* No Failure */
    public string? City { get; set; }
}

When I use code generate to create the Mapper, it fails on ADto.NonExistentInSource. But when I remove A.NonExistentInSource, it does not fail on BDto.NonExistentInSource. Is this the correct behavior? and if so, how do I work around it?

EniacMlezi commented 1 year ago

https://github.com/MapsterMapper/Mapster/issues/528 would also solve the problem in my case.