Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Nysosis
Copy link

@Nysosis Nysosis commented Nov 30, 2025

Adding support for IFormatProvider into static Parse method detetction

Description

Extended ParseMappingBuilder to act more like the ToStringMappingBuilder to resolve the method

Created and returned new ParseMethodMapping to handle the potential IFormatProvider argument

Fixes #1875

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)

@Nysosis Nysosis marked this pull request as ready for review December 1, 2025 06:44
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 this contribution, looks pretty good already!

@latonz latonz changed the title feat 1875: Added support for IFormatProvider in parse method feat: Added support for IFormatProvider in parse method Dec 1, 2025
@latonz latonz added the enhancement New feature or request label Dec 1, 2025
@Nysosis Nysosis force-pushed the feature/1875-parse-iformatprovider branch from ecee33d to eaa71cc Compare December 3, 2025 07:18
@Nysosis Nysosis requested a review from latonz December 3, 2025 15:57
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.

One nitpick left, also the tests need to be fixed.

@Nysosis Nysosis force-pushed the feature/1875-parse-iformatprovider branch 2 times, most recently from 31007ad to d6c5c47 Compare December 7, 2025 07:44
@Nysosis Nysosis requested a review from latonz December 8, 2025 09:21
@Nysosis
Copy link
Author

Nysosis commented Dec 8, 2025

I am wondering if technicallyyyy this could be considered a breaking change? Only in the situation if someone had a default FormatProvider defined for use in ToString, and was relying on the fact that Parse was not using that FormatProvider, this update would change that behaviour

@OwnageIsMagic
Copy link

@Nysosis yes, that's definitely a breaking change.
Currently ToString -> Parse doesn't roundtrip.
With this change it will.

@latonz
Copy link
Contributor

latonz commented Dec 9, 2025

You are absolutely right, this is definitely a breaking change. We plan to release the next breaking change with all open breaking change PR's (and maybe some other breaking changes) at the beginning of next year.
Planning to merge this as soon as this PR is ready and 4.3.1 or 4.4.0 is released.

@latonz latonz added the breaking-change This issue or pull request will break existing consumers label Dec 9, 2025
latonz
latonz previously approved these changes Dec 9, 2025
@Nysosis
Copy link
Author

Nysosis commented Dec 10, 2025

With regards to those breaking integration tests for framework and net8 @latonz, is this a case of 'You may need to manually update older versions' ? As when I'm running the integration tests via VS or dotnet test do not fail or make changes to those snapshots

@latonz
Copy link
Contributor

latonz commented Dec 10, 2025

With regards to those breaking integration tests for framework and net8 @latonz, is this a case of 'You may need to manually update older versions' ? As when I'm running the integration tests via VS or dotnet test do not fail or make changes to those snapshots

You'd need to run these tests with .NET 8.0/.NET Framework... However, usually it is easier to download the artifacts from the GitHub Actions Artifacts (you can find these here), extract and merge into your source, review the received/verified files and approve & commit them if ok.

@Nysosis
Copy link
Author

Nysosis commented Dec 12, 2025

Should the the tests for net6 and net7 be running on the GH pipelines? As it's not finding any:

A total of 1 test files matched the specified pattern.
No test is available in /__w/mapperly/mapperly/test/Riok.Mapperly.IntegrationTests/bin/Debug/net7.0/Riok.Mapperly.IntegrationTests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Noticed because I would have expected the snapshot verifications for 6&7 to also change (because they also support the formatprovider on int/guid parse) - if I change the sample project locally to be net 6.0 and add a format provider than the generated carmapper uses it.

@latonz
Copy link
Contributor

latonz commented Dec 12, 2025

Should the the tests for net6 and net7 be running on the GH pipelines? As it's not finding any:

A total of 1 test files matched the specified pattern.
No test is available in /__w/mapperly/mapperly/test/Riok.Mapperly.IntegrationTests/bin/Debug/net7.0/Riok.Mapperly.IntegrationTests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Noticed because I would have expected the snapshot verifications for 6&7 to also change (because they also support the formatprovider on int/guid parse) - if I change the sample project locally to be net 6.0 and add a format provider than the generated carmapper uses it.

Oh wow, I’m curious how long these haven’t been running. I’ll look into it. Since .NET 6 and 7 are no longer supported by Microsoft, we’re planning to drop support for them in Mapperly with the next breaking release. Because this will also be a breaking change, there’s nothing you need to worry about right now. Thanks for letting me know!

@Nysosis
Copy link
Author

Nysosis commented Dec 12, 2025

Oh wow, I’m curious how long these haven’t been running. I’ll look into it. Since .NET 6 and 7 are no longer supported by Microsoft, we’re planning to drop support for them in Mapperly with the next breaking release. Because this will also be a breaking change, there’s nothing you need to worry about right now. Thanks for letting me know!

I think it's the version of xunit.runner.visualstudio doing it, I dropped it down to 2.8.2 and was eventually able to get it running the net6 tests when using some dotnet command line arguments magic, but good to know I don't need to worry about them.

Will push up the framework/net8 snapshot changes :)

Extended ParseMappingBuilder to act more like the ToStringMappingBuilder to resolve the method

Created and returned new ParseMethodMapping to handle the potential IFormatProvider argument
@Nysosis Nysosis force-pushed the feature/1875-parse-iformatprovider branch from d6c5c47 to c7981b6 Compare December 12, 2025 13:00
@Nysosis Nysosis requested a review from latonz December 13, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This issue or pull request will break existing consumers enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use [FormatProvider] for Parse conversion

3 participants