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 }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Analyzer - support unknown values for some untracked values #2755
Currently the analyzer only tracks values which are "interesting", which really means System.Type or System.String. Both of these can carry DAM annotations. Everything is not tracked and flows through the system as TopValue which means "empty".
In some cases though, the intrinsic handling works with other types of values, for example integers or arrays. Analyzer has some basic handling of integers mostly around constants and some basic handling of arrays when created locally. But it doesn't track "unknown" values, instead it tracks the rest as "empty" value.
"empty" value means that it will not cause warnings (that's the purpose of the value), unlike "unknown" which typically produces warnings as it represents "can't figure this our statically".
This means that for example code like this:
classMyOwnGeneric<[DAM(All)]T>{}staticvoidMakeMyOwnGeneric(Type[]types){typeof(MyOwnGeneric).MakeGenericType(types);// No warning in the analyzer, linker warns}
In this case analyzer doesn't warn because the parameter to MakeGenericType is "empty" value, and so the entire call is effectively ignored. Linker warns, because it knows that the type has requirements on the generic parameters, and thus if it can't figure out the generic arguments it needs to warn.
classMyOwnGeneric<[DAM(All)]T>{}staticvoidMakeMyOwnGeneric(intlength){vartypes=newType[length];// Since length is unknown the array should be either treated as unknown as a whole, or at least its size should be as suchtypes[0]=typeof(TestType);typeof(MyOwnGeneric).MakeGenericType(types);// No warning in the analyzer, linker warns}
Currently since the length is treated as "empty", the value of the array creation is also "empty" -> no warnings.
Activity
vitek-karas commentedon Apr 22, 2022
Currently since the length is treated as "empty", the value of the array creation is also "empty" -> no warnings.
vitek-karas commentedon Apr 22, 2022
I'm going to add method tracking as well - similar scenario for
MethodInfovalues:Same reason - the untracked value is considered "empty" (unlike linker where it's "unknown").
[-]Analyzer - support unknown values for arrays[/-][+]Analyzer - support unknown values for some untracked values[/+]Trim analyzer: Implement intrinsics handling of object.GetType
Trim analyzer: Implement intrinsics handling of object.GetType (dotne…