Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Boemer <sbomer@gmail.com>2021-08-10 20:10:20 +0300
committerGitHub <noreply@github.com>2021-08-10 20:10:20 +0300
commitd8b94bd244f9239ef394817e2bd9a37ec1bae838 (patch)
tree0d74ea5c59ba7f18c121b60eb530d4f7a41cc156 /test/Mono.Linker.Tests.Cases
parente21bb44ca909d33c18acf3ed0b68f94a413351a5 (diff)
Fix warnings for DAM.All (#2191)
* Fix warnings for DAM.All Fixes https://github.com/mono/linker/issues/2159 * Add tests * PR feedback - Remove unnecessary helper * Avoid redundant DAM warnings for base members * PR feedback - Resolve -> TryResolve - Avoid nested yield returns - Testcases with base instantiated over self for generic parameter with requirements
Diffstat (limited to 'test/Mono.Linker.Tests.Cases')
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/AnnotatedMembersAccessedViaReflection.cs97
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs20
-rw-r--r--test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMemberTypes.cs15
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs178
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchySuppressions.cs11
5 files changed, 240 insertions, 81 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/AnnotatedMembersAccessedViaReflection.cs b/test/Mono.Linker.Tests.Cases/DataFlow/AnnotatedMembersAccessedViaReflection.cs
index f94b9a458..4b626431f 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/AnnotatedMembersAccessedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/AnnotatedMembersAccessedViaReflection.cs
@@ -84,6 +84,38 @@ namespace Mono.Linker.Tests.Cases.DataFlow
typeof (AnnotatedField).RequiresPublicFields ();
}
+ class NestedType
+ {
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ public static Type _annotatedField;
+ }
+
+ [ExpectedWarning ("IL2110", nameof (_annotatedField))]
+ [ExpectedWarning ("IL2026", "test")]
+ static void DynamicallyAccessedMembersAll1 ()
+ {
+ typeof (AnnotatedField).RequiresAll ();
+ }
+
+ [ExpectedWarning ("IL2110", nameof (_annotatedField))]
+ [ExpectedWarning ("IL2026", "test")]
+ static void DynamicallyAccessedMembersAll2 ()
+ {
+ typeof (AnnotatedField).RequiresAll ();
+ }
+
+ [ExpectedWarning ("IL2110", nameof (NestedType), nameof (NestedType._annotatedField))]
+ static void DynamicallyAccessedMembersNestedTypes1 ()
+ {
+ typeof (AnnotatedField).RequiresNonPublicNestedTypes ();
+ }
+
+ [ExpectedWarning ("IL2110", nameof (NestedType), nameof (NestedType._annotatedField))]
+ static void DynamicallyAccessedMembersNestedTypes2 ()
+ {
+ typeof (AnnotatedField).RequiresNonPublicNestedTypes ();
+ }
+
[UnconditionalSuppressMessage ("test", "IL2026")]
public static void Test ()
{
@@ -95,6 +127,10 @@ namespace Mono.Linker.Tests.Cases.DataFlow
DynamicDependencyByName ();
DynamicallyAccessedMembers ();
DynamicallyAccessedMembersSuppressedByRUC ();
+ DynamicallyAccessedMembersAll1 ();
+ DynamicallyAccessedMembersAll2 ();
+ DynamicallyAccessedMembersNestedTypes1 ();
+ DynamicallyAccessedMembersNestedTypes2 ();
}
}
@@ -177,6 +213,22 @@ namespace Mono.Linker.Tests.Cases.DataFlow
var _ = new Action<Type> (instance.AnnotatedMethod);
}
+ [ExpectedWarning ("IL2111", nameof (MethodWithSingleAnnotatedParameter))]
+ [ExpectedWarning ("IL2026", "test")]
+ [ExpectedWarning ("IL2111", nameof (IWithAnnotatedMethod.AnnotatedMethod))]
+ static void DynamicallyAccessedMembersAll1 ()
+ {
+ typeof (AnnotatedMethodParameters).RequiresAll ();
+ }
+
+ [ExpectedWarning ("IL2111", nameof (MethodWithSingleAnnotatedParameter))]
+ [ExpectedWarning ("IL2026", "test")]
+ [ExpectedWarning ("IL2111", nameof (IWithAnnotatedMethod.AnnotatedMethod))]
+ static void DynamicallyAccessedMembersAll2 ()
+ {
+ typeof (AnnotatedMethodParameters).RequiresAll ();
+ }
+
[UnconditionalSuppressMessage ("test", "IL2026")]
public static void Test ()
{
@@ -189,6 +241,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
DynamicallyAccessedMembersSuppressedByRUC ();
Ldftn ();
Ldvirtftn ();
+ DynamicallyAccessedMembersAll1 ();
+ DynamicallyAccessedMembersAll2 ();
}
}
@@ -395,6 +449,24 @@ namespace Mono.Linker.Tests.Cases.DataFlow
typeof (AnnotatedProperty).RequiresPublicProperties ();
}
+ [ExpectedWarning ("IL2111", nameof (PropertyWithAnnotation) + ".set")]
+ [ExpectedWarning ("IL2026", "test")]
+ [ExpectedWarning ("IL2111", nameof (VirtualPropertyWithAnnotationGetterOnly) + ".get")]
+ [UnconditionalSuppressMessage ("Test", "IL2110", Justification = "Suppress warning about backing field of PropertyWithAnnotation")]
+ static void DynamicallyAccessedMembersAll1 ()
+ {
+ typeof (AnnotatedProperty).RequiresAll ();
+ }
+
+ [ExpectedWarning ("IL2111", nameof (PropertyWithAnnotation) + ".set")]
+ [ExpectedWarning ("IL2026", "test")]
+ [ExpectedWarning ("IL2111", nameof (VirtualPropertyWithAnnotationGetterOnly) + ".get")]
+ [UnconditionalSuppressMessage ("Test", "IL2110", Justification = "Suppress warning about backing field of PropertyWithAnnotation")]
+ static void DynamicallyAccessedMembersAll2 ()
+ {
+ typeof (AnnotatedProperty).RequiresAll ();
+ }
+
[UnconditionalSuppressMessage ("test", "IL2026")]
public static void Test ()
{
@@ -410,6 +482,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
DynamicDependencySuppressedByRUC ();
DynamicallyAccessedMembers ();
DynamicallyAccessedMembersSuppressedByRUC ();
+ DynamicallyAccessedMembersAll1 ();
+ DynamicallyAccessedMembersAll2 ();
}
}
@@ -446,12 +520,19 @@ namespace Mono.Linker.Tests.Cases.DataFlow
typeof (AnnotatedGenerics).GetMethod (nameof (GenericWithAnnotation)).MakeGenericMethod (type);
}
+ // Like above, no warning expected
+ static void DynamicallyAccessedMembersAll ()
+ {
+ typeof (AnnotatedGenerics).RequiresAll ();
+ }
+
public static void Test ()
{
ReflectionOnly ();
DynamicDependency ();
DynamicallyAccessedMembers ();
InstantiateGeneric ();
+ DynamicallyAccessedMembersAll ();
}
}
@@ -499,6 +580,20 @@ namespace Mono.Linker.Tests.Cases.DataFlow
typeof (AnnotationOnGenerics).RequiresPublicMethods ();
}
+ [ExpectedWarning ("IL2111", nameof (GenericMethodWithAnnotation))]
+ [ExpectedWarning ("IL2111", "GenericWithAnnotatedMethod", "AnnotatedMethod")]
+ static void DynamicallyAccessedMembersAll1 ()
+ {
+ typeof (AnnotationOnGenerics).RequiresAll ();
+ }
+
+ [ExpectedWarning ("IL2111", nameof (GenericMethodWithAnnotation))]
+ [ExpectedWarning ("IL2111", "GenericWithAnnotatedMethod", "AnnotatedMethod")]
+ static void DynamicallyAccessedMembersAll2 ()
+ {
+ typeof (AnnotationOnGenerics).RequiresAll ();
+ }
+
public static void Test ()
{
GenericTypeWithStaticMethodViaLdftn ();
@@ -506,6 +601,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
GenericMethodWithAnnotationDirectCall ();
GenericMethodWithAnnotationViaLdftn ();
GenericMethodDynamicallyAccessedMembers ();
+ DynamicallyAccessedMembersAll1 ();
+ DynamicallyAccessedMembersAll2 ();
}
}
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs
index 09de0a015..1665c1abd 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs
@@ -243,6 +243,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
static void TestBaseTypeGenericRequirements ()
{
new DerivedTypeWithInstantiatedGenericOnBase ();
+ new DerivedTypeWithInstantiationOverSelfOnBase ();
new DerivedTypeWithOpenGenericOnBase<TestType> ();
new DerivedTypeWithOpenGenericOnBaseWithRequirements<TestType> ();
}
@@ -261,6 +262,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
+ class GenericBaseTypeWithRequiresAll<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] T>
+ {
+ }
+
+ [RecognizedReflectionAccessPattern]
+ class DerivedTypeWithInstantiationOverSelfOnBase : GenericBaseTypeWithRequirements<DerivedTypeWithInstantiationOverSelfOnBase>
+ {
+ }
+
[UnrecognizedReflectionAccessPattern (typeof (GenericBaseTypeWithRequirements<>), "T", messageCode: "IL2091")]
class DerivedTypeWithOpenGenericOnBase<T> : GenericBaseTypeWithRequirements<T>
{
@@ -277,6 +287,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
static void TestInterfaceTypeGenericRequirements ()
{
IGenericInterfaceTypeWithRequirements<TestType> instance = new InterfaceImplementationTypeWithInstantiatedGenericOnBase ();
+ new InterfaceImplementationTypeWithInstantiationOverSelfOnBase ();
new InterfaceImplementationTypeWithOpenGenericOnBase<TestType> ();
new InterfaceImplementationTypeWithOpenGenericOnBaseWithRequirements<TestType> ();
}
@@ -290,6 +301,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
+ interface IGenericInterfaceTypeWithRequiresAll<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] T>
+ {
+ }
+
+ [RecognizedReflectionAccessPattern]
+ class InterfaceImplementationTypeWithInstantiationOverSelfOnBase : IGenericInterfaceTypeWithRequiresAll<InterfaceImplementationTypeWithInstantiationOverSelfOnBase>
+ {
+ }
+
[UnrecognizedReflectionAccessPattern (typeof (IGenericInterfaceTypeWithRequirements<>), "T", messageCode: "IL2091")]
class InterfaceImplementationTypeWithOpenGenericOnBase<T> : IGenericInterfaceTypeWithRequirements<T>
{
diff --git a/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMemberTypes.cs b/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMemberTypes.cs
index f4bfca071..5ba9d6c25 100644
--- a/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMemberTypes.cs
+++ b/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMemberTypes.cs
@@ -119,12 +119,17 @@ namespace Mono.Linker.Tests.Cases.DynamicDependencies
class TypeWithPublicNestedType
{
[Kept]
+ [KeptMember (".ctor()")]
public class PublicNestedType
{
+ [Kept]
public void Method () { }
+ [Kept]
public int field;
-
+ [Kept]
void NonPublicMethod () { }
+ [Kept]
+ static class EmptyInnerNestedType { }
}
public void Method () { }
@@ -139,6 +144,8 @@ namespace Mono.Linker.Tests.Cases.DynamicDependencies
[KeptBaseType (typeof (MulticastDelegate))]
[KeptMember (".ctor(System.Object,System.IntPtr)")]
[KeptMember ("Invoke()")]
+ [KeptMember ("BeginInvoke(System.AsyncCallback,System.Object)")]
+ [KeptMember ("EndInvoke(System.IAsyncResult)")]
public delegate int PublicDelegate ();
private delegate int PrivateDelegate ();
@@ -148,12 +155,16 @@ namespace Mono.Linker.Tests.Cases.DynamicDependencies
class TypeWithNonPublicNestedType
{
[Kept]
+ [KeptMember (".ctor()")]
class NonPublicNestedType
{
+ [Kept]
public void Method () { }
+ [Kept]
public int field;
+ [Kept]
void NonPublicMethod () { }
}
@@ -171,6 +182,8 @@ namespace Mono.Linker.Tests.Cases.DynamicDependencies
[KeptBaseType (typeof (MulticastDelegate))]
[KeptMember (".ctor(System.Object,System.IntPtr)")]
[KeptMember ("Invoke()")]
+ [KeptMember ("BeginInvoke(System.AsyncCallback,System.Object)")]
+ [KeptMember ("EndInvoke(System.IAsyncResult)")]
private delegate int PrivateDelegate ();
}
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs b/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs
index 3cbdf4b0e..5bd06a7e7 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs
@@ -17,20 +17,27 @@ namespace Mono.Linker.Tests.Cases.Reflection
{
public static void Main ()
{
- RequirePublicMethods (annotatedBase.GetType ());
+ annotatedBase.GetType ().RequiresPublicMethods ();
+ var baseType = annotatedBaseSharedByNestedTypes.GetType ();
+ baseType.RequiresPublicNestedTypes ();
+ baseType.RequiresPublicMethods ();
+ var derivedType = typeof (DerivedWithNestedTypes);
// Reference to the derived type should apply base annotations
- var t = typeof (DerivedFromAnnotatedBase);
- RequirePublicMethods (annotatedDerivedFromBase.GetType ());
- RequirePublicNestedTypes (annotatedPublicNestedTypes.GetType ());
- RequirePublicFields (derivedFromAnnotatedDerivedFromBase.GetType ());
- RequirePublicMethods (annotatedPublicMethods.GetType ());
- RequirePublicFields (annotatedPublicFields.GetType ());
- RequirePublicProperties (annotatedPublicProperties.GetType ());
- RequirePublicEvents (annotatedPublicEvents.GetType ());
- RequirePublicNestedTypes (annotatedPublicNestedTypes.GetType ());
- RequireInterfaces (annotatedInterfaces.GetType ());
- RequireAll (annotatedAll.GetType ());
- RequirePublicMethods (annotatedRUCPublicMethods.GetType ());
+ var t1 = typeof (DerivedFromAnnotatedBase);
+ var t2 = typeof (AnnotatedDerivedFromAnnotatedBase);
+ annotatedDerivedFromBase.GetType ().RequiresPublicMethods ();
+ annotatedPublicNestedTypes.GetType ().RequiresPublicNestedTypes ();
+ derivedFromAnnotatedDerivedFromBase.GetType ().RequiresPublicFields ();
+ annotatedPublicMethods.GetType ().RequiresPublicMethods ();
+ annotatedPublicFields.GetType ().RequiresPublicFields ();
+ annotatedPublicProperties.GetType ().RequiresPublicProperties ();
+ annotatedPublicEvents.GetType ().RequiresPublicEvents ();
+ annotatedPublicNestedTypes.GetType ().RequiresPublicNestedTypes ();
+ annotatedInterfaces.GetType ().RequiresInterfaces ();
+ annotatedAll.GetType ().RequiresAll ();
+ var t3 = typeof (DerivedFromAnnotatedAll1);
+ var t4 = typeof (DerivedFromAnnotatedAll2);
+ annotatedRUCPublicMethods.GetType ().RequiresPublicMethods ();
// Instantiate this type just so its property getters are considered reachable
var b = new DerivedFromAnnotatedDerivedFromBase ();
@@ -55,6 +62,8 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
static AnnotatedBase annotatedBase;
[Kept]
+ static AnnotatedBaseSharedByNestedTypes annotatedBaseSharedByNestedTypes;
+ [Kept]
static AnnotatedDerivedFromBase annotatedDerivedFromBase;
[Kept]
static AnnotatedPublicNestedTypes annotatedPublicNestedTypes;
@@ -92,6 +101,20 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ [KeptMember (".ctor()")]
+ [KeptBaseType (typeof (AnnotatedAll))]
+ class DerivedFromAnnotatedAll1 : AnnotatedAll
+ {
+ }
+
+ [Kept]
+ [KeptMember (".ctor()")]
+ [KeptBaseType (typeof (AnnotatedAll))]
+ class DerivedFromAnnotatedAll2 : AnnotatedAll
+ {
+ }
+
+ [Kept]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
class AnnotatedPublicMethods
@@ -236,11 +259,14 @@ namespace Mono.Linker.Tests.Cases.Reflection
[ExpectedWarning ("IL2112", "--RUC on AnnotatedBase--")]
[RequiresUnreferencedCode ("--RUC on AnnotatedBase--")]
public void RUCMethod () { }
+
+ [Kept]
+ [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicMethods)]
+ public string DAMField1;
}
[KeptBaseType (typeof (AnnotatedBase))]
- // Warning about base member could go away with https://github.com/mono/linker/issues/2175
- [ExpectedWarning ("IL2113", "--RUC on AnnotatedBase--")]
class DerivedFromAnnotatedBase : AnnotatedBase
{
[Kept]
@@ -250,6 +276,29 @@ namespace Mono.Linker.Tests.Cases.Reflection
public void RUCMethod () { }
}
+ [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
+ [KeptBaseType (typeof (AnnotatedBase))]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields)]
+ // In theory we could avoid warning for public methods on base types because that
+ // annotation is already inherited from the base type, but currently we warn on base
+ // members whenever a type has an explicit annotation.
+ [ExpectedWarning ("IL2113", nameof (AnnotatedBase), nameof (AnnotatedBase.RUCMethod))]
+ [ExpectedWarning ("IL2115", nameof (AnnotatedBase), nameof (AnnotatedBase.DAMField1))]
+ class AnnotatedDerivedFromAnnotatedBase : AnnotatedBase
+ {
+ [Kept]
+ [KeptAttributeAttribute (typeof (RequiresUnreferencedCodeAttribute))]
+ [ExpectedWarning ("IL2112", "--RUC on AnnotatedDerivedFromAnnotatedBase--")]
+ [RequiresUnreferencedCode ("--RUC on AnnotatedDerivedFromAnnotatedBase--")]
+ public void DerivedRUCMethod () { }
+
+ [Kept]
+ [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
+ [ExpectedWarning ("IL2114", nameof (AnnotatedDerivedFromAnnotatedBase), nameof (DAMField2))]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicMethods)]
+ public string DAMField2;
+ }
+
[KeptMember (".ctor()")]
class Base
{
@@ -314,13 +363,11 @@ namespace Mono.Linker.Tests.Cases.Reflection
[KeptMember (".ctor()")]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)]
- // Warnings about base members could go away with https://github.com/mono/linker/issues/2175
+ // The annotation from this type should warn about all public fields including those
+ // from base types, but the inherited PublicMethods annotation should not warn
+ // again about base methods.
[ExpectedWarning ("IL2115", nameof (Base), nameof (DAMField1))]
[ExpectedWarning ("IL2115", nameof (AnnotatedDerivedFromBase), nameof (DAMField2))]
- [ExpectedWarning ("IL2113", "--RUCBaseMethod--")]
- [ExpectedWarning ("IL2113", "--Base.RUCVirtualMethod--")]
- [ExpectedWarning ("IL2113", "--RUC on AnnotatedDerivedFromBase--")]
- [ExpectedWarning ("IL2115", nameof (Base), nameof (Base.DAMVirtualProperty) + ".get")]
class DerivedFromAnnotatedDerivedFromBase : AnnotatedDerivedFromBase
{
[Kept]
@@ -349,8 +396,19 @@ namespace Mono.Linker.Tests.Cases.Reflection
public override string DAMVirtualProperty { [Kept] get; }
}
+ [KeptMember (".ctor()")]
+ public class BaseTypeOfNestedType
+ {
+ [Kept]
+ [KeptAttributeAttribute (typeof (RequiresUnreferencedCodeAttribute))]
+ [RequiresUnreferencedCode ("--RUC on BaseTypeOfNestedType.RUCMethod--")]
+ public void RUCMethod () { }
+ }
+
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicNestedTypes)]
+ // Warnings about base types of nested types are shown at the (outer) type level.
+ [ExpectedWarning ("IL2113", nameof (BaseTypeOfNestedType), nameof (BaseTypeOfNestedType.RUCMethod))]
class AnnotatedPublicNestedTypes
{
[KeptMember (".ctor()")]
@@ -364,6 +422,12 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[KeptMember (".ctor()")]
+ [KeptBaseType (typeof (BaseTypeOfNestedType))]
+ public class NestedTypeWithBase : BaseTypeOfNestedType
+ {
+ }
+
+ [KeptMember (".ctor()")]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
public class NestedAnnotatedType
@@ -407,6 +471,31 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
}
+ [KeptMember (".ctor()")]
+ [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicNestedTypes)]
+ class AnnotatedBaseSharedByNestedTypes
+ {
+ [Kept]
+ [KeptAttributeAttribute (typeof (RequiresUnreferencedCodeAttribute))]
+ [ExpectedWarning ("IL2112", "--RUC on AnnotatedBaseSharedByNestedTypes.RUCMethod--")]
+ [RequiresUnreferencedCode ("--RUC on AnnotatedBaseSharedByNestedTypes.RUCMethod--")]
+ public void RUCMethod () { }
+ }
+
+ [KeptBaseType (typeof (AnnotatedBaseSharedByNestedTypes))]
+ // Nested types that share the outer class base type can produce warnings about base methods of the annotated type.
+ [ExpectedWarning ("IL2113", "--RUC on AnnotatedBaseSharedByNestedTypes.RUCMethod--")]
+ class DerivedWithNestedTypes : AnnotatedBaseSharedByNestedTypes
+ {
+
+ [KeptMember (".ctor()")]
+ [KeptBaseType (typeof (AnnotatedBaseSharedByNestedTypes))]
+ public class NestedType : AnnotatedBaseSharedByNestedTypes
+ {
+ }
+ }
+
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[KeptAttributeAttribute (typeof (RequiresUnreferencedCodeAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
@@ -428,54 +517,5 @@ namespace Mono.Linker.Tests.Cases.Reflection
[ExpectedWarning ("IL2112", "--AnnotatedRUCPublicMethods--")]
public static void StaticMethod () { }
}
-
- [Kept]
- static void RequirePublicMethods (
- [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
- Type type)
- { }
-
- [Kept]
- static void RequirePublicFields (
- [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)]
- Type type)
- { }
-
- [Kept]
- static void RequirePublicProperties (
- [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)]
- Type type)
- { }
-
- [Kept]
- static void RequirePublicEvents (
- [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicEvents)]
- Type type)
- { }
-
- [Kept]
- static void RequireAll (
- [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)]
- Type type)
- { }
-
- [Kept]
- static void RequirePublicNestedTypes (
- [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicNestedTypes)]
- Type type)
- { }
-
- [Kept]
- static void RequireInterfaces (
- [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.Interfaces)]
- Type type)
- { }
}
}
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchySuppressions.cs b/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchySuppressions.cs
index fe9a44c3b..7318f1faf 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchySuppressions.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchySuppressions.cs
@@ -79,7 +79,6 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[KeptBaseType (typeof (Unsuppressed))]
- [ExpectedWarning ("IL2113", "--RUC on Unsuppressed--")]
class DerivedFromUnsuppressed1 : Unsuppressed
{
[Kept]
@@ -91,7 +90,6 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[KeptBaseType (typeof (Unsuppressed))]
- [ExpectedWarning ("IL2113", "--RUC on Unsuppressed--")]
class DerivedFromUnsuppressed2 : Unsuppressed
{
[Kept]
@@ -116,8 +114,6 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[KeptBaseType (typeof (Suppressed))]
- // Base method should warn even though it was suppressed on the base
- [ExpectedWarning ("IL2113", "--RUC on Suppressed--")]
class DerivedFromSuppressed1 : Suppressed
{
[Kept]
@@ -129,8 +125,6 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[KeptBaseType (typeof (Suppressed))]
- // Base method should warn even though it was suppressed on the base
- [ExpectedWarning ("IL2113", "--RUC on Suppressed--")]
class DerivedFromSuppressed2 : Suppressed
{
[Kept]
@@ -142,7 +136,6 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[KeptBaseType (typeof (Unsuppressed))]
- [ExpectedWarning ("IL2113", "--RUC on Unsuppressed--")]
class SuppressedOnDerived1 : Unsuppressed
{
[Kept]
@@ -155,7 +148,6 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[KeptBaseType (typeof (Unsuppressed))]
- [ExpectedWarning ("IL2113", "--RUC on Unsuppressed--")]
class SuppressedOnDerived2 : Unsuppressed
{
[Kept]
@@ -168,9 +160,6 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[KeptBaseType (typeof (Unsuppressed))]
- [KeptAttributeAttribute (typeof (UnconditionalSuppressMessageAttribute))]
- // Suppress warnings about base members
- [UnconditionalSuppressMessage ("TrimAnalysis", "IL2113")]
class SuppressedBaseWarningsOnDerived : Unsuppressed
{
[Kept]