MapsterMapper/Mapster

mapster tool generates non-public interface method/property implementation

Offen

#399 geöffnet am 05.01.2022

 (1 Kommentar) (0 Reaktionen) (1 zugewiesene Person)C# (312 Forks)batch import
bughelp wanted

Repository-Metriken

Stars
 (3.995 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 12T 15h) (10 gemergte PRs in 30 T)

Beschreibung

When generating mapper from interface containing mapping method/property with internal classes mapster tool generates internal implementation of this method/property

  • Mapster.Core v1.2.0
  • mapster.tool v8.2.1
  • executed on net5
[Mapper(IsInternal = true)]
internal interface IMyMappers
{
    PocoDto Map(Poco source);

    Expression<Func<Poco, PocoDto>> ProjectToDto { get; }
}

public record Poco(string Name, string Description);

internal record PocoDto(string Name, string Description);

Generated mapper class is:

internal partial class MyMappers : IMyMappers
{
    internal Expression<Func<Poco, PocoDto>> ProjectToDto => p1 => new PocoDto(p1.Name, p1.Description);
    internal PocoDto Map(Poco p2)
    {
        return p2 == null ? null : new PocoDto(p2.Name, p2.Description);
    }
}

CS0737: 'MyMappers.Map(Poco)' cannot implement an interface member because it is not public. CS0737: 'MyMappers.ProjectToDto' cannot implement an interface member because it is not public.

Maybe internal class with proper implementations should be generated even in case MapperAttribute.IsInternal hasn't been specified

Contributor Guide