Skip to content

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 community-contribution Indicates that the PR has been added by a community member area-System.Text.Json labels 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 <[email protected]>
@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