When invoking AddCollectionMappers() twice all collection mapping operations throw a StackoverflowException.
public class UnitTest1
{
public class DTO { }
public class Model { }
[Fact]
public void Test1()
{
var config = new MapperConfiguration(c =>
{
c.AddCollectionMappers();
c.AddCollectionMappers();
c.CreateMap<Model, DTO>();
});
var mapper = new Mapper(config);
mapper.Map<ICollection<DTO>>(new List<Model>() { new Model() });
}
}
It would be really nice ifAddCollectionMappers() checks if the mapper is already registered. This is extremely useful when the application has many independent invocations of services.AddAutoMapper() in completely independent modules.
When invoking
AddCollectionMappers()
twice all collection mapping operations throw aStackoverflowException
.It would be really nice if
AddCollectionMappers()
checks if the mapper is already registered. This is extremely useful when the application has many independent invocations ofservices.AddAutoMapper()
in completely independent modules.