Skip to content

AllowNullCollections=false not honored for ICollection #2145

Description

@tboby

Source/destination types

publicclassFoo{publicList<int>fooList=null;}publicclassFooDB{publicICollection<int>fooList=null;}

Mapping configuration

publicclassExplicitGlobalDefaultProfile:Profile{publicExplicitGlobalDefaultProfile(){AllowNullCollections=false;AllowNullDestinationValues=true;CreateMap<Foo,FooDB>();}}publicclassImplicitGlobalDefaultProfile:Profile{publicImplicitGlobalDefaultProfile(){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

varexplicitGlobalConfig=newMapperConfiguration(cfg =>{cfg.AddProfile<ExplicitGlobalDefaultProfile>();});varimplicitGlobalConfig=newMapperConfiguration(cfg =>{cfg.AddProfile<ImplicitGlobalDefaultProfile>();});varexplicitMapper=explicitGlobalConfig.CreateMapper();varimplicitMapper=implicitGlobalConfig.CreateMapper();varfoo=newFoo();varexplicitFooDB=explicitMapper.Map<Foo,FooDB>(foo);varimplicitFooDB=implicitMapper.Map<Foo,FooDB>(foo);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions