dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.63k stars 4.56k forks source link

ILLink: Trim analyzer doesn't warn on dataflow through multidimensional array #101951

Open jtschuster opened 2 months ago

jtschuster commented 2 months ago

Analyzer will not warn that an element of a multidimensional array does not satisfy DAM constraints.

ArrayDataFlow.cs: 

// Multidimensional Arrays not handled -- assumed to be UnknownValue
[UnexpectedWarning ("IL2062", nameof (DataFlowTypeExtensions.RequiresPublicMethods), Tool.Trimmer | Tool.NativeAot, "")]
[ExpectedWarning ("IL2062", nameof (DataFlowTypeExtensions.RequiresAll), Tool.Trimmer | Tool.NativeAot, "")]
static void TestArrayWithInitializerOneElementStaticType ()
{
    Type[,] arr = new Type[,] { { typeof (TestType) } };
    arr[0, 0].RequiresAll ();
    arr[0, 1].RequiresPublicMethods (); // Should warn - unknown value at this index
}
dotnet-policy-service[bot] commented 2 months ago

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas See info in area-owners.md if you want to be subscribed.