The Profile.AllowNullCollections property seems to be being missed in 5.0.2 and beyond. Moving the code out of the Configure method into a constructor results in the same behavior.
class Program
{
static void Main(string[] args)
{
var mapper = new MapperConfiguration(cfg =>
{
cfg.AddProfile(new TestMappingProfile());
}).CreateMapper();
var isNull = mapper.Map<Source, Destination>(new Source()).Ints == null;
// "true" in 4.2.1
// "false" in 5.0.2+
}
}
class TestMappingProfile : Profile
{
protected override void Configure()
{
AllowNullCollections = true;
CreateMap<Source, Destination>();
}
}
class Source
{
public IEnumerable<int> Ints { get; set; }
}
class Destination
{
public IEnumerable<int> Ints { get; set; }
}
@jbogard What about only a global AllowNullCollections?
There already is one, I've made MapperConfigurationExpression inherit from Profile. We might just not enforce it that way.
How would you propose one go about allowing null collections for all types in a specific Profile, if the property is removed?
Is there a status update on this issue? I was able to set the global property, and this worked, but that is of course applied to all profiles. For now, I have rolled back to 4.2.1.0.
Are there any updates here? @cjrogala's solution doesn't seem suitable in the long run.
Yeah, I'm working on a solution right now. Profiles are the last thing to get "fixed" from the configuration overhaul of 5.x
Great. When do you expect the changes to be available?
Try the MyGet build.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.