Message of 'AutoMapperMappingException' should contain concrete/runtime type name #3657
-
If I map but missing a configuration in profile then the AutoMapperMappingException is thrown. The output contains the name of source and target type which is a good thing. But the type name is only the build-time type not the runtime one. See my example below: public interface ITableModel { }
public interface IDtoModel { }
public class ConcreteTableModel : ITableModel { }
public class ConcreteDtoModel : IDtoModel { }
public class MyProfile : Profile { }
class Program
{
static void Main(string[] args)
{
var configuration = new MapperConfiguration(cfg => new MyProfile());
var mapper = new AutoMapper.Mapper(configuration);
// The error message shows the declared type (left side).
// I propose to show the runtime type (right side).
ITableModel concreteTableModel = new ConcreteTableModel();
IDtoModel concreteDtoModel = new ConcreteDtoModel();
try
{
mapper.Map(concreteTableModel, concreteDtoModel);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
} Current Message of 'AutoMapperMappingException'
Proposed Message of 'AutoMapperMappingException'
Why I propose that? Because If I miss a mapping then I miss a concrete mapping. We do not map abstractions. If I'm missing something then maybee the error message can contain both. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Try the MyGet build. |
Beta Was this translation helpful? Give feedback.
Try the MyGet build.