All Projects → cezarypiatek → Mappinggenerator

cezarypiatek / Mappinggenerator

Licence: mit
🔄 "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.

Projects that are alternatives of or similar to Mappinggenerator

awesome-maps-ukraine
A curated list of maps of Ukraine, ukrainian mappers and tools that they use or develop for creating and publish maps
Stars: ✭ 35 (-95.79%)
Mutual labels:  mapping, mapper
Poiji
🍬 A tiny library converting excel rows to a list of Java objects based on Apache POI
Stars: ✭ 255 (-69.31%)
Mutual labels:  mapper, mapping
Codist
A visual studio extension which enhances syntax highlighting, quick info (tooltip), navigation bar, scrollbar, display quality and brings smart tool bar to code editor.
Stars: ✭ 134 (-83.87%)
Mutual labels:  visual-studio, roslyn
JSONUtilities
Easily load JSON objects and decode them into structs or classes
Stars: ✭ 57 (-93.14%)
Mutual labels:  mapping, mapper
Awesome Roslyn
Curated list of awesome Roslyn books, tutorials, open-source projects, analyzers, code fixes, refactorings, and source generators
Stars: ✭ 395 (-52.47%)
Mutual labels:  roslyn, code-generation
Rosalina
Rosalina is a code generation tool for Unity's UI documents. It generates C# code-behind script based on a UXML template.
Stars: ✭ 57 (-93.14%)
Mutual labels:  roslyn, code-generation
orika-spring-boot-starter
Spring Boot Starter for Orika.
Stars: ✭ 116 (-86.04%)
Mutual labels:  mapping, mapper
Roslyn Security Guard
Roslyn analyzers that aim to help security audit on .NET applications.
Stars: ✭ 214 (-74.25%)
Mutual labels:  roslyn, visual-studio
Agilemapper
A zero-configuration, highly-configurable, unopinionated object mapper with viewable execution plans. Flattens, unflattens, deep clones, merges, updates and projects queries. Targets .NET 3.5+ and .NET Standard 1.0+
Stars: ✭ 345 (-58.48%)
Mutual labels:  mapper, mapping
Morphism
⚡ Type-safe data transformer for JavaScript, TypeScript & Node.js.
Stars: ✭ 336 (-59.57%)
Mutual labels:  mapper, automapper
experimental-tools
A bunch of quality refactorings and code fixes that are going to improve your C# development experience in Visual Studio and remove some common pain.
Stars: ✭ 19 (-97.71%)
Mutual labels:  visual-studio, roslyn
Equinoxproject
Full ASP.NET Core 5 application with DDD, CQRS and Event Sourcing concepts
Stars: ✭ 5,120 (+516.13%)
Mutual labels:  automapper, visual-studio
Roslyn
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
Stars: ✭ 15,296 (+1740.67%)
Mutual labels:  roslyn, visual-studio
Detached-Mapper
An ORM friendly mapper. Allows saving entire entity graphs. Heavily inspired in GraphDiff and AutoMapper.
Stars: ✭ 89 (-89.29%)
Mutual labels:  mapper, automapper
Retyped
Access 3600+ libraries from C# and let Bridge.NET compile your project into JavaScript.
Stars: ✭ 216 (-74.01%)
Mutual labels:  roslyn, visual-studio
Ref12
Sends F12 in Visual Studio to the new .Net Reference Source Browser
Stars: ✭ 76 (-90.85%)
Mutual labels:  visual-studio, roslyn
Bridge
♠️ C# to JavaScript compiler. Write modern mobile and web apps in C#. Run anywhere with Bridge.NET.
Stars: ✭ 2,216 (+166.67%)
Mutual labels:  roslyn, visual-studio
Seriloganalyzer
Roslyn-based analysis for code using the Serilog logging library. Checks for common mistakes and usage problems.
Stars: ✭ 214 (-74.25%)
Mutual labels:  roslyn, visual-studio
Efdesigner
Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
Stars: ✭ 256 (-69.19%)
Mutual labels:  visual-studio, code-generation
Codeconverter
Convert code from C# to VB.NET and vice versa using Roslyn
Stars: ✭ 432 (-48.01%)
Mutual labels:  roslyn, visual-studio

Mapping Generator Tweet

"AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time. Read more Mapping Generator – Design Time Alternative to AutoMapper

You can download it as Visual Studio Extension from Visual Studio Marketplace.

