Riok.Mapperly 3.0.0

Mapperly

Nuget Nuget Preview GitHub Downloads GitHub

Mapperly is a .NET source generator for generating object mappings. Inspired by MapStruct.

Because Mapperly creates the mapping code at build time, there is minimal overhead at runtime. Even better, the generated code is perfectly readable, allowing you to verify the generated mapping code easily.

Documentation

The documentation is available here.

Quickstart

Installation

Add the NuGet Package to your project:

dotnet add package Riok.Mapperly

Create your first mapper

Create a mapper declaration as a partial class and apply the Riok.Mapperly.Abstractions.MapperAttribute attribute. Mapperly generates mapping method implementations for the defined mapping methods in the mapper.

// Mapper declaration
[Mapper]
public partial class CarMapper
{
    public partial CarDto CarToCarDto(Car car);
}

// Mapper usage
var mapper = new CarMapper();
var car = new Car { NumberOfSeats = 10, ... };
var dto = mapper.CarToCarDto(car);
dto.NumberOfSeats.Should().Be(10);

Read the docs for any further information.

How To Contribute

We would love for you to contribute to Mapperly and help make it even better than it is today! Find information on how to contribute in the docs.

License

Mapperly is Apache 2.0 licensed.

No packages depend on Riok.Mapperly.

# [3.0.0](https://github.com/riok/mapperly/compare/v2.8.0...v3.0.0) (2023-08-07) ### Bug Fixes * is no longer treated as a member ([#575](https://github.com/riok/mapperly/issues/575)) ([b238481](https://github.com/riok/mapperly/commit/b23848167648b3dde900a6f241fb40a8d1563596)) * Add <auto-generated /> comment ([#496](https://github.com/riok/mapperly/issues/496)) ([b3e1657](https://github.com/riok/mapperly/commit/b3e1657325cfd65e6e678d841519c022a8bdf9a3)) * add private does not obscure test ([#554](https://github.com/riok/mapperly/issues/554)) ([f6d8d34](https://github.com/riok/mapperly/commit/f6d8d3440812deb6fe43574ebdf6a79e3797a8d9)) * allow reference handling for generic and runtime target type mapping methods ([#508](https://github.com/riok/mapperly/issues/508)) ([34b237f](https://github.com/riok/mapperly/commit/34b237fb44129fd7867a5f4fdda71872ded3aeff)) * clone array when deepcloning is enabled and target is an IEnumerable ([#431](https://github.com/riok/mapperly/issues/431)) ([082d877](https://github.com/riok/mapperly/commit/082d877e113378ec8d29b6928911ff4c398fe762)) * disable warning when iterating nullable array elements ([#592](https://github.com/riok/mapperly/issues/592)) ([8f37f44](https://github.com/riok/mapperly/commit/8f37f4401f51eb9c4f5fbcfb8424cbffe34fc9a8)) * exclude explicit casts when source type is object ([#400](https://github.com/riok/mapperly/issues/400)) ([3af9cc9](https://github.com/riok/mapperly/commit/3af9cc943a61e92dbc4dafcc956ce2bb51365825)) * existing dictionary and enumerable mapping should respect enabled conversion types ([#459](https://github.com/riok/mapperly/issues/459)) ([86f48a2](https://github.com/riok/mapperly/commit/86f48a2a152e637f46e188c4ee11f7d369f23230)) * generate nameof compatible member access ([#539](https://github.com/riok/mapperly/issues/539)) ([92673db](https://github.com/riok/mapperly/commit/92673dbfbb02d636b3de5dea6b024f93cb94c933)) * handle internal visibility correctly ([#597](https://github.com/riok/mapperly/issues/597)) ([5d4596a](https://github.com/riok/mapperly/commit/5d4596a2e963032b5d61be627f99581649868368)) * ignore user implemented generic methods ([#423](https://github.com/riok/mapperly/issues/423)) ([408d03f](https://github.com/riok/mapperly/commit/408d03fdc13a19ef254faa253e7745b452524068)) * improve performance for member resolution ([#603](https://github.com/riok/mapperly/issues/603)) ([641c1bf](https://github.com/riok/mapperly/commit/641c1bf594f751c0aaf30aa7403e1fc862cd37ef)) * incorrect initialization for nullable nested memberpath unflattening ([#591](https://github.com/riok/mapperly/issues/591)) ([9b74e8f](https://github.com/riok/mapperly/commit/9b74e8fb025809035a5dda0d6d91fb34f5f6d6ef)) * lambdas should use correct scopes to generate names ([#411](https://github.com/riok/mapperly/issues/411)) ([e5d9bb2](https://github.com/riok/mapperly/commit/e5d9bb2bf215fad916bdfbfa7d11366903256c8d)) * make all attributes sealed ([#614](https://github.com/riok/mapperly/issues/614)) ([24614c0](https://github.com/riok/mapperly/commit/24614c0f9b0350bf1af1a42a6049a316947850d0)) * map existing target sets correct ([#500](https://github.com/riok/mapperly/issues/500)) ([38e6556](https://github.com/riok/mapperly/commit/38e655630453b0dfe98fa76d73e5de4845eba405)) * only use instance constructors to create new object instances ([#458](https://github.com/riok/mapperly/issues/458)) ([848fb45](https://github.com/riok/mapperly/commit/848fb45c5d81ca868b2818a2496738eda57a1d25)) * prevent ctormapping using inaccessible constructors ([#456](https://github.com/riok/mapperly/issues/456)) ([125742e](https://github.com/riok/mapperly/commit/125742e799fb4ed166750ddc955750f5ab50f0cd)) * prevent duplicates attributes and base types for nested mappers ([#544](https://github.com/riok/mapperly/issues/544)) ([44667c8](https://github.com/riok/mapperly/commit/44667c8576d404bca9ce2696b90746d5d4e97a16)) * prevent generation of empty if not null statements ([#576](https://github.com/riok/mapperly/issues/576)) ([8cbeff1](https://github.com/riok/mapperly/commit/8cbeff1dbc7761f065d6ec75f5dbd8b05c713f87)) * prevent mapping backing field ([#608](https://github.com/riok/mapperly/issues/608)) ([d768dbb](https://github.com/riok/mapperly/commit/d768dbb4f74a889cf91784721a2b2a257744386c)) * prevent throw throw being generated. ([#415](https://github.com/riok/mapperly/issues/415)) ([3c41c84](https://github.com/riok/mapperly/commit/3c41c84991d68693cb34f349c33a6868e0987853)) * remove obsolete MapperIgnoreAttribute ([#611](https://github.com/riok/mapperly/issues/611)) ([c7a5099](https://github.com/riok/mapperly/commit/c7a509966a714dbb5bce92306798e1fe0196de60)) * required/init properties not using PropertyNameMappingStrategy ([#505](https://github.com/riok/mapperly/issues/505)) ([#556](https://github.com/riok/mapperly/issues/556)) ([564a43e](https://github.com/riok/mapperly/commit/564a43e2f62d458ebad32fc33c943f376c571c4e)) * seal all configuration attributes ([#403](https://github.com/riok/mapperly/issues/403)) ([cb837e0](https://github.com/riok/mapperly/commit/cb837e0166fa37eef682d74e967563737fca757d)) * support queryable projection mappings for derived type mappings ([#412](https://github.com/riok/mapperly/issues/412)) ([98a44a0](https://github.com/riok/mapperly/commit/98a44a029a58dd5024d6a8a2740df450a3d80bc5)) * throw NullReferenceException for element access ([#414](https://github.com/riok/mapperly/issues/414)) ([78b2736](https://github.com/riok/mapperly/commit/78b2736f0f30ca0b8fbd259e60f68941e7d0681b)) * update IsImmutable to identify valid types on framework ([#388](https://github.com/riok/mapperly/issues/388)) ([b9a1f19](https://github.com/riok/mapperly/commit/b9a1f1911637526c4ff3afa3ddc0841b6b417041)) * use ToList/ToArray to clone enumerable interfaces ([#432](https://github.com/riok/mapperly/issues/432)) ([f947cbf](https://github.com/riok/mapperly/commit/f947cbf868cc4a9ccdd7be2e4d55027229d2d3d7)) ### Features * accept destination type as mapping method parameter ([#398](https://github.com/riok/mapperly/issues/398)) ([b17f666](https://github.com/riok/mapperly/commit/b17f666eff839283e5d8976e52f11df307939840)) * add AllowNullPropertyAssignment option to disable assigning null values to nullable properties ([#584](https://github.com/riok/mapperly/issues/584)) ([0ccc734](https://github.com/riok/mapperly/commit/0ccc734a0f1cffc45538618904c910f4acb8c439)) * add IgnoreObsoleteMembers ([#392](https://github.com/riok/mapperly/issues/392)) ([def10cf](https://github.com/riok/mapperly/commit/def10cf187f14f5b8bcc3d4689fe86266deea4fb)) * add option to ignore enum values ([#536](https://github.com/riok/mapperly/issues/536)) ([3e2a2c8](https://github.com/riok/mapperly/commit/3e2a2c891440c0101ce00b5a391edbc9d93b2bfe)) * add support for and mappings ([#425](https://github.com/riok/mapperly/issues/425)) ([ac254ca](https://github.com/riok/mapperly/commit/ac254ca2ee276d26736e4ad406cfe04f534ff6a9)) * add support for user defined generic mapping methods ([#461](https://github.com/riok/mapperly/issues/461)) ([ddbc516](https://github.com/riok/mapperly/commit/ddbc5169a3afe4d290c58b5e05c6e4b749a6f30d)) * add tuple mapping support ([#467](https://github.com/riok/mapperly/issues/467)) ([208e8b4](https://github.com/riok/mapperly/commit/208e8b49d92d0e4d1dd6b1e3ffc09eea73b4adb0)) * Added MapEnumValueAttribute and support for explicit named enum value mapping ([#468](https://github.com/riok/mapperly/issues/468)) ([64e6c9d](https://github.com/riok/mapperly/commit/64e6c9d58862ea6beb88d11488a824cd5425220e)) * added source generator benchmark ([#419](https://github.com/riok/mapperly/issues/419)) ([b6836b2](https://github.com/riok/mapperly/commit/b6836b277e23a0028f6a762880be2c9efe4bff20)) * cache attribute symbols ([#478](https://github.com/riok/mapperly/issues/478)) ([fbe8ba1](https://github.com/riok/mapperly/commit/fbe8ba154efa5cd727affa5280bdc24dfd62a6aa)) * diagnostic if an incompatible language version is used ([#566](https://github.com/riok/mapperly/issues/566)) ([38332a6](https://github.com/riok/mapperly/commit/38332a68155d42570a93cd43d4e21f9610a4690b)) * directly assign System.Uri and System.Version when deep cloning ([#440](https://github.com/riok/mapperly/issues/440)) ([c845b43](https://github.com/riok/mapperly/commit/c845b43bea2651b9e67b1bc7dae99c5320da60b1)) * explicit enum mappings for byValue enum mappings ([#489](https://github.com/riok/mapperly/issues/489)) ([029dae2](https://github.com/riok/mapperly/commit/029dae28de90722f0bf55f7aabed47027db5ed83)) * ISet and IReadOnlySet support ([#502](https://github.com/riok/mapperly/issues/502)) ([9550ae4](https://github.com/riok/mapperly/commit/9550ae4591fd27652f4ff0aa403f2f1a38e41033)) * Map all accessible members by default ([#597](https://github.com/riok/mapperly/issues/597)) ([#612](https://github.com/riok/mapperly/issues/612)) ([3d2ed69](https://github.com/riok/mapperly/commit/3d2ed699119da04213d8e3303fc56471e411a770)) * optimize BuildMemberPathCandidates performance ([#480](https://github.com/riok/mapperly/issues/480)) ([34b926b](https://github.com/riok/mapperly/commit/34b926b456b74a7c3c36c11be29c271547ddba6f)) * optimize enum ByValueCheckDefined strategy and support flags ([#510](https://github.com/riok/mapperly/issues/510)) ([602c79d](https://github.com/riok/mapperly/commit/602c79dadbadd3f03a335a3bde2279950855f6cf)) * support derived type configuration inheritance ([#509](https://github.com/riok/mapperly/issues/509)) ([66124f8](https://github.com/riok/mapperly/commit/66124f8509f278f9e62428916db7cbafbcea5716)) * support derived type mappings ([#366](https://github.com/riok/mapperly/issues/366)) ([11995f0](https://github.com/riok/mapperly/commit/11995f0dddc8ebf35fd29c8f7837744d26855520)) * Support enum mapping is defined check and fallback values ([#491](https://github.com/riok/mapperly/issues/491)) ([f0065c8](https://github.com/riok/mapperly/commit/f0065c8c5e9fa4b3a26951e733c0d06bb5501816)) * support for strict enum mappings ([#356](https://github.com/riok/mapperly/issues/356)) ([b13d364](https://github.com/riok/mapperly/commit/b13d36453a51db9adcf49c76edc169c0c64b6919)) ### BREAKING CHANGES * mark all attributes as sealed * Include accessible internal and private members in mappings * Obsolete MapperIgnoreAttribute is removed and needs to be replaced with MapperIgnoreTargetAttribute

.NET Standard 2.0

  • No dependencies.

Version Downloads Last updated
4.2.1 2 04/28/2025
4.2.1-next.2 1 04/25/2025
4.2.1-next.1 1 04/25/2025
4.2.1-next.0 5 04/14/2025
4.2.0 6 03/31/2025
4.2.0-next.2 7 03/23/2025
4.2.0-next.1 8 02/21/2025
4.2.0-next.0 8 01/26/2025
4.1.1 16 11/23/2024
4.1.1-next.0 16 11/07/2024
4.1.0 15 10/31/2024
4.1.0-next.3 14 10/31/2024
4.1.0-next.2 14 10/26/2024
4.1.0-next.1 15 10/16/2024
4.1.0-next.0 20 10/11/2024
4.0.0 17 10/11/2024
4.0.0-next.4 14 10/02/2024
4.0.0-next.3 20 08/17/2024
4.0.0-next.2 21 08/12/2024
4.0.0-next.1 20 07/01/2024
3.6.0 1,999 06/19/2024
3.6.0-next.2 24 06/06/2024
3.6.0-next.1 23 05/03/2024
3.5.1 23 04/23/2024
3.5.1-next.2 22 04/19/2024
3.5.1-next.1 21 04/09/2024
3.5.0 23 04/05/2024
3.5.0-next.4 23 03/27/2024
3.5.0-next.3 25 03/18/2024
3.5.0-next.2 21 03/16/2024
3.5.0-next.1 23 03/10/2024
3.4.0 21 03/01/2024
3.4.0-next.5 21 02/28/2024
3.4.0-next.4 21 02/19/2024
3.4.0-next.3 25 02/13/2024
3.4.0-next.2 26 01/12/2024
3.4.0-next.1 23 01/12/2024
3.3.1-next.1 27 12/21/2023
3.3.0 1,984 12/16/2023
3.3.0-next.6 27 12/10/2023
3.3.0-next.5 23 12/06/2023
3.3.0-next.4 24 12/06/2023
3.3.0-next.3 26 12/06/2023
3.3.0-next.2 24 10/26/2023
3.3.0-next.1 21 10/22/2023
3.2.0 25 09/19/2023
3.2.0-next.4 25 09/25/2023
3.2.0-next.3 25 09/12/2023
3.2.0-next.2 26 09/23/2023
3.2.0-next.1 24 09/03/2023
3.1.0 29 08/26/2023
3.1.0-next.2 26 08/23/2023
3.1.0-next.1 27 08/16/2023
3.0.0 26 08/16/2023
3.0.0-next.1 29 08/17/2023
2.9.0-next.4 25 08/06/2023
2.9.0-next.3 27 08/10/2023
2.9.0-next.2 24 07/05/2023
2.9.0-next.1 24 07/05/2023
2.8.0 28 07/05/2023
2.8.0-next.2 28 07/06/2023
2.8.0-next.1 491 04/13/2023
2.7.1-next.1 27 07/10/2023
2.7.0 29 07/08/2023
2.7.0-next.2 25 07/07/2023
2.7.0-next.1 23 07/07/2023
2.6.0 24 07/05/2023
2.6.0-next.4 25 07/04/2023
2.6.0-next.3 23 07/08/2023
2.6.0-next.2 27 07/07/2023
2.6.0-next.1 27 07/07/2023
2.5.0 30 06/27/2023
2.5.0-next.2 25 07/09/2023
2.5.0-next.1 28 07/06/2023
2.4.1-next.1 26 07/07/2023
2.4.0 25 07/05/2023
2.3.3 28 07/11/2023
2.3.2 27 07/07/2023
2.3.1 30 07/06/2023
2.3.0 31 07/05/2023
2.2.1 32 07/06/2023
2.2.0 27 07/04/2023
2.1.0 26 07/03/2023
2.0.0 27 07/17/2023