-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
T-Gro
wants to merge
6
commits into
JamesNK:master
Choose a base branch
from
T-Gro:fsharp-struct-record-datamember
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JamesNK
reviewed
May 17, 2023
Src/Newtonsoft.Json.Tests/TestObjects/FsharpStructRecordWithDataMember.cs
Outdated
Show resolved
Hide resolved
JamesNK
reviewed
May 17, 2023
Co-authored-by: James Newton-King <james@newtonking.com>
…T-Gro/Newtonsoft.Json into fsharp-struct-record-datamember
sungam3r
reviewed
May 19, 2023
Co-authored-by: Ivan Maximov <sungam3r@yandex.ru>
Hi all, is there anything else I should improve here, or is this ready to be merged now? |
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. |
@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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.