dotnet / dotnet/linker

DAM warnings are produced twice in properties/events

Open
#2,462 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

Consider the following scenario:
```C#
class AnnotatedProperty
{
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicNestedTypes)]
public static Type PropertyWithAnnotation { get; set; }
}
```
The expectation is that calling `typeof (AnnotatedProperty).GetProperty (nameof (PropertyWithAnnotation));` will generate a warning in the setter method because properties look at their methods to produce warnings
Similarly calling `typeof (AnnotatedProperty).GetMethod ("set_" + nameof (PropertyWithAnnotation));` will generate a warning because methods will look if they have an annotation and additionally they will look at the associated property/event to produce warnings
Now if the method being called has both Properties and Methods kept we will do the analysis for both of the cases generating two warnings in the same place for the same annotation. This happens in several tests but is masked due to the fact that one ExpectedWarning in linker silence all the occurrences of the warning.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.