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 analyzer doesn't warn on GetType().GetMethods() #86921
One is that we haven't implemented type hierarchy annotations in the analyzer at all yet. That said implementing the object.GetType() is definitely the simple part - implementing full type hierarchy marking diagnostics is much more work. But the two could be done separatly.
Second is that analyzer has a different philosophy to trimmer and ilc. The design is such that if the analyzer doesn't know about something, it will NOT warn about it. Which is the opposite of trimmer and ilc both of which would warn as soon as they hit something they can't reason about. This is intentional to avoid producing warnings from the analyzer which are later on NOT reported by the trimmer/ilc and thus just confusing.
This was very important during analyzer bring up, as we didn't want to produce tons of warnings just because the analyzer didn't implement some specific behavior yet.
This specific case is an example of such case (what if the call is OK, without implementing the logic the analyzer would always warn about it).
Maybe it's about time we change the policy - given that analyzer is almost on par with trimmer now.
That said, there are (and always will be) cases where the analyzer can't produce the same warnings because it doesn't have a full program view. These should be rare, but they will always exist. Hopefully if we switch the policy these cases won't start to show up as extra noise (and only as missing warnings, which there are already quite a few).
Activity
vitek-karas commentedon May 31, 2023
There are two parts to this:
One is that we haven't implemented type hierarchy annotations in the analyzer at all yet. That said implementing the
object.GetType()is definitely the simple part - implementing full type hierarchy marking diagnostics is much more work. But the two could be done separatly.Second is that analyzer has a different philosophy to trimmer and ilc. The design is such that if the analyzer doesn't know about something, it will NOT warn about it. Which is the opposite of trimmer and ilc both of which would warn as soon as they hit something they can't reason about. This is intentional to avoid producing warnings from the analyzer which are later on NOT reported by the trimmer/ilc and thus just confusing.
This was very important during analyzer bring up, as we didn't want to produce tons of warnings just because the analyzer didn't implement some specific behavior yet.
This specific case is an example of such case (what if the call is OK, without implementing the logic the analyzer would always warn about it).
Maybe it's about time we change the policy - given that analyzer is almost on par with trimmer now.
That said, there are (and always will be) cases where the analyzer can't produce the same warnings because it doesn't have a full program view. These should be rare, but they will always exist. Hopefully if we switch the policy these cases won't start to show up as extra noise (and only as missing warnings, which there are already quite a few).
Trim analyzer: Implement intrinsics handling of object.GetType
Trim analyzer: Implement intrinsics handling of object.GetType (#93732)