Skip to content

Enable more ILLinker skipped tests on native AOT #110353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ public void Reflection (string t)
{
switch (t)
{
case "ObjectGetType":
// Skip for now
break;
case "ObjectGetTypeLibraryMode":
case "TypeHierarchyLibraryModeSuppressions":
// No Library mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ class InterfaceSeenFirst
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods)]
interface IAnnotatedInterface
{
[Kept]
[Kept (By = Tool.Trimmer /* The method is not a target of reflection */)]
void InterfaceMethod ();
}

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

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

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

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

Expand Down Expand Up @@ -843,12 +843,12 @@ public static void Test ()
[Kept]
class AllAnnotationsAreApplied
{
[Kept]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
interface IMethodsAnnotatedInterface
{
[Kept]
[Kept (By = Tool.Trimmer)]
void InterfaceMethod ();
}

Expand All @@ -858,14 +858,14 @@ interface IPropertiesAnnotatedInterface
bool Property { get; }
}

[Kept]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicEvents)]
interface IEventsAnnotatedInterface
{
[Kept]
[KeptEventAddMethod]
[KeptEventRemoveMethod]
[Kept(By = Tool.Trimmer)]
[KeptEventAddMethod(By = Tool.Trimmer)]
[KeptEventRemoveMethod(By = Tool.Trimmer)]
event EventHandler MyEvent;
}

Expand Down Expand Up @@ -1037,12 +1037,12 @@ public static void Test ()
[Kept]
class DiamondShapeWithAnnotatedInterface
{
[Kept]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
interface IAnnotatedCommon
{
[Kept] // Due to the annotation
[Kept (By = Tool.Trimmer)] // Due to the annotation
void InterfaceMethod ();
}

Expand Down Expand Up @@ -1158,8 +1158,8 @@ public static void Test ()
[Kept]
class ApplyingAnnotationIntroducesTypesToApplyAnnotationToViaInterfaces
{
[Kept]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[Kept (By = Tool.Trimmer /* The interface is not actually used */)]
[KeptAttributeAttribute (typeof(DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)]
interface IAnnotatedInterface
{
Expand Down Expand Up @@ -1188,7 +1188,7 @@ class FieldTypeAlsoImplementsInterface : IAnnotatedInterface
public NestedFieldType _nestedField;

[Kept]
public class NestedFieldType
public struct NestedFieldType
Copy link
Member Author

@MichalStrehovsky MichalStrehovsky Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native AOT will still try to optimize out the MethodTable of a type even if it's used as the type of a reflection-visible field so this wasn't kept. It is not able to optimize it out if the type of the field is a struct since reflection APIs (FieldInfo.GetValue) will create a default-initialized boxed version when called.

(The test infrastructure is looking for MethodTables, not for type metadata. We would have the metadata only.)

{
}
}
Expand Down Expand Up @@ -1230,11 +1230,11 @@ class DerivedFromMethodsBase : MethodAnnotatedBase
void PrivateMethod () { }
}

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

static void PrivateStaticMethod () { }
Expand All @@ -1248,27 +1248,27 @@ class PropertiesAnnotatedBase
{
}

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

private static UnusedType PrivateProperty { get => null; }
}

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

private static UnusedType PrivateProperty { get => null; }
}

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

class UnusedType { }
Expand Down Expand Up @@ -1343,12 +1343,12 @@ interface INestedInterface
void InterfaceMethod ();
}

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

Expand Down Expand Up @@ -1557,17 +1557,17 @@ class UsedByDerived
{
class AnnotatedBase
{
[Kept]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[Kept (By = Tool.Trimmer /* https://github.com/dotnet/runtime/issues/110563 */)]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
class Base
{
[Kept]
[Kept (By = Tool.Trimmer)]
public void Method () { }
}

[Kept]
[KeptBaseType (typeof (Base))]
[Kept (By = Tool.Trimmer /* https://github.com/dotnet/runtime/issues/110563 */)]
[KeptBaseType (typeof (Base), By = Tool.Trimmer)]
class Derived : Base
{
}
Expand All @@ -1591,9 +1591,9 @@ class Base
public void Method () { }
}

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

Expand Down
Loading