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

Propagate marked attributes from primary constructor parameters to backing fields. #76475

Conversation

AlekseyTs
Copy link
Contributor

Related to #73920.

@AlekseyTs AlekseyTs requested a review from a team as a code owner December 17, 2024 18:53
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Dec 17, 2024
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler Please review

@AlekseyTs AlekseyTs changed the base branch from main to features/GeneratedCodeAttributes December 18, 2024 16:59
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler Please review


string source2 = @"
public record " + keyword + @" Test1(
[Preserve1]
Copy link
Member

Choose a reason for hiding this comment

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

[Preserve1]

Why isn't this attribute copied to the backing field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#73920 explicitly asks to not copy the attribute for records:

Cases where attributes should not flow:

  • Primary constructor parameters of record types: the compiler allows adding [property: ...] annotations to primary constructor parameters of record types ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A user is able to explicitly apply attributes to backing fields in records

@AlekseyTs AlekseyTs requested a review from cston December 18, 2024 22:02
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review

@AlekseyTs AlekseyTs requested a review from a team December 19, 2024 14:42
@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler For the second review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants