-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Source/destination types
public class Foo
{
public List<int> fooList = null;
}
public class FooDB
{
public ICollection<int> fooList = null;
}
Mapping configuration
public class ExplicitGlobalDefaultProfile : Profile
{
public ExplicitGlobalDefaultProfile()
{
AllowNullCollections = false;
AllowNullDestinationValues = true;
CreateMap<Foo, FooDB>();
}
}
public class ImplicitGlobalDefaultProfile : Profile {
public ImplicitGlobalDefaultProfile()
{
CreateMap<Foo, FooDB>();
}
}
Version: x.y.z
6.1.0
Expected behavior
I expect fooDB.fooList to be an empty collection of some kind.
In 6.0.2 (and 5.2.0) this is the actual behaviour.
Actual behavior
fooList is null.
Steps to reproduce
var explicitGlobalConfig = new MapperConfiguration(cfg => { cfg.AddProfile<ExplicitGlobalDefaultProfile>(); });
var implicitGlobalConfig = new MapperConfiguration(cfg => { cfg.AddProfile<ImplicitGlobalDefaultProfile>(); });
var explicitMapper = explicitGlobalConfig.CreateMapper();
var implicitMapper = implicitGlobalConfig.CreateMapper();
var foo = new Foo();
var explicitFooDB = explicitMapper.Map<Foo, FooDB>(foo);
var implicitFooDB = implicitMapper.Map<Foo, FooDB>(foo);
wufe