-
Notifications
You must be signed in to change notification settings - Fork 822
Fix access checking for properies setters in attribute arguments #18581
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
Conversation
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
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.
Pull Request Overview
This PR enhances attribute argument validation by enforcing accessibility checks on property setters when used in attribute targets.
- Retrieves the setter method and checks its accessibility using existing
MethInfoChecks
logic. - Emits a distinct error (
tcPropertyCannotBeSet1
) if the setter exists but isn’t accessible. - Integrates the new check into the
Item.Property
branch ofTcAttributeEx
.
Comments suppressed due to low confidence (2)
src/Compiler/Checking/Expressions/CheckExpressions.fs:11414
- [nitpick] Consider renaming
setterMeth
tosetterMethod
for clarity and consistency with other method-related variables.
let setterMeth = pinfo.SetterMethod
src/Compiler/Checking/Expressions/CheckExpressions.fs:11414
- Add unit tests covering this new setter accessibility check in attribute arguments to prevent regressions and validate both allowed and disallowed cases.
let setterMeth = pinfo.SetterMethod
Is it the same as #18575? |
@vzarytovskii I don't think #18575 can solve this problem, I looked into the code of the |
Ok, I can close this pr and go to #18575 |
It's fine to process here, I was just curious whether it overlaps or not. I can close that one down and you can incorporate changes into one/this one. Conversing with copilot is a bit tiresome. |
Yeah, I'll work on this pr then |
For sure carry on, please consider the currently open copilot PRs more of an exercise of the capabilities - pick anything good from there and we can close it down and keep yours only :) |
… extracting checking into a function
…ion for 3248; Update test to check for error 3248
@dotnet-policy-service agree |
Description
Fixes #18571
I use checking from
MethInfoChecks
Checklist