Skip to content

Conversation

iclectic
Copy link
Contributor

@iclectic iclectic commented Sep 2, 2025

Should fix #1929 by extending MapperIgnore to work with static conversion methods. Now one can mark specific static methods with [MapperIgnore] to prevent them from being used as conversion methods.

Changes:

  • Updated MapperIgnoreAttribute to support methods
  • Added filtering in ConvertStaticMethodMappingBuilder to skip ignored static methods
  • Added tests to verify the new behaviour

Testing:

  • All existing tests pass
  • New test cases cover both source and target method scenarios

iclectic and others added 2 commits September 2, 2025 18:52
- Extend MapperIgnoreAttribute to support methods
- Filter out ignored static methods during conversion discovery
- Add tests for ignored static methods
- Proposed fix for Issue riok#1929
Copy link
Contributor

@latonz latonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I added my feedback.

@latonz latonz added the enhancement New feature or request label Sep 2, 2025
- Add [MapperIgnore] attribute filtering to ConvertInstanceMethodMappingBuilder
- Add [MapperIgnore] attribute filtering to ParseMappingBuilder
- Update test to use nameof(FromB) for better maintainability
- Add test case for constructor fallback when static method is ignored

Proposal to fix Issue riok#1929
@iclectic iclectic requested a review from latonz September 2, 2025 19:18
…th MapperIgnore

- Extend MapperIgnoreAttribute to support methods
- Add filtering for ignored methods in ParseMappingBuilder and ConvertInstanceMethodMappingBuilder
- Add test cases for ignored parse and instance methods

Proposal to fix Issue riok#1929
@iclectic iclectic requested a review from latonz September 3, 2025 04:43
- Add AttributeTargets.Method to MapperIgnoreAttribute
- Update snapshot to include Method (order matched)
- Move/adjust tests for parse and ToTarget ignore
- Docs: mention methods and add ignore examples
latonz
latonz previously approved these changes Sep 4, 2025
Copy link
Contributor

@latonz latonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again for the updates, almost good to merge 😊

Copy link
Contributor

@latonz latonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates, now it almost looks good to be merged. One small nitpick 🙈 And please also check the linter issues: https://github.com/riok/mapperly/actions/runs/17701857152/job/50422690421?pr=1941

@latonz latonz merged commit 97e75d6 into riok:main Oct 7, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore static convert methods by applying MapperIgnoreAttribute

2 participants