The problem
The major advantage of using Mapperly over other reflection based solutions like AutoMapper is that we now have mapping validation at build time. This works fine for most objects but not for enums, this is still done at run time when mapping a source object to a destination type.
The solution
A feature that can be enabled for explicit enum mapping. When the feature is enabled Mapperly should enforce that all enum values in the destination enum can be created using the values of the source enum. Possibly using a MapperAttribute. When it's not possible to create all enum values, the build should fail.
Alternatives
Writing unit tests and run them during the build step in the CI/CD pipeline to enforce integrity.
The problem
The major advantage of using Mapperly over other reflection based solutions like AutoMapper is that we now have mapping validation at build time. This works fine for most objects but not for enums, this is still done at run time when mapping a source object to a destination type.
The solution
A feature that can be enabled for explicit enum mapping. When the feature is enabled Mapperly should enforce that all enum values in the destination enum can be created using the values of the source enum. Possibly using a
MapperAttribute. When it's not possible to create all enum values, the build should fail.Alternatives
Writing unit tests and run them during the build step in the CI/CD pipeline to enforce integrity.