Skip to content

Commit 731a96b

Browse files
Enable more ILLinker skipped tests on native AOT (#110353)
Progress towards #82447.
1 parent ad30479 commit 731a96b

File tree

2 files changed

+44
-47
lines changed

2 files changed

+44
-47
lines changed

src/coreclr/tools/aot/ILCompiler.Trimming.Tests/TestCases/TestSuites.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ public void Reflection (string t)
7171
{
7272
switch (t)
7373
{
74-
case "ObjectGetType":
75-
// Skip for now
76-
break;
7774
case "ObjectGetTypeLibraryMode":
7875
case "TypeHierarchyLibraryModeSuppressions":
7976
// No Library mode

src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/ObjectGetType.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ class InterfaceSeenFirst
694694
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]
695695
interface IAnnotatedInterface
696696
{
697-
[Kept]
697+
[Kept (By = Tool.Trimmer /* The method is not a target of reflection */)]
698698
void InterfaceMethod ();
699699
}
700700

@@ -744,7 +744,7 @@ class AnnotationsRequestedOnImplementation
744744
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]
745745
interface IAnnotatedInterface
746746
{
747-
[Kept] // Kept because it's implemented on the class
747+
[Kept (By = Tool.Trimmer /* The method is not a target of reflection */)] // Kept because it's implemented on the class
748748
void InterfaceMethod ();
749749

750750
// Annotation will not be applied to the interface, since nothing
@@ -797,14 +797,14 @@ class AnnotationsRequestedOnInterface
797797
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]
798798
interface IAnnotatedInterface
799799
{
800-
[Kept] // Kept because it's implemented on the class
800+
[Kept (By = Tool.Trimmer /* The method is not a target of reflection */)] // Kept because it's implemented on the class
801801
void InterfaceMethod ();
802802

803803
// Annotation applied to the interface since that's what reflection asked about
804-
[Kept]
804+
[Kept (By = Tool.Trimmer /* The method is not a target of reflection */)]
805805
static void DoSomething () { }
806806

807-
[Kept]
807+
[Kept (By = Tool.Trimmer /* The method is not a target of reflection */)]
808808
void DefaultInterfaceMethod () { }
809809
}
810810

@@ -843,12 +843,12 @@ public static void Test ()
843843
[Kept]
844844
class AllAnnotationsAreApplied
845845
{
846-
[Kept]
847-
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
846+
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
847+
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
848848
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
849849
interface IMethodsAnnotatedInterface
850850
{
851-
[Kept]
851+
[Kept (By = Tool.Trimmer)]
852852
void InterfaceMethod ();
853853
}
854854

@@ -858,14 +858,14 @@ interface IPropertiesAnnotatedInterface
858858
bool Property { get; }
859859
}
860860

861-
[Kept]
862-
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
861+
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
862+
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
863863
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicEvents)]
864864
interface IEventsAnnotatedInterface
865865
{
866-
[Kept]
867-
[KeptEventAddMethod]
868-
[KeptEventRemoveMethod]
866+
[Kept(By = Tool.Trimmer)]
867+
[KeptEventAddMethod(By = Tool.Trimmer)]
868+
[KeptEventRemoveMethod(By = Tool.Trimmer)]
869869
event EventHandler MyEvent;
870870
}
871871

@@ -1037,12 +1037,12 @@ public static void Test ()
10371037
[Kept]
10381038
class DiamondShapeWithAnnotatedInterface
10391039
{
1040-
[Kept]
1041-
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
1040+
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
1041+
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
10421042
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
10431043
interface IAnnotatedCommon
10441044
{
1045-
[Kept] // Due to the annotation
1045+
[Kept (By = Tool.Trimmer)] // Due to the annotation
10461046
void InterfaceMethod ();
10471047
}
10481048

@@ -1158,8 +1158,8 @@ public static void Test ()
11581158
[Kept]
11591159
class ApplyingAnnotationIntroducesTypesToApplyAnnotationToViaInterfaces
11601160
{
1161-
[Kept]
1162-
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
1161+
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
1162+
[KeptAttributeAttribute (typeof(DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
11631163
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)]
11641164
interface IAnnotatedInterface
11651165
{
@@ -1188,7 +1188,7 @@ class FieldTypeAlsoImplementsInterface : IAnnotatedInterface
11881188
public NestedFieldType _nestedField;
11891189

11901190
[Kept]
1191-
public class NestedFieldType
1191+
public struct NestedFieldType
11921192
{
11931193
}
11941194
}
@@ -1230,11 +1230,11 @@ class DerivedFromMethodsBase : MethodAnnotatedBase
12301230
void PrivateMethod () { }
12311231
}
12321232

1233-
[Kept]
1234-
[KeptBaseType (typeof (MethodAnnotatedBase))]
1233+
[Kept(By = Tool.Trimmer /* only used in a method signature, not legitimate to keep beyond IL-level trimming */)]
1234+
[KeptBaseType (typeof (MethodAnnotatedBase), By = Tool.Trimmer)]
12351235
class AnotherMethodsDerived : MethodAnnotatedBase
12361236
{
1237-
[Kept]
1237+
[Kept(By = Tool.Trimmer)]
12381238
public static void PublicStaticMethod (DerivedFromPropertiesBase p) { }
12391239

12401240
static void PrivateStaticMethod () { }
@@ -1248,27 +1248,27 @@ class PropertiesAnnotatedBase
12481248
{
12491249
}
12501250

1251-
[Kept]
1252-
[KeptBaseType (typeof (PropertiesAnnotatedBase))]
1251+
[Kept (By = Tool.Trimmer /* only used in a method signature, not legitimate to keep beyond IL-level trimming */)]
1252+
[KeptBaseType (typeof (PropertiesAnnotatedBase), By = Tool.Trimmer)]
12531253
class DerivedFromPropertiesBase : PropertiesAnnotatedBase
12541254
{
1255-
[Kept]
1256-
public static AnotherPropertiesDerived PublicProperty { [Kept] get => null; }
1255+
[Kept (By = Tool.Trimmer)]
1256+
public static AnotherPropertiesDerived PublicProperty { [Kept (By = Tool.Trimmer)] get => null; }
12571257

12581258
private static UnusedType PrivateProperty { get => null; }
12591259
}
12601260

1261-
[Kept]
1262-
[KeptBaseType (typeof (PropertiesAnnotatedBase))]
1261+
[Kept (By = Tool.Trimmer /* only used in a method signature, not legitimate to keep beyond IL-level trimming */)]
1262+
[KeptBaseType (typeof (PropertiesAnnotatedBase), By = Tool.Trimmer)]
12631263
class AnotherPropertiesDerived : PropertiesAnnotatedBase
12641264
{
1265-
[Kept]
1266-
public static UsedType PublicProperty { [Kept] get => null; }
1265+
[Kept(By = Tool.Trimmer)]
1266+
public static UsedType PublicProperty { [Kept(By = Tool.Trimmer)] get => null; }
12671267

12681268
private static UnusedType PrivateProperty { get => null; }
12691269
}
12701270

1271-
[Kept]
1271+
[Kept (By = Tool.Trimmer /* only used in a method signature, not legitimate to keep beyond IL-level trimming */)]
12721272
class UsedType { }
12731273

12741274
class UnusedType { }
@@ -1343,12 +1343,12 @@ interface INestedInterface
13431343
void InterfaceMethod ();
13441344
}
13451345

1346-
[Kept]
1347-
[KeptMember (".ctor()")]
1348-
[KeptBaseType (typeof (AnnotatedBase))]
1346+
[Kept (By = Tool.Trimmer /* only used in a method signature, not legitimate to keep beyond IL-level trimming */)]
1347+
[KeptMember (".ctor()", By = Tool.Trimmer)]
1348+
[KeptBaseType (typeof (AnnotatedBase), By = Tool.Trimmer)]
13491349
class AnotherAnnotatedType : AnnotatedBase
13501350
{
1351-
[Kept]
1351+
[Kept (By = Tool.Trimmer)]
13521352
int _field;
13531353
}
13541354

@@ -1557,17 +1557,17 @@ class UsedByDerived
15571557
{
15581558
class AnnotatedBase
15591559
{
1560-
[Kept]
1561-
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
1560+
[Kept (By = Tool.Trimmer /* https://github.com/dotnet/runtime/issues/110563 */)]
1561+
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
15621562
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
15631563
class Base
15641564
{
1565-
[Kept]
1565+
[Kept (By = Tool.Trimmer)]
15661566
public void Method () { }
15671567
}
15681568

1569-
[Kept]
1570-
[KeptBaseType (typeof (Base))]
1569+
[Kept (By = Tool.Trimmer /* https://github.com/dotnet/runtime/issues/110563 */)]
1570+
[KeptBaseType (typeof (Base), By = Tool.Trimmer)]
15711571
class Derived : Base
15721572
{
15731573
}
@@ -1591,9 +1591,9 @@ class Base
15911591
public void Method () { }
15921592
}
15931593

1594-
[Kept]
1595-
[KeptBaseType (typeof (Base))]
1596-
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
1594+
[Kept (By = Tool.Trimmer /* The object.GetType() call is statically unreachable, this could be trimmed */)]
1595+
[KeptBaseType (typeof (Base), By = Tool.Trimmer)]
1596+
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
15971597
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
15981598
class Derived : Base
15991599
{
@@ -1616,7 +1616,7 @@ class AnnotatedInterface
16161616
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)]
16171617
interface IBase
16181618
{
1619-
[Kept]
1619+
[Kept (By = Tool.Trimmer /* https://github.com/dotnet/runtime/issues/104740 */)]
16201620
public void Method () { }
16211621
}
16221622

0 commit comments

Comments
 (0)