Skip to content

Fix warning origin for DAM on types #2162

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

Merged
merged 8 commits into from
Jul 29, 2021
Merged

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Jul 23, 2021

Fixes #2136.

The warnings pretty much work as described in #2136 (comment), and the scenario from #2136 (comment) will warn on the derived type. There's still an issue where the member warnings can't be suppressed on the member because we haven't marked custom attributes at that point.

@sbomer sbomer requested a review from marek-safar as a code owner July 23, 2021 00:14
@sbomer
Copy link
Member Author

sbomer commented Jul 23, 2021

I'm not seeing an easy way to fix the suppression issue so I'd like to leave that for a separate change (filed #2163)

@vitek-karas
Copy link
Member

Actually the interaction with RUC go so complex that I just added a design doc (it will be easier to discuss that in its own PR): #2168

@sbomer sbomer force-pushed the typeHierarchyWarnings branch from 6a24687 to 9eb043c Compare July 26, 2021 17:33
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!

@sbomer sbomer force-pushed the typeHierarchyWarnings branch from 2e5ba55 to 15cffe2 Compare July 27, 2021 23:30
@sbomer sbomer mentioned this pull request Jul 28, 2021
sbomer added a commit to sbomer/runtime that referenced this pull request Jul 29, 2021
dotnet/linker#2145 warns when accessing members
annotated with DynamicallyAccessedMembers using reflection, and
dotnet/linker#2162 updates the warning origin of
warnings for DynamicallyAccessedMembers on types.

This adds suppressions for the new warnings.
sbomer added 8 commits July 29, 2021 22:07
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
Clarify that getter without annotated return value doesn't warn because
it's non-virtual
@sbomer sbomer force-pushed the typeHierarchyWarnings branch from 15cffe2 to e08cded Compare July 29, 2021 22:08
@sbomer sbomer merged commit aec70d0 into dotnet:main Jul 29, 2021
sbomer added a commit to dotnet/runtime that referenced this pull request Aug 3, 2021
* Update linker warning suppressions

dotnet/linker#2145 warns when accessing members
annotated with DynamicallyAccessedMembers using reflection, and
dotnet/linker#2162 updates the warning origin of
warnings for DynamicallyAccessedMembers on types.

This adds suppressions for the new warnings.

* Add windows-specific suppressions

* Update dependencies from https://github.com/mono/linker build 20210729.2

Microsoft.NET.ILLink.Tasks
 From Version 6.0.100-preview.6.21378.1 -> To Version 6.0.100-preview.6.21379.2

* Fix failures and address feedback

- Annotate mono's EnumBuilder and TypeBuilder
- Add (non-unique) readable short names to the warning codes

* Update dependencies from https://github.com/mono/linker build 20210730.2

Microsoft.NET.ILLink.Tasks
 From Version 6.0.100-preview.6.21378.1 -> To Version 6.0.100-preview.6.21380.2

* Suppress IL2111

* Update dependencies from https://github.com/mono/linker build 20210802.2

Microsoft.NET.ILLink.Tasks
 From Version 6.0.100-preview.6.21378.1 -> To Version 6.0.100-preview.6.21402.2

* Feedback

- Suppress IL2111 in trimming tests
- Remove unnecessary DynamicDependency
- Fix indentation

* Update readable warning names

Co-authored-by: Sven Boemer <sbomer@gmail.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
* Fix warning origin for DAM on types

* Update tests with link to suppression issue

Messages for these warnings can not be suppressed at the member  level
due to issues described in dotnet/linker#2163.

Also fix expected warnings for properties, revert ResultChecker changes,
and remove redundant test.

* PR feedback

- Include "Attribute" in attribute type names
- Add comments about why we want to report warnings
- Add comment about the interaction with RUC on types

* Add testcase for nested type with default ctor

* PR feedback

- 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.

* Use member-level suppressions in tests

* Unify with behavior for DAM warnings

- Don't warn on non-virtual methods that don't have return annotations
- Use the helpers introduced in dotnet/linker#2145

* PR feedback

Clarify that getter without annotated return value doesn't warn because
it's non-virtual

Commit migrated from dotnet/linker@aec70d0
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.

Unnecessary warnings for DiagnosticSourceEventSource
2 participants