Motivation

The reasons behind why I don't use AutoMapper

Further Development

If you find this extension useful (you feel it helps you on the daily basis) you can support further development by buying me a coffee (it's simple, just click the button below). Sometimes it's hard to stay awake till midnight implementing new features, coffee helps me with that. . I really appreciate your support in any form.

support guide

Contributing

Before you start any contributing work, please read the contribution guidline

Supported IDE

VisualStudio.

Install as VSIX from Market place or as a NuGet package. Verify your Roslyn integration option in case you are using R#.

JetBrains Rider

Install as a NuGet package

VSCode

Install as a NuGet package or use this instruction to install from VSIX

Using along with Resharper

If you are not able to open Roslyn refactoring menu (ctr + .) please verify your Resharper settings related to Visual Studio Integration or Visual Studio code analysis (depends on the R# version). For more information please check #50

resharper settings

Main features

Generate mapping method body

Pure mapping method

Non-void method that takes single parameter

public UserDTO Map(UserEntity entity)
{
    
}

Generating pure mapping method implementation

Updating method

Void method that takes two parameters

public void Update(UserDTO source, UserEntity target)
{
    
}

Generating update method implementation

Mapping Constructor

Constructor method that takes single complex parameter

public UserDTO(UserEntity user)
{
    
}

Generating mapping constructor implementation

Constructor method that takes more than one parameter

public UserDTO(string firstName, string lastName, int age, int cash)
{
}

Generating multi-parameter constructor

Updating member method

Void member method that takes single parameter

public void UpdateWith(UserEntity en)
{
    
}

Generating update member method imeplementation

Void member method with more than one parameter

public void Update(string firstName, string lastName, int age)
{
}

Generate inline code for fixing Compiler Errors:

CS0029 Cannot implicitly convert type 'type' to 'type'

cs0029

CS0266 Cannot implicitly convert type 'type1' to 'type2'. An explicit conversion exists (are you missing a cast?)

cs0266

CS7036 There is no argument given that corresponds to the required formal parameter

CS7036

Other mappings

  • Complete empty initialization block Generate initialization bloc

  • Complete empty initialization block in lambda expression Expression<Func<T,T2>> = (T) => new T2{} initialization block in lambda expression

  • Provide local accessible variables as parameters for method and constructor invocation locals as parameters

  • Create missing mapping lambda
    mapping lambda

  • Generate ICloneable interface implementation generate clone method

Object scaffolding

sample scaffolding

Mapping rules

  • Mapping Property-To-Property

    target.FirstName = source.FirstName;
    target.LastName = source.LastName;
    
  • Mapping Method Call-To-Property

    target.Total = source.GetTotal()
    
  • Flattening with sub-property

    target.UnitId = source.Unit.Id
    
  • Mapping complex property

     target.MainAddress = new AddressDTO(){
    	BuildingNo = source.MainAddress.BuildingNo,
    	City = source.MainAddress.City,
    	FlatNo = source.MainAddress.FlatNo,
    	Street = source.MainAddress.Street,
    	ZipCode = source.MainAddress.ZipCode
    };
    
  • Mapping collections

    target.Addresses = source.Addresses.Select(sourceAddresse => new AddressDTO(){
      BuildingNo = sourceAddresse.BuildingNo,
      City = sourceAddresse.City,
      FlatNo = sourceAddresse.FlatNo,
      Street = sourceAddresse.Street,
      ZipCode = sourceAddresse.ZipCode
    }).ToList().AsReadOnly();
    
  • Unwrapping wrappers

    customerEntity.Kind = cutomerDTO.Kind.Selected;
    
      public enum CustomerKind
      {
          Regular,
          Premium
      }
    
      public class Dropdown<T>
      {
          public List<T> AllOptions { get; set; }
    
          public T Selected { get; set; }
      }
    
      public class CustomerDTO
      {
          public string Name { get; set; }
          public Dropdown<CustomerKind> Kind { get; set; }
      }
    
      public class UserEntity
      {
          public string Name { get; set; }
          public CustomerKind Kind { get; set; }
      }
    
  • Using existing direct mapping constructor

    target.MainAddress = new AddressDTO(source.MainAddress);
    
  • using existing multi-parameter constuctor

    this.User =  new UserDTO(firstName: entity.FirstName, lastName: entity.LastName, age: entity.Age);
    
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].