A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/MapsterMapper/Mapster/issues/269 below:

Source types are not validated against destination types for collections during compile with RequireExplicitMapping set to true · Issue #269 · MapsterMapper/Mapster · GitHub

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4