You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ReverseMap creates invalid configuration when Source and Destination support different int values #27
Destination.OnlyInDestination will map to Source.OnlyInSource because of the ReverseMap()
Actual behavior
AssertConfigurationIsValid() throws
Trying to map Destination to Source throws
In both cases the error is:
AutoMapper.AutoMapperMappingException : Value OnlyInDestination of type AutoMapper.Extensions.EnumMapping.Tests.ReverseCustomEnumValueMappingByValue+OnlyInSourceValueIsMappedToOnlyInDestiationValue+Destination not supported
Steps to reproduce
// This slightly altered test from the project's test suite will failpublicclassOnlyInSourceValueIsMappedToOnlyInDestinationValue:AutoMapperSpecBase{readonlyList<Source>_results=newList<Source>();publicenumSource{Default,OnlyInSource=3}publicenumDestination{Default,OnlyInDestination=4}protectedoverrideMapperConfigurationConfiguration{get;}=newMapperConfiguration(cfg =>{cfg.EnableEnumMappingValidation();cfg.CreateMap<Source,Destination>().ConvertUsingEnumMapping(opt =>opt.MapByValue().MapValue(Source.OnlyInSource,Destination.OnlyInDestination)).ReverseMap();});protectedoverridevoidBecause_of(){_results.Add(Mapper.Map<Destination,Source>(Destination.Default));_results.Add(Mapper.Map<Destination,Source>(Destination.OnlyInDestination));}[Fact]publicvoidShould_map_using_custom_map(){_results[0].ShouldBe(Source.Default);_results[1].ShouldBe(Source.OnlyInSource);}}
Activity
lbargaoanu commentedon Dec 19, 2024
A PR is welcome. Features might be useful here.