You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Trim analysis doesn't understand receiver type for calls to GetType() #100786
DynamicallyAccessedMembers annotations on a type will treat the return value of GetType as satisfying the annotation, for a call to this.GetType(), but not for a call to c.GetType() where c is assignable to the annotated type.
This causes a warning on the call to Require(c.GetType()) in the sample below. It's possible to work around this by defining an annotated helper on the type that just returns this.GetType(), but this ideally wouldn't be necessary:
This is basically the same issue as #93720, also combined with the fact that trimmer doesn't track return values of new (as in it doesn't know the static type of it, although it could) - there's another bug for that one, but I can't find it now.
The current state of the comments on the other issue is that typed stack would fix this for the declared variable type. It would not fix the new issue though.
Activity
dotnet-policy-service commentedon Apr 8, 2024
Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.
vitek-karas commentedon Apr 8, 2024
This is basically the same issue as #93720, also combined with the fact that trimmer doesn't track return values of
new(as in it doesn't know the static type of it, although it could) - there's another bug for that one, but I can't find it now.The current state of the comments on the other issue is that typed stack would fix this for the declared variable type. It would not fix the
newissue though.sbomer commentedon Apr 8, 2024
Thanks, I thought there was some discussion but was having trouble finding an existing issue. Closing this as a duplicate of #93720.
sbomer commentedon Apr 8, 2024
Dup of #93720
Fix TableLayoutSettings.StyleConverter trim warnings (#11176)