Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Map from source object #1247

Merged
merged 7 commits into from
May 3, 2024
Merged

Conversation

rhodon-jargon
Copy link
Contributor

Allow mapping from source object

Description

Adds a MapPropertyFromSourceAttribute, that allows using the source object directly for mappings. In most of the code, this is represented as an empty source MemberPath. This required a few changes, as most of the code just assumed MemberPaths were not empty. Currently, when a MapPropertyFromSourceAttribute is used, all unused source member diagnostics are suppressed, as there is no way to analyse for every situation what members of the source are used by the conversion. This can be changed to require explicit ignore attributes for all members that are used implicitly by the mapping from source.

An additional reason for wanting this, apart from the arguments discussed in #1161, is to allow these kind of mappings for required or init-only members.

Fixes #1161

Checklist

  • The existing code style is followed
  • The commit message follows our guidelines
  • Performed a self-review of my code
  • Hard-to-understand areas of my code are commented
  • The documentation is updated (as applicable)
  • Unit tests are added/updated
  • Integration tests are added/updated (as applicable, especially if feature/bug depends on roslyn or framework version in use)

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.

Thanks for this contribution! I really like the idea of MemberPath.ToDisplayString.
And great test coverage 👍
I added my feedback 😊

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.

Thanks for the updates 😊 Only open feedback point: #1247 (comment).

@rhodon-jargon rhodon-jargon requested a review from latonz May 3, 2024 13:30
@latonz latonz enabled auto-merge (squash) May 3, 2024 18:33
@latonz latonz merged commit d790055 into riok:main May 3, 2024
17 checks passed
@latonz
Copy link
Contributor

latonz commented May 3, 2024

Thank you for this great addition to Mapperly!

Copy link

github-actions bot commented May 3, 2024

🎉 This PR is included in version 3.6.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 3.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Mapping from the source object
2 participants