Skip to content

Type hierarchy merge #2176

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

Closed
wants to merge 14 commits into from
Closed

Type hierarchy merge #2176

wants to merge 14 commits into from

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Jul 28, 2021

This contains the changes from #2145 and #2162. PTAL at the last commit @vitek-karas. Once we have the runtime changes ready I would suggest we merge your change in, then I will rebase my original PR with this change included and we can check it in immediately (that way the repo commit history will be cleaner since the changes are logically separate).

vitek-karas and others added 13 commits July 27, 2021 23:43
Any access to DAM annotated method must be validated by the trimmer. Normal calls and such are handled already, but direct reflection access or other indirect accesses can lead to trimmer allowing potential invocation of DAM annotated method without validating the annotations. This change will warn whenever such potential "leak" happens.

This applies to method parameter, method return value and field annotations.
Uses the same infra as RUC already just adds additional checks.

Tests for the new cases.
Annotated return value is mostly not problematic (the caller only "Reads" from it, which is always safe). The only case where it's problematic is if something would override the method at runtime (ref emit) in which case the trimmer can't validate the new code that it fulfills the return value requirements. But that can only happen if the method is virtual.
Messages for these warnings can not be suppressed at the member  level
due to issues described in dotnet#2163.

Also fix expected warnings for properties, revert ResultChecker changes,
and remove redundant test.
- Include "Attribute" in attribute type names
- Add comments about why we want to report warnings
- Add comment about the interaction with RUC on types
- Clean up some test attributes
- Add test with DAM field on annotated PublicMethods type
- Add link to issue about duplicate warnings

Also use replace DAMT with DAM in tests.
- Don't warn on non-virtual methods that don't have return annotations
- Use the helpers introduced in dotnet#2145
@sbomer sbomer requested a review from marek-safar as a code owner July 28, 2021 00:12
@sbomer sbomer requested a review from vitek-karas July 28, 2021 00:12
Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

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

Looks good

Clarify that getter without annotated return value doesn't warn because
it's non-virtual
@sbomer
Copy link
Member Author

sbomer commented Jul 29, 2021

@vitek-karas here are the updated runtime suppressions: https://github.com/dotnet/runtime/compare/main...sbomer:updateSuppressionsForReflectionAccess?expand=1.

I took a few of them straight from your changes in https://github.com/dotnet/runtime/compare/main...vitek-karas:FixReflectionOnDAMImpact?expand=1 with updated warning codes.

@sbomer sbomer closed this Jul 29, 2021
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.

2 participants