From 28d4e3f226ef65f103c41677dbbf387072cdae63 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Thu, 14 Sep 2023 22:36:36 +0000 Subject: [PATCH 1/6] Avoid marking property attributes multiple times --- .../src/linker/Linker.Steps/MarkStep.cs | 3 +- .../illink/src/linker/Linker/Annotations.cs | 1 - .../DataFlow/AttributePropertyDataflow.cs | 36 +++++++++++++++++++ .../RequiresCapability/RequiresOnAttribute.cs | 5 --- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs b/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs index 52fe64b3632559..4ca984f023d6f0 100644 --- a/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs +++ b/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs @@ -3548,7 +3548,8 @@ protected virtual bool ShouldParseMethodBody (MethodDefinition method) protected internal void MarkProperty (PropertyDefinition prop, in DependencyInfo reason) { - Tracer.AddDirectDependency (prop, reason, marked: false); + if (!Annotations.MarkProcessed (prop, reason)) + return; using var propertyScope = ScopeStack.PushScope (new MessageOrigin (prop)); diff --git a/src/tools/illink/src/linker/Linker/Annotations.cs b/src/tools/illink/src/linker/Linker/Annotations.cs index 6576436b963cec..456af9fdf6ab1e 100644 --- a/src/tools/illink/src/linker/Linker/Annotations.cs +++ b/src/tools/illink/src/linker/Linker/Annotations.cs @@ -272,7 +272,6 @@ public bool IsProcessed (IMetadataTokenProvider provider) public bool MarkProcessed (IMetadataTokenProvider provider, in DependencyInfo reason) { - Debug.Assert (!(reason.Kind == DependencyKind.AlreadyMarked)); Tracer.AddDirectDependency (provider, reason, marked: true); // The item may or may not be pending. marked_pending.Remove (provider); diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs index 91fdad3652d8fd..5897eea96f43ed 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs @@ -26,6 +26,7 @@ public static void Main () { typeof (AttributePropertyDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicConstructorsAttribute)); typeof (AttributePropertyDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicMethodsAttribute)); + RecursivePropertyDataFlow.Test (); } [Kept] @@ -117,5 +118,40 @@ public TypeArrayAttribute () [Kept] public Type[] Types { get; [Kept] set; } } + + [Kept] + class RecursivePropertyDataFlow + { + [Kept] + [KeptBaseType (typeof (Attribute))] + class AttributePropertyRequiresPropertiesAttribute : Attribute + { + [Kept] + public AttributePropertyRequiresPropertiesAttribute () + { + } + + [Kept] + [field: Kept] + [KeptAttributeAttribute (typeof (AttributePropertyRequiresPropertiesAttribute))] + [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] + [ExpectedWarning ("IL2111", nameof (AttributePropertyRequiresPropertiesAttribute) + "." + nameof (RequiresPublicProperties), ProducedBy = Tool.Trimmer)] + [AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (AttributePropertyRequiresPropertiesAttribute))] + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] + public Type RequiresPublicProperties { + [Kept] + get; + [Kept] + set; + } + } + + [Kept] + [KeptAttributeAttribute (typeof (AttributePropertyRequiresPropertiesAttribute))] + [AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (int))] + public static void Test () + { + } + } } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs index d44fb0f4466fae..8710ed0e45cf82 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs @@ -112,14 +112,9 @@ static void MethodWithAttributeWhichRequires () { } static int _fieldWithAttributeWhichRequires; [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] - // /~https://github.com/dotnet/runtime/issues/83581 - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = Tool.Trimmer)] // Trimmer can produce duplicate warnings for property access - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = Tool.Trimmer)] // Trimmer can produce duplicate warnings for property access [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = Tool.Analyzer | Tool.NativeAot)] [ExpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = Tool.Analyzer | Tool.NativeAot)] [ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = Tool.Trimmer)] // Trimmer can produce duplicate warnings for property access - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = Tool.Trimmer)] // Trimmer can produce duplicate warnings for property access [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = Tool.Analyzer | Tool.NativeAot)] [ExpectedWarning ("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = Tool.Analyzer | Tool.NativeAot)] [AttributeWhichRequires] From 8f95d07874083482a91e0965f586119de8ee68fc Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 15 Sep 2023 15:33:23 +0000 Subject: [PATCH 2/6] Fix test for nativeaot --- .../DataFlow/AttributePropertyDataflow.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs index 5897eea96f43ed..f8b9565a78257a 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs @@ -135,7 +135,8 @@ public AttributePropertyRequiresPropertiesAttribute () [field: Kept] [KeptAttributeAttribute (typeof (AttributePropertyRequiresPropertiesAttribute))] [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] - [ExpectedWarning ("IL2111", nameof (AttributePropertyRequiresPropertiesAttribute) + "." + nameof (RequiresPublicProperties), ProducedBy = Tool.Trimmer)] + [ExpectedWarning ("IL2111", nameof (AttributePropertyRequiresPropertiesAttribute) + "." + nameof (RequiresPublicProperties), + ProducedBy = Tool.Trimmer | Tool.NativeAot)] [AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (AttributePropertyRequiresPropertiesAttribute))] [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] public Type RequiresPublicProperties { From 931cb31eba87b9260acde5de7e1755b1565cf3bf Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 15 Sep 2023 16:17:40 +0000 Subject: [PATCH 3/6] Add issue link --- .../DataFlow/AttributePropertyDataflow.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs index f8b9565a78257a..bb63b451e870a5 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs @@ -136,6 +136,7 @@ public AttributePropertyRequiresPropertiesAttribute () [KeptAttributeAttribute (typeof (AttributePropertyRequiresPropertiesAttribute))] [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] [ExpectedWarning ("IL2111", nameof (AttributePropertyRequiresPropertiesAttribute) + "." + nameof (RequiresPublicProperties), + // /~https://github.com/dotnet/runtime/issues/92131 ProducedBy = Tool.Trimmer | Tool.NativeAot)] [AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (AttributePropertyRequiresPropertiesAttribute))] [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] From 549dc627b91f6f20c3fac57ff096c3940a223477 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 15 Sep 2023 16:40:04 +0000 Subject: [PATCH 4/6] Simplify test, fix bug for events, add more coverage --- .../src/linker/Linker.Steps/MarkStep.cs | 4 +- .../DataFlow/AttributePropertyDataflow.cs | 120 ++++++++++++++---- 2 files changed, 96 insertions(+), 28 deletions(-) diff --git a/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs b/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs index 4ca984f023d6f0..d5923d135aa5b8 100644 --- a/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs +++ b/src/tools/illink/src/linker/Linker.Steps/MarkStep.cs @@ -3560,8 +3560,8 @@ protected internal void MarkProperty (PropertyDefinition prop, in DependencyInfo protected internal virtual void MarkEvent (EventDefinition evt, in DependencyInfo reason) { - // Record the event without marking it in Annotations. - Tracer.AddDirectDependency (evt, reason, marked: false); + if (!Annotations.MarkProcessed (evt, reason)) + return; using var eventScope = ScopeStack.PushScope (new MessageOrigin (evt)); diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs index bb63b451e870a5..b45c35850b9a1f 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs @@ -17,7 +17,7 @@ class AttributePropertyDataflow [KeptAttributeAttribute (typeof (KeepsPublicFieldsAttribute))] [KeptAttributeAttribute (typeof (TypeArrayAttribute))] [KeepsPublicConstructors (Type = typeof (ClassWithKeptPublicConstructor))] - [KeepsPublicMethods (Type = "Mono.Linker.Tests.Cases.DataFlow.AttributePropertyDataflow+ClassWithKeptPublicMethods")] + [KeepsPublicMethods (TypeName = "Mono.Linker.Tests.Cases.DataFlow.AttributePropertyDataflow+ClassWithKeptPublicMethods")] [KeepsPublicFields (Type = null, TypeName = null)] [TypeArray (Types = new Type[] { typeof (AttributePropertyDataflow) })] // Trimmer only for now - /~https://github.com/dotnet/linker/issues/2273 @@ -27,6 +27,9 @@ public static void Main () typeof (AttributePropertyDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicConstructorsAttribute)); typeof (AttributePropertyDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicMethodsAttribute)); RecursivePropertyDataFlow.Test (); + RecursiveEventDataFlow.Test (); + RecursiveFieldDataFlow.Test (); + RecursiveMethodDataFlow.Test (); } [Kept] @@ -58,7 +61,13 @@ public KeepsPublicMethodsAttribute () [Kept] [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public string Type { get; [Kept] set; } + public Type Type { get; [Kept] set; } + + [field: Kept] + [Kept] + [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] + public string TypeName { get; [Kept] set; } } // Used to test null values @@ -84,6 +93,38 @@ public KeepsPublicFieldsAttribute () public string TypeName { get; [Kept] set; } } + [Kept] + [KeptBaseType (typeof (Attribute))] + class KeepsPublicPropertiesAttribute : Attribute + { + [Kept] + public KeepsPublicPropertiesAttribute () + { + } + + [field: Kept] + [Kept] + [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] + public Type Type { get; [Kept] set; } + } + + [Kept] + [KeptBaseType (typeof (Attribute))] + class KeepsPublicEventsAttribute : Attribute + { + [Kept] + public KeepsPublicEventsAttribute () + { + } + + [field: Kept] + [Kept] + [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicEvents)] + public Type Type { get; [Kept] set; } + } + [Kept] class ClassWithKeptPublicConstructor { @@ -122,37 +163,64 @@ public TypeArrayAttribute () [Kept] class RecursivePropertyDataFlow { + [field: Kept] + [Kept] + [KeptAttributeAttribute (typeof (KeepsPublicPropertiesAttribute))] + [KeepsPublicProperties (Type = typeof (RecursivePropertyDataFlow))] + public static int Property { [Kept] get; [Kept] set; } + + [Kept] + public static void Test () + { + Property = 0; + } + } + + [Kept] + class RecursiveEventDataFlow + { + [field: Kept] + [Kept] + [KeptEventAddMethod] + [KeptEventRemoveMethod] + [KeptAttributeAttribute (typeof (KeepsPublicEventsAttribute))] + [KeepsPublicEvents (Type = typeof (RecursiveEventDataFlow))] + public static event EventHandler Event; + [Kept] - [KeptBaseType (typeof (Attribute))] - class AttributePropertyRequiresPropertiesAttribute : Attribute + public static void Test () { - [Kept] - public AttributePropertyRequiresPropertiesAttribute () - { - } - - [Kept] - [field: Kept] - [KeptAttributeAttribute (typeof (AttributePropertyRequiresPropertiesAttribute))] - [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))] - [ExpectedWarning ("IL2111", nameof (AttributePropertyRequiresPropertiesAttribute) + "." + nameof (RequiresPublicProperties), - // /~https://github.com/dotnet/runtime/issues/92131 - ProducedBy = Tool.Trimmer | Tool.NativeAot)] - [AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (AttributePropertyRequiresPropertiesAttribute))] - [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] - public Type RequiresPublicProperties { - [Kept] - get; - [Kept] - set; - } + Event += (sender, e) => { }; } + } + + [Kept] + class RecursiveFieldDataFlow + { + [Kept] + [KeptAttributeAttribute (typeof (KeepsPublicFieldsAttribute))] + [KeepsPublicFields (Type = typeof (RecursiveFieldDataFlow))] + public static int field; + + [Kept] + public static void Test () + { + field = 0; + } + } + + [Kept] + class RecursiveMethodDataFlow + { + [Kept] + [KeptAttributeAttribute (typeof (KeepsPublicMethodsAttribute))] + [KeepsPublicMethods (Type = typeof (RecursiveMethodDataFlow))] + public static void Method () { } [Kept] - [KeptAttributeAttribute (typeof (AttributePropertyRequiresPropertiesAttribute))] - [AttributePropertyRequiresProperties (RequiresPublicProperties = typeof (int))] public static void Test () { + Method (); } } } From e9444309d9b3bc5bf564ebeaef9487e69c84c10c Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 15 Sep 2023 16:52:54 +0000 Subject: [PATCH 5/6] Fix event tests --- .../Reflection/TypeHierarchyReflectionWarnings.cs | 5 ----- .../RequiresCapability/BasicRequires.cs | 2 -- .../RequiresCapability/RequiresOnClass.cs | 6 ------ 3 files changed, 13 deletions(-) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs index a0d84562dd8917..d7225a40eacdb1 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeHierarchyReflectionWarnings.cs @@ -246,11 +246,6 @@ class AnnotatedPublicEvents public delegate void MyEventHandler (object sender, int i); [Kept] - // ILLink always keeps event methods when an event is kept, so this generates warnings - // on the event itself (since an event access is considered to reference the annotated add method), - // and on the add method (if it is accessed through reflection). - [ExpectedWarning ("IL2026", "--RUC on add_RUCEvent--", ProducedBy = Tool.Trimmer)] - [ExpectedWarning ("IL2026", "--RUC on add_RUCEvent--", ProducedBy = Tool.Trimmer)] [ExpectedWarning ("IL2026", "--RUC on add_RUCEvent--", ProducedBy = Tool.Trimmer)] public event MyEventHandler RUCEvent { [Kept] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/BasicRequires.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/BasicRequires.cs index ba11e7fa07fdef..0d6b360ac71478 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/BasicRequires.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/BasicRequires.cs @@ -137,7 +137,6 @@ static void TestRequiresFromNameOf () class OnEventMethod { - [ExpectedWarning ("IL2026", "--EventToTestRemove.remove--", ProducedBy = Tool.Trimmer)] [ExpectedWarning ("IL2026", "--EventToTestRemove.remove--", ProducedBy = Tool.Trimmer)] static event EventHandler EventToTestRemove { add { } @@ -147,7 +146,6 @@ static event EventHandler EventToTestRemove { remove { } } - [ExpectedWarning ("IL2026", "--EventToTestAdd.add--", ProducedBy = Tool.Trimmer)] [ExpectedWarning ("IL2026", "--EventToTestAdd.add--", ProducedBy = Tool.Trimmer)] static event EventHandler EventToTestAdd { [RequiresUnreferencedCode ("Message for --EventToTestAdd.add--")] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnClass.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnClass.cs index c95e7abe6fa65b..abc594d1777390 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnClass.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnClass.cs @@ -494,8 +494,6 @@ class MemberTypesWithRequires // These should not be reported /~https://github.com/mono/linker/issues/2218 [ExpectedWarning ("IL2026", "MemberTypesWithRequires.Event.add", ProducedBy = Tool.Trimmer)] - [ExpectedWarning ("IL2026", "MemberTypesWithRequires.Event.add", ProducedBy = Tool.Trimmer)] - [ExpectedWarning ("IL2026", "MemberTypesWithRequires.Event.remove", ProducedBy = Tool.Trimmer)] [ExpectedWarning ("IL2026", "MemberTypesWithRequires.Event.remove", ProducedBy = Tool.Trimmer)] public static event EventHandler Event; } @@ -851,10 +849,6 @@ class WithRequires // These should be reported only in TestDirectReflectionAccess // /~https://github.com/mono/linker/issues/2218 [ExpectedWarning ("IL2026", "StaticEvent.add", ProducedBy = Tool.Trimmer)] - [ExpectedWarning ("IL2026", "StaticEvent.add", ProducedBy = Tool.Trimmer)] - [ExpectedWarning ("IL2026", "StaticEvent.add", ProducedBy = Tool.Trimmer)] - [ExpectedWarning ("IL2026", "StaticEvent.remove", ProducedBy = Tool.Trimmer)] - [ExpectedWarning ("IL2026", "StaticEvent.remove", ProducedBy = Tool.Trimmer)] [ExpectedWarning ("IL2026", "StaticEvent.remove", ProducedBy = Tool.Trimmer)] public static event EventHandler StaticEvent; } From 0f2c80dd8d78bf62591896c6bf8b24bd061bb864 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 15 Sep 2023 18:11:12 +0000 Subject: [PATCH 6/6] Fix test for nativeaot NativeAot requires a call to GetCustomAttribute for the attributes to be kept. --- .../DataFlow/AttributePropertyDataflow.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs index b45c35850b9a1f..2167c1886fa235 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AttributePropertyDataflow.cs @@ -24,8 +24,8 @@ class AttributePropertyDataflow [ExpectedWarning ("IL2026", "--ClassWithKeptPublicMethods--", ProducedBy = Tool.Trimmer | Tool.NativeAot)] public static void Main () { - typeof (AttributePropertyDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicConstructorsAttribute)); - typeof (AttributePropertyDataflow).GetMethod ("Main").GetCustomAttribute (typeof (KeepsPublicMethodsAttribute)); + typeof (AttributePropertyDataflow).GetMethod (nameof (Main)).GetCustomAttribute (typeof (KeepsPublicConstructorsAttribute)); + typeof (AttributePropertyDataflow).GetMethod (nameof (Main)).GetCustomAttribute (typeof (KeepsPublicMethodsAttribute)); RecursivePropertyDataFlow.Test (); RecursiveEventDataFlow.Test (); RecursiveFieldDataFlow.Test (); @@ -172,6 +172,7 @@ class RecursivePropertyDataFlow [Kept] public static void Test () { + typeof (RecursivePropertyDataFlow).GetProperty (nameof (Property)).GetCustomAttribute (typeof (KeepsPublicPropertiesAttribute)); Property = 0; } } @@ -190,6 +191,7 @@ class RecursiveEventDataFlow [Kept] public static void Test () { + typeof (RecursiveEventDataFlow).GetEvent (nameof (Event)).GetCustomAttribute (typeof (KeepsPublicEventsAttribute)); Event += (sender, e) => { }; } } @@ -205,6 +207,7 @@ class RecursiveFieldDataFlow [Kept] public static void Test () { + typeof (RecursiveMethodDataFlow).GetField (nameof (field)).GetCustomAttribute (typeof (KeepsPublicFieldsAttribute)); field = 0; } } @@ -220,6 +223,7 @@ public static void Method () { } [Kept] public static void Test () { + typeof (RecursiveMethodDataFlow).GetMethod (nameof (Method)).GetCustomAttribute (typeof (KeepsPublicMethodsAttribute)); Method (); } }