AllowNullCollections has no effect when a profile is used
See original GitHub issueWhen a mapper configuration is set through a profile, the AllowNullCollections
setting has no effect. The following pseudo test fails:
public class Source
{
public System.Collections.Generic.IList<string> Collection { get; set; }
}
public class Destination
{
public System.Collections.Generic.IList<string> Collection { get; set; }
}
public class TestProfile: AutoMapper.Profile
{
protected override void Configure()
{
CreateMap<Source, Destination>();
}
}
[Fact]
public void NullCollection()
{
var mapper = new MapperConfiguration(cfg => {
cfg.AllowNullCollections=true;
cfg.AddProfile<TestProfile>();
}).CreateMapper();
var source = new Source();
Destination destination = mapper.Map<Destination>(source);
Assert.Null(destination.Collection);
}
When configured directly with CreateMap
, the setting works as expected.
AutoMapper 4.2.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Automapper: setting AllowNullCollections on the profile
There is a property on the Profile class called AllowNullCollections. It is not affecting the mapping. If I set cfg.AllowNullCollections to True ...
Read more >AutoMapper Documentation
A convention-based object-object mapper. AutoMapper uses a fluent configuration API to define an object-object mapping strategy.
Read more >Lists and Arrays
This behavior can be changed by setting the AllowNullCollections property to true when configuring the mapper. var configuration = new MapperConfiguration(cfg => ...
Read more >C# (CSharp) ConfigurationStore Examples
C# (CSharp) ConfigurationStore - 60 examples found. These are the top rated real world C# (CSharp) examples of ConfigurationStore extracted from open source ......
Read more >How to disable selection some item in a listview windows ...
Start with a copy of the list box item style then add a Setter to change the IsHitTestVisible property. For example:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am seeing this issue, possibly a regression, in version 5.1.1.
The following unit test fails
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.