Skip to content

Conversation

@eiriktsarpalis
Copy link
Member

When querying a ValueTuple type symbol for fields, the returned symbols include any explicitly named tupled elements. These do not correspond to runtime properties and as such should be filtered from the generated code.

Note that while the source generator could take advantage of this compile-time metadata, emitting serialization code that accounts for explicitly named tuple elements would diverge from the reflection-based behaviour. As such, all tuples will be serialized as { "Item1" : 1, "Item2" : 2 , ... } regardless of any element labels used at compile time.

Should be backported to release/6.0.

Fixes #58137.

@ghost
Copy link

ghost commented Sep 3, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

When querying a ValueTuple type symbol for fields, the returned symbols include any explicitly named tupled elements. These do not correspond to runtime properties and as such should be filtered from the generated code.

Note that while the source generator could take advantage of this compile-time metadata, emitting serialization code that accounts for explicitly named tuple elements would diverge from the reflection-based behaviour. As such, all tuples will be serialized as { "Item1" : 1, "Item2" : 2 , ... } regardless of any element labels used at compile time.

Should be backported to release/6.0.

Fixes #58137.

Author: eiriktsarpalis
Assignees: eiriktsarpalis
Labels:

area-System.Text.Json

Milestone: 6.0.0

@eiriktsarpalis eiriktsarpalis merged commit dff1c70 into dotnet:main Sep 6, 2021
@eiriktsarpalis
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2021

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1205881963

@eiriktsarpalis eiriktsarpalis deleted the fix-sourcegen-tuple-support branch September 6, 2021 12:22
@ghost ghost locked as resolved and limited conversation to collaborators Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

STJ Source Generator generates invalid code with value tuples

3 participants