Mapster icon indicating copy to clipboard operation
Mapster copied to clipboard

Attribute based CodeGeneration RequireDestinationMemberSource propagate to dependents

Open EniacMlezi opened this issue 2 years ago • 1 comments

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 avatar Feb 13 '23 20:02 EniacMlezi

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

EniacMlezi avatar Feb 13 '23 22:02 EniacMlezi