diff options
author | Vitek Karas <vitek.karas@microsoft.com> | 2020-10-13 15:37:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 15:37:35 +0300 |
commit | 2bcc466760c8c5fd08f79eb35ca1e5beb888ae77 (patch) | |
tree | f037f13abcf4dd207c11de808e5658ee6f5c9140 /test/Mono.Linker.Tests.Cases/DataFlow | |
parent | 24c3616ee88623bea1e068605eba15009a8a3043 (diff) |
Test handling of arrays in data flow (#1564)
The test is currently failing due to https://github.com/mono/linker/issues/1559
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/DataFlow')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs b/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs new file mode 100644 index 000000000..e723b6a80 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs @@ -0,0 +1,100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Mono.Linker.Tests.Cases.Expectations.Assertions; + +namespace Mono.Linker.Tests.Cases.DataFlow +{ + [IgnoreTestCase ("Active issue https://github.com/mono/linker/issues/1559")] + public class ComplexTypeHandling + { + public static void Main () + { + TestArray (); + TestArrayOnGeneric (); + TestGenericArray (); + TestGenericArrayOnGeneric (); + } + + [Kept] + class ArrayElementType + { + public ArrayElementType () { } + + [Kept] + public void PublicMethod () { } + + private int _privateField; + } + + [Kept] + static void TestArray () + { + RequirePublicMethods (typeof (ArrayElementType[])); + } + + [Kept] + static void TestGenericArray () + { + RequirePublicMethodsOnArrayOfGeneric<ArrayElementType> (); + } + + [Kept] + static void RequirePublicMethodsOnArrayOfGeneric<T> () + { + RequirePublicMethods (typeof (T[])); + } + + [Kept] + private static void RequirePublicMethods ( + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + [KeptAttributeAttribute(typeof(DynamicallyAccessedMembersAttribute))] + Type type) + { + } + + [Kept] + class ArrayElementInGenericType + { + public ArrayElementInGenericType () { } + + [Kept] + public void PublicMethod () { } + + private int _privateField; + } + + [Kept] + [KeptMember (".ctor()")] + class RequirePublicMethodsGeneric< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] + [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] + T> + { + } + + [Kept] + static void TestArrayOnGeneric () + { + _ = new RequirePublicMethodsGeneric<ArrayElementInGenericType[]> (); + } + + [Kept] + static void TestGenericArrayOnGeneric () + { + RequirePublicMethodsOnArrayOfGenericParameter<ArrayElementInGenericType> (); + } + + static void RequirePublicMethodsOnArrayOfGenericParameter<T> () + { + _ = new RequirePublicMethodsGeneric<T[]> (); + } + } +} |