Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source types are not validated against destination types for collections during compile with RequireExplicitMapping set to true #269

Closed
jonathantorley opened this issue Sep 11, 2020 · 0 comments

Comments

@jonathantorley
Copy link

jonathantorley commented Sep 11, 2020

Given the following classes:

class Source
{
    public List<SourceChild> Child { get; set; }
}

class SourceChild
{
    public string Id { get; set; }
}

class Destination
{
    public List<DestinationChild> Child { get; set; }
}

class DestinationChild
{
    public string Id { get; set; }
}

I'd expect the compile to fail with the below configuration, but it passes; it fails when it actually tries to perform the work:

TypeAdapterConfig.GlobalSettings.RequireExplicitMapping = true;
var config = TypeAdapterConfig<Source, Destination>.NewConfig();

config.Compile(); // Should fail here

var source = new Source { Child = new List<SourceChild> { new SourceChild { Id = "MyId" } } };
_ = source.Adapt<Destination>(); // Actually fails here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant