Skip to content

[Err] - Mapper Should only have 1 default Format Provider #5

@Liamth99

Description

@Liamth99

Example of code diagnostic:

[GenerateMapper(options: MappingOptions.AllowIConvertable)]
public partial class MapperClass
{
    [UseFormatProvider]
    private static IFormatProvider Default => CultureInfo.CurrentCulture;

    [UseFormatProvider]
    private static IFormatProvider SecondDefault => CultureInfo.InvariantCulture;

    [UseFormatProvider<int, string>]
    [UseFormatProvider<int, string>]
    private static IFormatProvider IntStringFormat => CultureInfo.InvariantCulture;
}

2 Defaults or 2 with the same type declarations will cause a generator exception, only one should be allowed but the following is ok.

[GenerateMapper(options: MappingOptions.AllowIConvertable)]
public partial class MapperClass
{
    [UseFormatProvider]
    private static IFormatProvider Default => CultureInfo.CurrentCulture;

    [UseFormatProvider<int, string>]
    [UseFormatProvider<string, int>]
    private static IFormatProvider IntStringFormat => CultureInfo.InvariantCulture;
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions