无法使用 AutoMapper 映射到空值

Can't use AutoMapper to map to null value

public class TestNullableString {
    public string? Test;

    public TestNullableString(string? test) {
        Test = test;
    }
}

public class TestNonNullableString {
    public string Test;
}

public class TestProfile : Profile
{
    public TestProfile() {
        CreateMap<TestNonNullableString, TestNullableString>
             .ForMember(dest => dest.Test, opt => {
                 opt.AllowNull();
                 opt.MapFrom(src => src.Test == "" ? null : src.Test);
              });
    }
}

如果我尝试从 NonNullableString 映射到 NullableString,它在映射时仍然给我空字符串。它不会给我一个空值,即使 NonNullableString 是“”。我做错了什么?

我正在使用 AutoMapper 9.0.0。

PS。我也试过将 AllowNullDestinationValues 设置为 true 但没有成功。

CreateMap<TestNonNullableString, TestNullableString>()
            .ForMember(dest => dest.Test,
                opt => { opt.MapFrom(src => string.IsNullOrWhiteSpace(src.Test) ? null : src.Test); })
            .ConstructUsing(x => new TestNullableString(string.IsNullOrWhiteSpace(x.Test) ? null: x.Test ));