Skip to content

DenDeline/SunMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet NuGet

.NET

SunMapper

Lightweight and fast object mapper, which creates methods for mapping at the compile time.

Testing 🛠

There are a lot of things that are not implemented yet or some code can give you unexpected result, so use this package at your own risk.

Install

  • PowerShell:
Install-Package SunMapper

-- OR --

  • Add reference to the project file:
<PackageReference Include="SunMapper"/>

You can find other ways for installing here.

Usage

Add MapTo attribute to a model you want to get data from:

using SunMapper.Common.Attributes;

[MapTo(typeof(UserGetDto))]
public class User {
    public int Id { get; set; }
    public string Name { get; set; }
    public string PasswordHash { get; set; }
}

public class UserGetDto {
    public string Name { get; set; }
}

Bunch stuff will be generated under the hood, that's why you can use extension method TryMapTo of User:

var user = new User { Id = 0, Name = "User", PasswordHash = "Hash" };

if (user.TryMapTo(out UserGetDto dto)) {
    // working with dto
}

Limitations

You can map only public properties with { get; set } methods and the same type.

Milestones 🚩

For comfortable using library, this things should be implemented:

  • Mapping profiles
  • Custom type conversation
  • Upselling architecture
  • Support of popular libraries such as FluentValidation
  • ASP.NET Support
  • Readable generated code

About

Lightweight mapper based on sourcecode gen

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages