Skip to content

Analyzer - support unknown values for some untracked values #2755

@vitek-karas

Description

@vitek-karas

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:

class MyOwnGeneric<[DAM(All)] T> { }

static void MakeMyOwnGeneric(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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions