Mapster
Mapster copied to clipboard
Mapster Tool Extensions generation fails to generate from internal extension methods
public static partial class GeneratedMapperExtensionClass
{
private static Func<decimal, decimal> ToExt1;
public static DestinationClass AdaptToDestinationClass (this SourceClass p1)
{
return p1 == null ? null : new DestinationClass ()
{
Property = AdapterRegister.Convert(ToExt1.Invoke(p1.Property ))
};
}
}
IRegister class
public sealed class AdapterRegister : IRegister
{
public void Register(TypeAdapterConfig config)
{
config.NewConfig<SourceClass , DestinationClass>()
.Map(dst => dst.Property , src => Convert(src.Property .ToExt())) // using ToExt from internal extension class
.GenerateMapper(MapType.Map);
}
public static decimal Convert(decimal c)
{
return c;
}
}
internal extension class
internal static class TetsExt
{
internal static decimal ToExt(this decimal d)
{
return d * 1.0001m;
}
}
Command to generate extension:
<Target Name="TestAfterBuild" AfterTargets="Build"> <Exec Command="dotnet mapster extension -a "$(OutputPath)$(TargetFileName)" -n "$(RootNamespace).Adapters" -o "$(ProjectDir)Adapters"" /> </Target>
So as you see from this example when using internal static method it generates it as private static Func<decimal, decimal> ToExt1; Is there any way to fix this?