From f39ba1a20374ac6af0f2a866a7381192d28b8c37 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Thu, 3 Jun 2021 20:37:55 +0600 Subject: Handle different dynamic member access for multiple branches (#2076) This case assume that all code branches should have same minimal dynamic access pattern Was discovered as part of https://github.com/dotnet/runtimelab/issues/1187 Issue happens when 2 code blocks has diferent requirements for dynamic code access, and this produce MergePoint. This case was not handled. --- test/Mono.Linker.Tests.Cases/DataFlow/GetInterfaceDataFlow.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/Mono.Linker.Tests.Cases/DataFlow') diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/GetInterfaceDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/GetInterfaceDataFlow.cs index 630fc3c14..4a9d8c39f 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/GetInterfaceDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/GetInterfaceDataFlow.cs @@ -66,6 +66,16 @@ namespace Mono.Linker.Tests.Cases.DataFlow type.GetInterface ("ITestInterface").RequiresAll (); // Warns since only one of the values is guaranteed All } + [ExpectedWarning ("IL2075", nameof (DynamicallyAccessedMemberTypes) + "." + nameof (DynamicallyAccessedMemberTypes.Interfaces))] + static void TestMergedValues (int p, [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] Type typeWithAll) + { + Type type = new TestType ().GetType (); + if (p == 0) { + type = typeWithAll; + type.GetInterface ("ITestInterface").RequiresInterfaces (); + } + } + public static void Test () { TestNoAnnotation (typeof (TestType)); @@ -74,6 +84,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow TestWithAll (typeof (TestType)); TestKnownType (); TestMultipleValues (0, typeof (TestType)); + TestMergedValues (0, typeof (TestType)); } } -- cgit v1.2.3