-
Notifications
You must be signed in to change notification settings - Fork 392
Closed
Description
When BeforeMapping()/AfterMapping() are defined for base and derived class mapping then they are executed in incorrect order: base class BeforeMapping()/AfterMapping() is executed after such method from derived class
Sample code (based on After_Mapping() UT):
Types def
public class SimplePocoBase
{
public string Name { get; set; }
}
public class SimplePoco : SimplePocoBase
{
public Guid Id { get; set; }
}
public class SimpleDto
{
public Guid Id { get; set; }
public string Name { get; set; }
}Mapping def
TypeAdapterConfig<SimplePocoBase, SimpleDto>.NewConfig()
.AfterMapping((src, dest) => dest.Name = src.Name + "BASE");
TypeAdapterConfig<SimplePoco, SimpleDto>.NewConfig()
.AfterMapping((src, dest) => dest.Name = src.Name + "SRC");
var poco = new SimplePoco
{
Id = Guid.NewGuid(),
Name = "test",
};
var result = TypeAdapter.Adapt<SimpleDto>(poco);Expected result: result.Name should be testSRC
Actual result: result.Name is testBASE
Code for testing BeforeMapping() is similar
Metadata
Metadata
Assignees
Labels
No labels