Skip to content

PavelLev/MappingSourceGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MappingSourceGenerator

This project has source generator that allows to generate constructor mappings without any business logic. Main use case is considered to be immutable models (records).

Package NuGet
MappingSourceGenerator NuGet

Features:

  • Extension methods
  • Collections support (arrays, List<T> and any interface implemented by them)
  • Enum support
  • Nested mapping support
  • Using of manual mapping for nested properties

For examples please check out src/MappingSourceGenerator.IntegrationTests project.

Usage:

  1. Add package references to required packages
        <PackageReference Include="MappingSourceGenerator" Version="0.1.12" PrivateAssets="all" ExcludeAssets="runtime" />
  1. Create method definition for source generator. It should be static partial method marked with MappingSourceGenerator.Markers.GenerateMappingAttribute in static partial class.
public static partial class Mapper
{
    [GenerateMapping]
    public static partial Person2 Map(this Person1 person1);
}

Support

Feel free to create issues for bugs or feature requests. General improvement suggestions (e.g. regarding tests) are appreciated.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages