- Notifications
You must be signed in to change notification settings - Fork120
🔄 "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
License
cezarypiatek/MappingGenerator
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
MappingGenerator is discontinued in the form of FOSS. I spent the last three months (March 2021 - June 2021) working hard on improving MappingGenerator. I solved many issues and added a bunch of new cool features. I also made a general refactoring which restored the project maintainability. All of that cost me a lot of my private time and I did it all by myself, so I decided to convert MappingGenerator into a commercial product. A perpetual license for a new version of MappingGenerator can be obtained via the official product websitehttps://www.mappinggenerator.net/
I would like to thank all of you who contributed to this product by reporting issues, testing, authoring PRs, or buying me coffee.PR authors (except the Only README Updaters) and Coffee Buyers will be awarded with a special license for MappingGenerator for free - I will send them an email with details in a few days.
🔥 Important Links:
- Product pagehttps://www.mappinggenerator.net/
- Download page for VS2017 and VS2019https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.mappinggenerator
- Download page for VS2022https://marketplace.visualstudio.com/items?itemName=54748ff9-45fc-43c2-8ec5-cf7912bc3b84.MappingGenerator2022
- Current release noteshttps://github.com/cezarypiatek/MappingGeneratorReleases/releases
- New Issue Trackerhttps://github.com/cezarypiatek/MappingGeneratorIssueTracker
"AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time. Read moreMapping Generator – Design Time Alternative to AutoMapper
You can download it as Visual Studio Extension fromVisual Studio Marketplace.
The reasons behind why I don't use AutoMapper
Before you start any contributing work, please read thecontribution guideline
Install as VSIX fromMarket place or as aNuGet package. Verify yourRoslyn integration option in case you are using R#.
Install as aNuGet package
Install as aNuGet package or usethis instruction to install fromVSIX
If you are not able to open Roslyn refactoring menu (ctr + .) please verify your Resharper settings related toVisual Studio Integration orVisual Studio code analysis (depends on the R# version). For more information please check#50
Non-void method that takes single parameter
publicUserDTOMap(UserEntityentity){}
Void method that takes two parameters
publicvoidUpdate(UserDTOsource,UserEntitytarget){}
Constructor method that takes single complex parameter
publicUserDTO(UserEntity user){}
Constructor method that takes more than one parameter
publicUserDTO(string firstName,string lastName,int age,int cash){}
Void member method that takes single parameter
publicvoidUpdateWith(UserEntityen){}
Void member method with more than one parameter
publicvoidUpdate(stringfirstName,stringlastName,intage){}
CS0029 Cannot implicitly convert type 'type' to 'type'
CS0266 Cannot implicitly convert type 'type1' to 'type2'. An explicit conversion exists (are you missing a cast?)
CS7036 There is no argument given that corresponds to the required formal parameter
Complete empty initialization block in lambda expression
Expression<Func<T,T2>> = (T) => new T2{}
Provide local accessible variables as parameters for method and constructor invocation

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=newAddressDTO(){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=>newAddressDTO(){BuildingNo=sourceAddresse.BuildingNo,City=sourceAddresse.City,FlatNo=sourceAddresse.FlatNo,Street=sourceAddresse.Street,ZipCode=sourceAddresse.ZipCode}).ToList().AsReadOnly();
Unwrapping wrappers
customerEntity.Kind=cutomerDTO.Kind.Selected;
publicenumCustomerKind{Regular,Premium}publicclassDropdown<T>{publicList<T>AllOptions{get;set;}publicTSelected{get;set;}}publicclassCustomerDTO{publicstringName{get;set;}publicDropdown<CustomerKind>Kind{get;set;}}publicclassUserEntity{publicstringName{get;set;}publicCustomerKindKind{get;set;}}
Using existing direct mapping constructor
target.MainAddress=newAddressDTO(source.MainAddress);
using existing multi-parameter constuctor
this.User=newUserDTO(firstName:entity.FirstName,lastName:entity.LastName,age:entity.Age);
About
🔄 "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.













