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

Support Records in GenAPI #34433

Merged
merged 4 commits into from
Aug 10, 2023
Merged

Support Records in GenAPI #34433

merged 4 commits into from
Aug 10, 2023

Conversation

ericstj
Copy link
Member

@ericstj ericstj commented Aug 3, 2023

Fixes #32196

Class records are mostly handled and regenerated with minimal compiler boilerplate.

Struct records show all the compiler generated boilerplate as I don't try to discern them from regular structs. We could do more here - by recognizing all the compiler generated members and reducing, but it's not necessary for compat parity.

Class records are mostly handled and regenerated with minimal
compiler boilerplate.
�Struct records show all the compiler generated boilerplate as I don't
try to discern them from regular structs.  We could do more here - by
recognizing all the compiler generated members and reducing, but it's
not necessary for compat parity.
@ericstj ericstj requested a review from ViktorHofer August 3, 2023 19:55
@ericstj ericstj requested review from andriipatsula, a team and joperezr as code owners August 3, 2023 19:55
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-GenAPI untriaged Request triage from a team member labels Aug 3, 2023
Copy link
Member

@carlossanlop carlossanlop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just have questions.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is slightly more costly now, I think it fits better into the existing filtering story. If we would like to mitigate the cost of recurring calls to symbol.ContainingType.TryGetRecordConstructor, we could add caching to the filter.

@ericstj
Copy link
Member Author

ericstj commented Aug 8, 2023

Looks like I broke things a bit when moving to the filter. Fixing ...

@ViktorHofer ViktorHofer merged commit 0d64135 into dotnet:main Aug 10, 2023
@ericstj
Copy link
Member Author

ericstj commented Aug 10, 2023

If we wanted to better handle struct records we could implement our own heuristic for detecting them from metadata - essentially if we see the entire set of methods that could be replaced with record syntax - do so. It's a bit more expensive than what we did here for classes but not impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-GenAPI untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GenAPI cannot decode records when reading from metadata
3 participants