-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Conversation
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
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsImproving the analyzer to not flag a warning about init-only properties that are actually constructor parameters. In particular, See: Issue 58770
|
...ies/System.Text.Json/tests/System.Text.Json.SourceGeneration.Unit.Tests/CompilationHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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!
* 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>
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