Skip to content

Conversation

@neozhu
Copy link
Owner

@neozhu neozhu commented Nov 6, 2024

Summary

This PR replaces AutoMapper with Mapperly as the object mapping solution in the project. The motivation behind this change is to leverage Mapperly's advantages, particularly in terms of performance, as well as its more efficient approach to mapping configuration.

Details

  • Performance Benefits: Mapperly uses source generation to create mapping code during compile time, which results in faster execution compared to the runtime reflection used by AutoMapper. This leads to significant performance gains, especially for applications with large-scale or frequent mapping requirements.
  • Simpler Mapping Configuration: Unlike AutoMapper, Mapperly generates mappings without relying on reflection and allows us to easily customize mappings with strongly-typed configurations. When an object does not have a predefined mapping, Mapperly requires us to create a Mapper class explicitly, ensuring clear and well-maintained mapping definitions.
  • Reduced Overhead: Mapperly has minimal runtime overhead since mappings are pre-generated. This leads to lower memory consumption and fewer performance bottlenecks during application execution.

Code Changes

  • Removed all AutoMapper dependencies from the project.
  • Introduced Mapperly as the new object mapping tool.
  • Created mapper classes for objects that were previously handled by AutoMapper, ensuring consistency in mapping logic while benefiting from Mapperly's compile-time checks.

Testing

  • Verified that all unit tests related to object mappings pass with Mapperly.
  • Conducted performance profiling to confirm improvements in mapping speed.

Next Steps

If you have any questions or concerns about these changes or the migration process, feel free to reach out. I’m happy to discuss the benefits further or provide additional context if needed.

@neozhu neozhu merged commit 3768099 into main Nov 7, 2024
4 checks passed
@neozhu neozhu deleted the replace-automapper-with-mapperly branch July 11, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants