Generate extension methods from your Mapster mappings.
using Mapster;
public class MappingConfig : IRegister
{
[Generate] <--
public void Register(TypeAdapterConfig config)
{
config.NewConfig<User, UserDto>();
}
}Build. Use the generated extensions:
user.Adapt<UserDto>(); // meh
user.ToUserDto(); // nice, press T and Tab doneTLDR: The Generator scans [Generate] methods, finds config.NewConfig<A, B>() calls, and generates A.ToB() extensions for each one.
No registrations = no generated code = compilation fails.
This project is licensed under the MIT License.