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

Warn on reflection access to instance methods on RUC types #3147

Merged
merged 8 commits into from
Dec 5, 2022

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Dec 1, 2022

Fixes the hole for methods in #3140. We don't warn for RUC attributes on methods in RUC types, but instead prevent reflection access from creating these attributes by warning on the reflection access to methods (including instance methods).

This leaves the attribute warnings for fields as-is - so instance fields will get attribute warnings unlike instance methods, because we don't warn on reflection access to instance fields in RUC types. This is inconsistent with the analyzer behavior, which doesn't warn for attributes in this case. I may try to address that in a follow-up.

- Add link to bug
- Remove unused code
- Remove left-over incomplete comment
- Update comments in modified testcases
@sbomer sbomer merged commit f3469ca into dotnet:main Dec 5, 2022
tlakollo pushed a commit to tlakollo/linker that referenced this pull request Dec 20, 2022
Fixes an analysis hole where reflecting on instance methods of RUC
types produced no warnings. This isn't trim-compatible in case the
methods are decorated with attributes with RUC constructors, or in
case they are invoked on a null instance. We don't warn for RUC
attributes on methods in RUC types, but instead prevent reflection
access from creating these attributes by warning on the reflection
access to methods (including instance methods).

This leaves the attribute warnings for fields as-is - so instance
fields will get attribute warnings unlike instance methods, because we
don't warn on reflection access to instance fields in RUC types. This
is currently inconsistent with the analyzer behavior, which doesn't warn
for attributes in this case.

Commit migrated from dotnet@f3469ca
tlakollo pushed a commit to tlakollo/runtime that referenced this pull request Dec 22, 2022
…nker#3147)

Fixes an analysis hole where reflecting on instance methods of RUC
types produced no warnings. This isn't trim-compatible in case the
methods are decorated with attributes with RUC constructors, or in
case they are invoked on a null instance. We don't warn for RUC
attributes on methods in RUC types, but instead prevent reflection
access from creating these attributes by warning on the reflection
access to methods (including instance methods).

This leaves the attribute warnings for fields as-is - so instance
fields will get attribute warnings unlike instance methods, because we
don't warn on reflection access to instance fields in RUC types. This
is currently inconsistent with the analyzer behavior, which doesn't warn
for attributes in this case.


Commit migrated from dotnet/linker@f3469ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants