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

Add support for From and To method conversions (#1117) #1616

Merged

Conversation

TonEnfer
Copy link
Contributor

@TonEnfer TonEnfer commented Nov 30, 2024

Add support for From and To method conversions (#1117)

Description

  • Added support for conversion by calling the ToTTarget method on the source object
  • Added support for conversion by calling the static Create, CreateFrom, FromTSource methods on the integer type, as well as by calling the static ToTTarget method on the source type

Despite the discussion in the issue, the ToString mapping builder remains untouched as it contains a lot of logic.
Instead, the new mapping builder eliminates the mapping to string.

The previously existing mapping builders for DateTime mapping have been removed, as their role is now performed by the new mapping builder for static methods.
However, MappingConversionType has only been extended, the previously existing MappingConversionType.DateTimeToDateOnly and MappingConversionType.DateTimeToTimeOnly are left for backward compatibility, their processing has been moved to the new mapping builder

Fixes #1117

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)

@TonEnfer TonEnfer marked this pull request as ready for review November 30, 2024 06:51
@TonEnfer TonEnfer force-pushed the #1117_Support_From_and_To_static_factory_methods branch from 22527b1 to 2d82323 Compare December 1, 2024 05:06
@latonz latonz added the enhancement New feature or request label Dec 2, 2024
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 PR! I’m excited to see this feature added to Mapperly. I’ve shared my feedback 😊

…_factory_methods' into #1117_Support_From_and_To_static_factory_methods

# Conflicts:
#	docs/docs/configuration/conversions.md
#	src/Riok.Mapperly.Abstractions/MappingConversionType.cs
#	src/Riok.Mapperly/Descriptors/MappingBuilders/ConvertInstanceMethodMappingBuilder.cs
#	src/Riok.Mapperly/Descriptors/MappingBuilders/ConvertStaticMethodMappingBuilder.cs
#	src/Riok.Mapperly/Descriptors/Mappings/ToStringMapping.cs
#	test/Riok.Mapperly.Abstractions.Tests/_snapshots/PublicApiTest.PublicApiHasNotChanged.verified.cs
#	test/Riok.Mapperly.Tests/Mapping/StaticMethodConversionTest.cs
@TonEnfer TonEnfer requested a review from latonz December 5, 2024 19:12
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! I added my feedback 😊

@TonEnfer TonEnfer force-pushed the #1117_Support_From_and_To_static_factory_methods branch 3 times, most recently from 6cce5d5 to e0ac3e4 Compare December 9, 2024 07:39
@TonEnfer TonEnfer force-pushed the #1117_Support_From_and_To_static_factory_methods branch from e0ac3e4 to 2016b07 Compare December 9, 2024 07:46
@TonEnfer TonEnfer requested a review from latonz December 9, 2024 07:50
@latonz latonz merged commit 39376fa into riok:main Dec 9, 2024
18 checks passed
@latonz
Copy link
Contributor

latonz commented Dec 9, 2024

Thank you for this contribution!

@TonEnfer TonEnfer deleted the #1117_Support_From_and_To_static_factory_methods branch December 9, 2024 08:48
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.

Support From and To static factory methods
2 participants