Skip to content

Enum Mapping Validation is not working #33

@mpodonyi

Description

@mpodonyi

In the following code i expected to come back with an Validation Error that "Utc" is not mapped.
But no Error is thrown.

#!/usr/bin/env dotnet-script
#r "nuget: AutoMapper, 13.0.1"
#r "nuget: AutoMapper.Extensions.EnumMapping, 3.2.0"
#nullable enable

using AutoMapper;
using System.Globalization;
using System.IO.Compression;
using System.Text.Json;
using AutoMapper.Extensions.EnumMapping;

enum TimeZoneSource
{
    Local,
    Utc,
    Custom
}

enum TimeZoneTarget
{
    Local,

    Custom
}


var AutoMapperConfiguration = new MapperConfiguration(cfg =>
       {
           cfg.EnableEnumMappingValidation();
           cfg.CreateMap<TimeZoneSource, TimeZoneTarget>(MemberList.Source)
                           .ConvertUsingEnumMapping(opt =>
                           {
                               opt.MapValue(TimeZoneSource.Local, TimeZoneTarget.Local);

                               opt.MapValue(TimeZoneSource.Custom, TimeZoneTarget.Custom);
                           });
});

AutoMapperConfiguration.AssertConfigurationIsValid();

Console.WriteLine("----End----");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions