Skip to content

Use of the EnableEnumMappingValidation throws NullReferenceException #18

Closed
@trejjam

Description

@trejjam

Mapping configuration

new MapperConfiguration(c =>
{
  c.EnableEnumMappingValidation();
  c.CreateMap<object, object>();
})

Version: 3.0.0

Expected behavior

It validates mapping and does not throw exception

Actual behavior

System.NullReferenceException: Object reference not set to an instance of an object.
   at AutoMapper.Features.Features`1.GetEnumerator()
   at AutoMapper.Extensions.EnumMapping.EnumMapperConfigurationExpressionExtensions.<>c.<EnableEnumMappingValidation>b__0_0(ValidationContext context)
   at AutoMapper.Configuration.ConfigurationValidator.Validate(ValidationContext context)
   at AutoMapper.Configuration.ConfigurationValidator.DryRunTypeMap(IGlobalConfiguration config, HashSet`1 typeMapsChecked, TypePair types, TypeMap typeMap, MemberMap memberMap)
   at AutoMapper.Configuration.ConfigurationValidator.AssertConfigurationIsValid(IGlobalConfiguration config, IEnumerable`1 typeMaps)

Steps to reproduce

new MapperConfiguration(c =>
{
  c.EnableEnumMappingValidation();
  c.CreateMap<object, object>();
}).AssertConfigurationIsValid();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions