Skip to content

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Jul 27, 2021

Previously attribute suppressions were populated while marking
the attributes. This meant that any suppression checks before the
attributes got marked would not see the suppressions. Doing this
lazily fixes the problem, but may result in scanning the attributes
multiple times.

Fixes #2163
FIxes #2095
Fixes dotnet/runtime#56252

This also fixes an issue where we were not respecting
UnconditionalSuppressMessageAttribute injected via
XML for anything other than assembly/module level attributes.

Previously attribute suppressions were populated while marking
the attributes. This meant that any suppression checks before the
attributes got marked would not see the suppressions. Doing this
lazily fixes the problem, but may result in scanning the attributes
multiple times.

Fixes dotnet#2163
FIxes dotnet#2095

This also fixes an issue where we were not respecting
UnconditionalSuppressMessageAttribute injected via
XML for anything other than assembly/module level attributes.
@sbomer sbomer requested a review from marek-safar as a code owner July 27, 2021 00:54
@sbomer sbomer requested a review from vitek-karas July 27, 2021 00:54
@sbomer sbomer requested a review from mateoatr July 27, 2021 17:23
Copy link
Contributor

@mateoatr mateoatr left a comment

Choose a reason for hiding this comment

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

LGTM!

- Make helper private
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.

Other than the test for dotnet/runtime#56252 this looks good!

@sbomer sbomer merged commit 5c9d308 into dotnet:main Jul 27, 2021
sbomer added a commit to sbomer/linker that referenced this pull request Jul 29, 2021
The change in dotnet#2171 was incorrect
because it didn't account for the possibility that the suppressions
cache already contains assembly or module suppressions for the provider.

This fixes the check by re-using the cache to also track whether we have
scanned for suppression attributes on the provider. This caching is
necessary since we warn about duplicate suppressions.

Providers without any suppressions may still be scanned multiple times
since we don't cache the negative result.
sbomer added a commit that referenced this pull request Aug 11, 2021
* Fix suppression check with assembly suppressions

The change in #2171 was incorrect
because it didn't account for the possibility that the suppressions
cache already contains assembly or module suppressions for the provider.

This fixes the check by re-using the cache to also track whether we have
scanned for suppression attributes on the provider. This caching is
necessary since we warn about duplicate suppressions.

Providers without any suppressions may still be scanned multiple times
since we don't cache the negative result.

* Populate cache eagerly to avoid extra state

Now whenever we add a record to the cache, we ensure that all of the
suppressions that might apply to the member have been discovered.
This way we don't need to track whether we have scanned the suppressed
member, but have to do a bit more work up-front.

* Use private accessibility

For methods only used in
UnconditionalSuppressMessageAttributeState
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
* Check attribute suppressions lazily

Previously attribute suppressions were populated while marking
the attributes. This meant that any suppression checks before the
attributes got marked would not see the suppressions. Doing this
lazily fixes the problem, but may result in scanning the attributes
multiple times.

Fixes dotnet/linker#2163
FIxes dotnet/linker#2095

This also fixes an issue where we were not respecting
UnconditionalSuppressMessageAttribute injected via
XML for anything other than assembly/module level attributes.

* Fix formatting

* PR feedback

- Make helper private

* Add test for compiler generated code in copy assembly

Commit migrated from dotnet/linker@5c9d308
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
* Fix suppression check with assembly suppressions

The change in dotnet/linker#2171 was incorrect
because it didn't account for the possibility that the suppressions
cache already contains assembly or module suppressions for the provider.

This fixes the check by re-using the cache to also track whether we have
scanned for suppression attributes on the provider. This caching is
necessary since we warn about duplicate suppressions.

Providers without any suppressions may still be scanned multiple times
since we don't cache the negative result.

* Populate cache eagerly to avoid extra state

Now whenever we add a record to the cache, we ensure that all of the
suppressions that might apply to the member have been discovered.
This way we don't need to track whether we have scanned the suppressed
member, but have to do a bit more work up-front.

* Use private accessibility

For methods only used in
UnconditionalSuppressMessageAttributeState

Commit migrated from dotnet/linker@5d376b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants