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

Improving STJ source generator support for record types #68064

Merged
merged 5 commits into from
Apr 19, 2022
Merged

Improving STJ source generator support for record types #68064

merged 5 commits into from
Apr 19, 2022

Conversation

jharjung
Copy link
Contributor

Improving the analyzer to not flag a warning about init-only properties that are actually constructor parameters. In particular,
record types with positional parameters desugar to classes with both a constructor and init-only properties (eg, to support "with" expressions). Since these properties are deserialized via the constructor and not the property setter, they support the fast path and round trip just fine, so the diagnostic analyzer should not raise the SYSLIB1037 warning.

See: Issue 58770

Joe Harjung added 2 commits April 14, 2022 20:06
Improving the analyzer to not flag a warning about init-only
properties that are actually constructor parameters. In particular,
record types with positional parameters desugar to classes with both
a constructor and init-only properties (eg, to support "with"
expressions). Since these properties are deserialized via the
constructor and not the property setter, they support the fast path and
round trip just fine, so the diagonstic analyzer should not raise the
SYSLIB1037 warning.

Issue 58770
Edit to fix missing semi colon in unit test's CreateCompiliation string

Issue 58770
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Apr 15, 2022
@ghost
Copy link

ghost commented Apr 15, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Improving the analyzer to not flag a warning about init-only properties that are actually constructor parameters. In particular,
record types with positional parameters desugar to classes with both a constructor and init-only properties (eg, to support "with" expressions). Since these properties are deserialized via the constructor and not the property setter, they support the fast path and round trip just fine, so the diagnostic analyzer should not raise the SYSLIB1037 warning.

See: Issue 58770

Author: jharjung
Assignees: -
Labels:

area-System.Text.Json, community-contribution

Milestone: -

@dnfadmin
Copy link

dnfadmin commented Apr 15, 2022

CLA assistant check
All CLA requirements met.

@eiriktsarpalis eiriktsarpalis self-assigned this Apr 15, 2022
Copy link
Member

@eiriktsarpalis eiriktsarpalis 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 your contribution!

@eiriktsarpalis eiriktsarpalis merged commit e2a4bb0 into dotnet:main Apr 19, 2022
directhex pushed a commit to directhex/runtime that referenced this pull request Apr 21, 2022
* Improving STJ source generator support for record types

Improving the analyzer to not flag a warning about init-only
properties that are actually constructor parameters. In particular,
record types with positional parameters desugar to classes with both
a constructor and init-only properties (eg, to support "with"
expressions). Since these properties are deserialized via the
constructor and not the property setter, they support the fast path and
round trip just fine, so the diagonstic analyzer should not raise the
SYSLIB1037 warning.

Issue 58770

* Improving STJ source generator support for record types

Edit to fix missing semi colon in unit test's CreateCompiliation string

Issue 58770

* Case insensitive matching of props with ctor params

* Additional unit tests

* Test for source gen positional records roundtrip

Co-authored-by: Joe Harjung <jharjung@integratedlabor.com>
@ghost ghost locked as resolved and limited conversation to collaborators May 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants