Fix warning suppressions on types for type hierarchy #2148
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently it's not possible to suppress warnings that originate from types in most cases, because we don't process the suppression attributes until after we've processed the type for type hierarchy related warnings.
#2114 changes the library-mode behavior of type hierarchy marking to apply the DAMT annotation when the type with the annotation is first seen. So far we have been reporting an inconsistent warning origin for these (sometimes the GetType call, sometimes the type - see #2136). But by applying the annotations when the type is first marked, we are now reporting warnings from the type, which is introducing some of the additional warnings in dotnet/runtime#55636 that were previously suppressed on the GetType call.
This change makes it possible to suppress the warnings on the originating type. I don't think it's complete since there might be cases where the type is derived from an attribute type and also has attribute instances of that attribute - which would mark the declaring type before processing type hierarchy annotations. But this workaround should be good enough in the meantime, in case we want to use type-level suppressions to unblock runtime dependency flow.