Skip to content

Commit

Permalink
Test handling of arrays in data flow (dotnet/linker#1564)
Browse files Browse the repository at this point in the history
The test is currently failing due to dotnet/linker#1559


Commit migrated from dotnet/linker@2bcc466
  • Loading branch information
vitek-karas committed Oct 13, 2020
1 parent 3dd2215 commit e574052
Showing 1 changed file with 100 additions and 0 deletions.
@@ -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[]> ();
}
}
}

0 comments on commit e574052

Please sign in to comment.