MapsterMapper / Mapster

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

Mapping fails when a record property is `Ignore`d #456

Open amantinband opened 2 years ago

amantinband commented 2 years ago

The following will throw an exception:

public record User(string Name);
public record UserDto(string Name);
TypeAdapterConfig<User, UserDto>.NewConfig()
    .Ignore(dest => dest.Name);

var user = new User("Amichai");
var userDto = user.Adapt<UserDto>(); // <-- throws Mapster.CompileException: Error while compiling, with inner exception: System.ArgumentException: Incorrect number of arguments for constructor

Is this by design? Didn't see this documented

skuirrels commented 1 year ago

This needs to be solved. It precludes the use of Mapster.