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

Enable roundtrip for F# struct record with datamember attribute #2860

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

T-Gro
Copy link

@T-Gro T-Gro commented May 17, 2023

This addresses #1295 , specifically the part which started to regress after F#7 added the "readonly" modified to compiler generated records.

The solution is to adjust the heuristic in order to find a good fitting parametrized constructor, and avoid fallback to default one.
Why did this work before? Because a default constructor was used, and private property/field injected later. However, with the "readonly" modifier, field injection no longer works.

This was always working fine without using mapping attributes, because newtonsoft found a constructor argument by its name.
The change in this PR just extends this to also look for constructor argument using the underlying name, and not just the name of the JSON property.

@T-Gro T-Gro requested a review from JamesNK May 17, 2023 09:30
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
@T-Gro
Copy link
Author

T-Gro commented May 29, 2023

Hi all, is there anything else I should improve here, or is this ready to be merged now?

@JamesNK
Copy link
Owner

JamesNK commented May 31, 2023

I need time to think this through and understand what breaking changes it could cause. I'm really busy right now, so I don't know when I'll get to that.

@T-Gro
Copy link
Author

T-Gro commented Nov 2, 2023

@JamesNK : Hi James, would now be a better time to merge this in please?

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.

3 participants