Fix dataflow warnings for invalid trim annotations#106672
Merged
sbomer merged 8 commits intodotnet:mainfrom Aug 23, 2024
Merged
Fix dataflow warnings for invalid trim annotations#106672sbomer merged 8 commits intodotnet:mainfrom
sbomer merged 8 commits intodotnet:mainfrom
Conversation
This was referenced Aug 20, 2024
jtschuster
reviewed
Aug 20, 2024
| ReportRequiresUnreferencedCodeDiagnostic (location, requiresUnreferencedCodeAttributeData, fieldSymbol); | ||
|
|
||
| if (fieldSymbol.GetDynamicallyAccessedMemberTypes () != DynamicallyAccessedMemberTypes.None) { | ||
| if (FlowAnnotations.GetFieldAnnotation (fieldSymbol) != DynamicallyAccessedMemberTypes.None) { |
Member
There was a problem hiding this comment.
Should we change most of the uses of ISymbol.GetDynamicallyAccessedMemberTypes() to instead use FlowAnnotations.GetXAnnotation() (except for when we warn on annotations on unsupported types)? Or at least a doc comment on it pointing to the FlowAnnotations for most use cases.
Also, I think we might still have extra warnings about DAM annotation mismatch property definition and accessor, but that can be a separate issue.
Member
Author
There was a problem hiding this comment.
Good catch, I fixed the property/accessor mismatch, and one other case (virtual/override mismatch - this was still calling GetDynamicallyAccessedMemberTypes).
- Add comment - Fix remaining uses of GetDynamicallyAccessedMemberTypes outside of invalid annotation warnings This adds some tests for more cases that are fixed now: - Property definition and accessor mismatch with invalid annotations - Virtual and override mismatch with invalid annotations
jtschuster
approved these changes
Aug 23, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #101211