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-11-16 20:21:59 +0300
committerSven Boemer <sbomer@gmail.com>2021-11-16 20:39:54 +0300
commita556862ea401d080a2b9dab1615f3e8cc8892026 (patch)
tree467a67802e4519e8250c9eb650ee7e19b25c28cb /test/Mono.Linker.Tests.Cases
parent2aed9937115a6bd5a81e37658431272ce4be3317 (diff)
parent53c5d48842fe53e05272d163c7f49e54ddcb4b37 (diff)
Merge remote-tracking branch 'origin/main' into updateFromMain
Diffstat (limited to 'test/Mono.Linker.Tests.Cases')
-rw-r--r--test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.Descriptor.xml4
-rw-r--r--test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.cs10
-rw-r--r--test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.LinkAttributes.xml8
-rw-r--r--test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.cs48
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/EventUsedViaReflection.cs32
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/FieldUsedViaReflection.cs19
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/MethodUsedViaReflection.cs47
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/MethodsUsedViaReflection.cs26
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/NestedTypeUsedViaReflection.cs21
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/PropertiesUsedViaReflection.cs26
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/PropertyUsedViaReflection.cs49
-rw-r--r--test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/ReferenceInterfaces.cs44
-rw-r--r--test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/RequiresInCopyAssembly.cs13
-rw-r--r--test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs357
-rw-r--r--test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapabilityFromCopiedAssembly.cs1
-rw-r--r--test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInCompilerGeneratedCode.cs232
16 files changed, 927 insertions, 10 deletions
diff --git a/test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.Descriptor.xml b/test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.Descriptor.xml
new file mode 100644
index 000000000..4fa3f75f9
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.Descriptor.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<linker>
+ <assembly fullname="test" />
+</linker> \ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.cs b/test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.cs
new file mode 100644
index 000000000..c61f1562a
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.cs
@@ -0,0 +1,10 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace Mono.Linker.Tests.Cases.LinkAttributes.Dependencies
+{
+ public static class Used
+ {
+ public static void Use () { }
+ }
+}
diff --git a/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.LinkAttributes.xml b/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.LinkAttributes.xml
new file mode 100644
index 000000000..b28401f8a
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.LinkAttributes.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<linker>
+ <assembly fullname="*">
+ <type fullname="Mono.Linker.Tests.Cases.LinkAttributes.AttributeToRemoveAttribute">
+ <attribute internal="RemoveAttributeInstances"/>
+ </type>
+ </assembly>
+</linker>
diff --git a/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.cs b/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.cs
new file mode 100644
index 000000000..1e0e34a17
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/LinkerAttributeRemovalAndPreserveAssembly.cs
@@ -0,0 +1,48 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Metadata;
+using Mono.Linker.Tests.Cases.LinkAttributes.Dependencies;
+
+namespace Mono.Linker.Tests.Cases.LinkAttributes
+{
+ [IgnoreDescriptors (false)]
+
+ // The test verifies that removed attributes which are later on kept due to descriptors correctly warn.
+ // The setup is:
+ // - test assembly with the AttributeToRemoveAttribute type
+ // - link attributes.xml which marks the attribute for removal (applied early, in this case via command line, but could be a embedded in the test assembly)
+ // - the attribute is used by the test assembly
+ // - another assembly lib.dll is added and is referenced (after the attribute is used/marked)
+ // - This new assembly has a descriptor which marks the entire test assembly (note that it marks the TEST assembly)
+ // - This marking causes the warning, as it's an explicit request to keep the attribute which was supposed to be removed
+
+ [SetupLinkAttributesFile ("LinkerAttributeRemovalAndPreserveAssembly.LinkAttributes.xml")]
+
+ [SetupCompileBefore (
+ "lib.dll",
+ new[] { "Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.cs" })]
+ // https://github.com/dotnet/linker/issues/2358 - adding the descriptor currently causes nullref in the linker
+ // resources: new object[] { new string[] { "Dependencies/LinkerAttributeRemovalAndPreserveAssembly_Lib.Descriptor.xml", "ILLink.Descriptors.xml" } })]
+
+ [ExpectedNoWarnings]
+
+ class LinkerAttributeRemovalAndPreserveAssembly
+ {
+ public static void Main ()
+ {
+ TestAttributeRemoval ();
+ }
+
+ [AttributeToRemoveAttribute]
+ [Kept]
+ static void TestAttributeRemoval ()
+ {
+ Used.Use ();
+ }
+ }
+
+ public class AttributeToRemoveAttribute : Attribute { }
+} \ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/EventUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/EventUsedViaReflection.cs
index ba33cdc4e..5f93cf879 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/EventUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/EventUsedViaReflection.cs
@@ -17,6 +17,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestNameBindingFlags ();
TestNameWrongBindingFlags ();
TestNameUnknownBindingFlags (BindingFlags.Public);
+ TestNameUnknownBindingFlagsAndName (BindingFlags.Public, "DoesntMatter");
TestNullName ();
TestEmptyName ();
TestNonExistingName ();
@@ -72,6 +73,13 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ static void TestNameUnknownBindingFlagsAndName (BindingFlags bindingFlags, string name)
+ {
+ // Since the binding flags are not known linker should mark all events on the type
+ var eventInfo = typeof (UnknownBindingFlagsAndName).GetEvent (name, bindingFlags);
+ }
+
+ [Kept]
static void TestNullName ()
{
var eventInfo = typeof (EventUsedViaReflection).GetEvent (null);
@@ -221,6 +229,30 @@ namespace Mono.Linker.Tests.Cases.Reflection
public event EventHandler<EventArgs> PublicEvent;
}
+ class UnknownBindingFlagsAndName
+ {
+ [Kept]
+ [KeptEventAddMethod]
+ [KeptEventRemoveMethod]
+ [method: ExpectBodyModified]
+ internal event EventHandler<EventArgs> InternalEvent;
+ [Kept]
+ [KeptBackingField]
+ [KeptEventAddMethod]
+ [KeptEventRemoveMethod]
+ static event EventHandler<EventArgs> Static;
+ [Kept]
+ [KeptEventAddMethod]
+ [KeptEventRemoveMethod]
+ [method: ExpectBodyModified]
+ private event EventHandler<EventArgs> PrivateEvent;
+ [Kept]
+ [KeptEventAddMethod]
+ [KeptEventRemoveMethod]
+ [method: ExpectBodyModified]
+ public event EventHandler<EventArgs> PublicEvent;
+ }
+
class IfClass
{
[Kept]
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/FieldUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/FieldUsedViaReflection.cs
index 7d7fc22d3..94535adb1 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/FieldUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/FieldUsedViaReflection.cs
@@ -15,6 +15,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestNameBindingFlags ();
TestNameWrongBindingFlags ();
TestNameUnknownBindingFlags (BindingFlags.Public);
+ TestNameUnknownBindingFlagsAndName (BindingFlags.Public, "DoesntMatter");
TestNullName ();
TestEmptyName ();
TestNonExistingName ();
@@ -67,6 +68,13 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ static void TestNameUnknownBindingFlagsAndName (BindingFlags bindingFlags, string name)
+ {
+ // Since the binding flags and name are not known linker should mark all fields on the type
+ var field = typeof (UnknownBindingFlagsAndName).GetField (name, bindingFlags);
+ }
+
+ [Kept]
static void TestNullName ()
{
var field = typeof (FieldUsedViaReflection).GetField (null);
@@ -187,6 +195,17 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ private class UnknownBindingFlagsAndName
+ {
+ [Kept]
+ public static int field;
+ [Kept]
+ public int nonStatic;
+ [Kept]
+ private static int privatefield;
+ }
+
+ [Kept]
private class IfClass
{
[Kept]
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/MethodUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/MethodUsedViaReflection.cs
index 18e70c058..bff3994a2 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/MethodUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/MethodUsedViaReflection.cs
@@ -17,6 +17,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
GetMethod_Name_Types.TestNameAndType ();
GetMethod_Name_BindingAttr.TestExplicitBindingFlags ();
GetMethod_Name_BindingAttr.TestUnknownBindingFlags (BindingFlags.Public);
+ GetMethod_Name_BindingAttr.TestUnknownBindingFlagsAndName (BindingFlags.Public, "DoesntMatter");
GetMethod_Name_BindingAttr.TestUnknownNullBindingFlags (BindingFlags.Public);
GetMethod_Name_BindingAttr_Binder_Types_Modifiers.TestNameBindingFlagsAndParameterModifier ();
GetMethod_Name_BindingAttr_Binder_CallConvention_Types_Modifiers.TestNameBindingFlagsCallingConventionParameterModifier ();
@@ -37,6 +38,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
DerivedAndBase.TestMethodInBaseType ();
IgnoreCaseBindingFlags.TestIgnoreCaseBindingFlags ();
FailIgnoreCaseBindingFlags.TestFailIgnoreCaseBindingFlags ();
+ IgnorableBindingFlags.TestIgnorableBindingFlags ();
UnsupportedBindingFlags.TestUnsupportedBindingFlags ();
}
@@ -200,6 +202,25 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ class UnknownBindingFlagsAndName
+ {
+ [Kept]
+ private static int OnlyCalledViaReflection ()
+ {
+ return 42;
+ }
+ }
+
+ [Kept]
+ [RecognizedReflectionAccessPattern]
+ public static void TestUnknownBindingFlagsAndName (BindingFlags bindingFlags, string name)
+ {
+ // Since the binding flags and name are not known linker should mark all methods on the type
+ var method = typeof (UnknownBindingFlagsAndName).GetMethod (name, bindingFlags);
+ method.Invoke (null, new object[] { });
+ }
+
+ [Kept]
private class NullBindingFlags
{
[Kept]
@@ -732,6 +753,28 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ class IgnorableBindingFlags
+ {
+ [Kept]
+ public int OnlyCalledViaReflection ()
+ {
+ return 54;
+ }
+
+ private bool Unmarked ()
+ {
+ return true;
+ }
+
+ [Kept]
+ public static void TestIgnorableBindingFlags ()
+ {
+ var method = typeof (IgnorableBindingFlags).GetMethod ("OnlyCalledViaReflection", BindingFlags.Public | BindingFlags.InvokeMethod);
+ method.Invoke (null, new object[] { });
+ }
+ }
+
+ [Kept]
class UnsupportedBindingFlags
{
[Kept]
@@ -741,7 +784,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
- private bool MarkedDueToInvokeMethod ()
+ private bool MarkedDueToChangeType ()
{
return true;
}
@@ -749,7 +792,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
public static void TestUnsupportedBindingFlags ()
{
- var method = typeof (UnsupportedBindingFlags).GetMethod ("OnlyCalledViaReflection", BindingFlags.InvokeMethod);
+ var method = typeof (UnsupportedBindingFlags).GetMethod ("OnlyCalledViaReflection", BindingFlags.Public | BindingFlags.SuppressChangeType);
method.Invoke (null, new object[] { });
}
}
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/MethodsUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/MethodsUsedViaReflection.cs
index 9fdbf389a..5658a1a99 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/MethodsUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/MethodsUsedViaReflection.cs
@@ -22,6 +22,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestDataFlowWithAnnotation (typeof (MyType));
TestIfElse (1);
TestIgnoreCaseBindingFlags ();
+ TestIgnorableBindingFlags ();
TestUnsupportedBindingFlags ();
}
@@ -100,9 +101,15 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ static void TestIgnorableBindingFlags ()
+ {
+ var methods = typeof (InvokeMethodClass).GetMethods (BindingFlags.Public | BindingFlags.InvokeMethod);
+ }
+
+ [Kept]
static void TestUnsupportedBindingFlags ()
{
- var methods = typeof (InvokeMethodClass).GetMethods (BindingFlags.InvokeMethod);
+ var methods = typeof (SuppressChangeTypeClass).GetMethods (BindingFlags.Public | BindingFlags.SuppressChangeType);
}
[Kept]
@@ -287,8 +294,23 @@ namespace Mono.Linker.Tests.Cases.Reflection
return 54;
}
+ private bool Unmarked ()
+ {
+ return true;
+ }
+ }
+
+ [Kept]
+ private class SuppressChangeTypeClass
+ {
+ [Kept]
+ public int OnlyCalledViaReflection ()
+ {
+ return 54;
+ }
+
[Kept]
- private bool MarkedDueToInvokeMethod ()
+ private bool MarkedDueToSuppressChangeType ()
{
return true;
}
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/NestedTypeUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/NestedTypeUsedViaReflection.cs
index cda87ee85..2700a8793 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/NestedTypeUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/NestedTypeUsedViaReflection.cs
@@ -16,6 +16,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestPrivateByName ();
TestByBindingFlags ();
TestByUnknownBindingFlags (BindingFlags.Public);
+ TestByUnknownBindingFlagsAndName (BindingFlags.Public, "DoesntMatter");
TestNonExistingName ();
TestNullType ();
TestIgnoreCaseBindingFlags ();
@@ -81,6 +82,16 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ [RecognizedReflectionAccessPattern (
+ typeof (Type), nameof (Type.GetNestedType), new Type[] { typeof (string), typeof (BindingFlags) },
+ typeof (UnknownBindingFlagsAndName.PublicNestedType), null, (Type[]) null)]
+ static void TestByUnknownBindingFlagsAndName (BindingFlags bindingFlags, string name)
+ {
+ // Since the binding flags and name are not known linker should mark all nested types on the type
+ _ = typeof (UnknownBindingFlagsAndName).GetNestedType (name, bindingFlags);
+ }
+
+ [Kept]
static void TestNonExistingName ()
{
_ = typeof (NestedTypeUsedViaReflection).GetNestedType ("NonExisting");
@@ -125,6 +136,16 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ private class UnknownBindingFlagsAndName
+ {
+ [Kept]
+ public static class PublicNestedType { }
+
+ [Kept]
+ private static class PrivateNestedType { }
+ }
+
+ [Kept]
private class IgnoreCaseClass
{
[Kept]
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/PropertiesUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/PropertiesUsedViaReflection.cs
index a7b7dbea8..4f8346b7c 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/PropertiesUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/PropertiesUsedViaReflection.cs
@@ -23,6 +23,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestDataFlowWithAnnotation (typeof (MyType));
TestIfElse (1);
TestIgnoreCaseBindingFlags ();
+ TestIgnorableBindingFlags ();
TestUnsupportedBindingFlags ();
}
@@ -107,9 +108,16 @@ namespace Mono.Linker.Tests.Cases.Reflection
[Kept]
[RecognizedReflectionAccessPattern]
+ static void TestIgnorableBindingFlags ()
+ {
+ var properties = typeof (ExactBindingBindingFlagsClass).GetProperties (BindingFlags.Public | BindingFlags.ExactBinding);
+ }
+
+ [Kept]
+ [RecognizedReflectionAccessPattern]
static void TestUnsupportedBindingFlags ()
{
- var properties = typeof (ExactBindingBindingFlagsClass).GetProperties (BindingFlags.ExactBinding);
+ var properties = typeof (ChangeTypeBindingFlagsClass).GetProperties (BindingFlags.Public | BindingFlags.SuppressChangeType);
}
[Kept]
@@ -256,8 +264,22 @@ namespace Mono.Linker.Tests.Cases.Reflection
set { _field = value; }
}
+ private static int Unmarked {
+ get { return _field; }
+ }
+ }
+
+ [Kept]
+ class ChangeTypeBindingFlagsClass
+ {
+ [Kept]
+ public static int SetterOnly {
+ [Kept]
+ set { _field = value; }
+ }
+
[Kept]
- private static int MarkedDueToExactBinding {
+ private static int KeptDueToChangeType {
[Kept]
get { return _field; }
}
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/PropertyUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/PropertyUsedViaReflection.cs
index 3971f9108..4004e894b 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/PropertyUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/PropertyUsedViaReflection.cs
@@ -17,6 +17,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestGetterOnly ();
TestBindingFlags ();
TestUnknownBindingFlags (BindingFlags.Public);
+ TestUnknownBindingFlagsAndName (BindingFlags.Public, "IrrelevantName");
TestNullName ();
TestEmptyName ();
TestNonExistingName ();
@@ -27,6 +28,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestPropertyInBaseType ();
TestIgnoreCaseBindingFlags ();
TestFailIgnoreCaseBindingFlags ();
+ TestIgnorableBindingFlags ();
TestUnsupportedBindingFlags ();
}
@@ -90,6 +92,17 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ [RecognizedReflectionAccessPattern (
+ typeof (Type), nameof (Type.GetProperty), new Type[] { typeof (string), typeof (BindingFlags) },
+ typeof (UnknownBindingFlagsAndName), nameof (UnknownBindingFlagsAndName.SomeProperty), (Type[]) null)]
+ static void TestUnknownBindingFlagsAndName (BindingFlags bindingFlags, string name)
+ {
+ // Since the binding flags and name are not known linker should mark all properties on the type
+ var property = typeof (UnknownBindingFlagsAndName).GetProperty (name, bindingFlags);
+ property.GetValue (null, new object[] { });
+ }
+
+ [Kept]
static void TestNullName ()
{
var property = typeof (PropertyUsedViaReflection).GetProperty (null);
@@ -194,9 +207,15 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ static void TestIgnorableBindingFlags ()
+ {
+ var property = typeof (ExactBindingBindingFlagsClass).GetProperty ("SetterOnly", BindingFlags.Public | BindingFlags.ExactBinding);
+ }
+
+ [Kept]
static void TestUnsupportedBindingFlags ()
{
- var property = typeof (ExactBindingBindingFlagsClass).GetProperty ("SetterOnly", BindingFlags.ExactBinding);
+ var property = typeof (ChangeTypeBindingFlagsClass).GetProperty ("SetterOnly", BindingFlags.Public | BindingFlags.SuppressChangeType);
}
[Kept]
@@ -314,6 +333,18 @@ namespace Mono.Linker.Tests.Cases.Reflection
}
[Kept]
+ class UnknownBindingFlagsAndName
+ {
+ [Kept]
+ internal static int SomeProperty {
+ [Kept]
+ private get { return _field; }
+ [Kept]
+ set { _field = value; }
+ }
+ }
+
+ [Kept]
class IgnoreCaseBindingFlagsClass
{
[Kept]
@@ -346,8 +377,22 @@ namespace Mono.Linker.Tests.Cases.Reflection
set { _field = value; }
}
+ public static int Unmarked {
+ get { return _field; }
+ }
+ }
+
+ [Kept]
+ class ChangeTypeBindingFlagsClass
+ {
+ [Kept]
+ public static int SetterOnly {
+ [Kept]
+ set { _field = value; }
+ }
+
[Kept]
- public static int MarkedDueToExactBinding {
+ public static int Marked {
[Kept]
get { return _field; }
}
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/ReferenceInterfaces.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/ReferenceInterfaces.cs
new file mode 100644
index 000000000..e30fd271c
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/ReferenceInterfaces.cs
@@ -0,0 +1,44 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Mono.Linker.Tests.Cases.RequiresCapability.Dependencies
+{
+ public class ReferenceInterfaces
+ {
+ public interface IBaseWithRequiresInReference
+ {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ public void Method ();
+
+ public string PropertyAnnotationInAccesor {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ get;
+ set;
+ }
+
+ [RequiresAssemblyFiles ("Message")]
+ public string PropertyAnnotationInProperty { get; set; }
+ }
+
+ public interface IBaseWithoutRequiresInReference
+ {
+ public void Method ();
+
+ public string PropertyAnnotationInAccesor {
+ get;
+ set;
+ }
+
+ public string PropertyAnnotationInProperty { get; set; }
+ }
+ }
+} \ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/RequiresInCopyAssembly.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/RequiresInCopyAssembly.cs
index 74cdff268..c121ff4ef 100644
--- a/test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/RequiresInCopyAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/Dependencies/RequiresInCopyAssembly.cs
@@ -15,24 +15,29 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability.Dependencies
}
[RequiresUnreferencedCode ("Message for --Method--")]
+ [RequiresAssemblyFiles ("Message for --Method--")]
public void Method ()
{
}
[RequiresUnreferencedCode ("Message for --UncalledMethod--")]
+ [RequiresAssemblyFiles ("Message for --UncalledMethod--")]
public void UncalledMethod ()
{
}
[RequiresUnreferencedCode ("Message for --MethodCalledThroughReflection--")]
+ [RequiresAssemblyFiles ("Message for --MethodCalledThroughReflection--")]
static void MethodCalledThroughReflection ()
{
}
public int UnusedProperty {
[RequiresUnreferencedCode ("Message for --getter UnusedProperty--")]
+ [RequiresAssemblyFiles ("Message for --getter UnusedProperty--")]
get { return 42; }
+ [RequiresAssemblyFiles ("Message for --setter UnusedProperty--")]
[RequiresUnreferencedCode ("Message for --setter UnusedProperty--")]
set { }
}
@@ -40,16 +45,19 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability.Dependencies
class UnusedBaseType
{
[RequiresUnreferencedCode ("Message for --UnusedBaseTypeCctor--")]
+ [RequiresAssemblyFiles ("Message for --UnusedBaseTypeCctor--")]
static UnusedBaseType ()
{
}
[RequiresUnreferencedCode ("Message for --UnusedVirtualMethod1--")]
+ [RequiresAssemblyFiles ("Message for --UnusedVirtualMethod1--")]
public virtual void UnusedVirtualMethod1 ()
{
}
[RequiresUnreferencedCode ("Message for --UnusedVirtualMethod2--")]
+ [RequiresAssemblyFiles ("Message for --UnusedVirtualMethod2--")]
public virtual void UnusedVirtualMethod2 ()
{
}
@@ -58,6 +66,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability.Dependencies
class UnusedDerivedType : UnusedBaseType
{
[RequiresUnreferencedCode ("Message for --UnusedVirtualMethod1--")]
+ [RequiresAssemblyFiles ("Message for --UnusedVirtualMethod1--")]
public override void UnusedVirtualMethod1 ()
{
}
@@ -71,12 +80,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability.Dependencies
interface IUnusedInterface
{
[RequiresUnreferencedCode ("Message for --IUnusedInterface.UnusedMethod--")]
+ [RequiresAssemblyFiles ("Message for --IUnusedInterface.UnusedMethod--")]
public void UnusedMethod ();
}
class UnusedImplementationClass : IUnusedInterface
{
[RequiresUnreferencedCode ("Message for --UnusedImplementationClass.UnusedMethod--")]
+ [RequiresAssemblyFiles ("Message for --UnusedImplementationClass.UnusedMethod--")]
public void UnusedMethod ()
{
}
@@ -85,12 +96,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability.Dependencies
public interface IBaseInterface
{
[RequiresUnreferencedCode ("Message for --IBaseInterface.MethodInBaseInterface--")]
+ [RequiresAssemblyFiles ("Message for --IBaseInterface.MethodInBaseInterface--")]
void MethodInBaseInterface ();
}
public interface IDerivedInterface : IBaseInterface
{
[RequiresUnreferencedCode ("Message for --IDerivedInterface.MethodInDerivedInterface--")]
+ [RequiresAssemblyFiles ("Message for --IDerivedInterface.MethodInDerivedInterface--")]
void MethodInDerivedInterface ();
}
}
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
index f7155e5fe..40814d2e6 100644
--- a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
+++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapability.cs
@@ -19,6 +19,9 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[SetupLinkerAction ("copy", "lib")]
[SetupCompileBefore ("lib.dll", new[] { "Dependencies/RequiresInCopyAssembly.cs" })]
[KeptAllTypesAndMembersInAssembly ("lib.dll")]
+ [SetupLinkerAction ("copy", "lib2")]
+ [SetupCompileBefore ("lib2.dll", new[] { "Dependencies/ReferenceInterfaces.cs" })]
+ [KeptAllTypesAndMembersInAssembly ("lib2.dll")]
[SetupLinkAttributesFile ("RequiresCapability.attributes.xml")]
[SetupLinkerDescriptorFile ("RequiresCapability.descriptor.xml")]
[SkipKeptItemsValidation]
@@ -82,32 +85,38 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
AccessThroughNewConstraint.TestNewConstraintOnTypeParameter ();
AccessThroughNewConstraint.TestNewConstraintOnTypeParameterOfStaticType ();
AccessThroughLdToken.Test ();
+ AttributeMismatch.Test ();
RequiresOnClass.Test ();
}
[ExpectedWarning ("IL2026", "Message for --RequiresWithMessageOnly--.")]
+ [ExpectedWarning ("IL3002", "Message for --RequiresWithMessageOnly--.", ProducedBy = ProducedBy.Analyzer)]
static void TestRequiresWithMessageOnlyOnMethod ()
{
RequiresWithMessageOnly ();
}
[RequiresUnreferencedCode ("Message for --RequiresWithMessageOnly--")]
+ [RequiresAssemblyFiles ("Message for --RequiresWithMessageOnly--")]
static void RequiresWithMessageOnly ()
{
}
[ExpectedWarning ("IL2026", "Message for --RequiresWithMessageAndUrl--.", "https://helpurl")]
+ [ExpectedWarning ("IL3002", "Message for --RequiresWithMessageAndUrl--.", "https://helpurl", ProducedBy = ProducedBy.Analyzer)]
static void TestRequiresWithMessageAndUrlOnMethod ()
{
RequiresWithMessageAndUrl ();
}
[RequiresUnreferencedCode ("Message for --RequiresWithMessageAndUrl--", Url = "https://helpurl")]
+ [RequiresAssemblyFiles ("Message for --RequiresWithMessageAndUrl--", Url = "https://helpurl")]
static void RequiresWithMessageAndUrl ()
{
}
[ExpectedWarning ("IL2026", "Message for --ConstructorRequires--.")]
+ [ExpectedWarning ("IL3002", "Message for --ConstructorRequires--.", ProducedBy = ProducedBy.Analyzer)]
static void TestRequiresOnConstructor ()
{
new ConstructorRequires ();
@@ -116,6 +125,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class ConstructorRequires
{
[RequiresUnreferencedCode ("Message for --ConstructorRequires--")]
+ [RequiresAssemblyFiles ("Message for --ConstructorRequires--")]
public ConstructorRequires ()
{
}
@@ -123,6 +133,8 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL2026", "Message for --getter PropertyRequires--.")]
[ExpectedWarning ("IL2026", "Message for --setter PropertyRequires--.")]
+ [ExpectedWarning ("IL3002", "Message for --getter PropertyRequires--.", ProducedBy = ProducedBy.Analyzer)]
+ [ExpectedWarning ("IL3002", "Message for --setter PropertyRequires--.", ProducedBy = ProducedBy.Analyzer)]
static void TestRequiresOnPropertyGetterAndSetter ()
{
_ = PropertyRequires;
@@ -131,9 +143,11 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
static int PropertyRequires {
[RequiresUnreferencedCode ("Message for --getter PropertyRequires--")]
+ [RequiresAssemblyFiles ("Message for --getter PropertyRequires--")]
get { return 42; }
[RequiresUnreferencedCode ("Message for --setter PropertyRequires--")]
+ [RequiresAssemblyFiles ("Message for --setter PropertyRequires--")]
set { }
}
@@ -144,6 +158,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
static Type GetUnknownType () => null;
[RequiresUnreferencedCode ("Message for --MethodWithRequires--")]
+ [RequiresAssemblyFiles ("Message for --MethodWithRequires--")]
static void MethodWithRequires ()
{
}
@@ -152,6 +167,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
static Type _requiresPublicConstructors;
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestMethodWithRequires ()
{
// Normally this would warn, but with the attribute on this method it should be auto-suppressed
@@ -159,24 +175,28 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestParameter ()
{
_unknownType.RequiresPublicMethods ();
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestReturnValue ()
{
GetUnknownType ().RequiresPublicEvents ();
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestField ()
{
_requiresPublicConstructors = _unknownType;
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestMethodWithRequires ();
@@ -196,36 +216,42 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class GenericTypeRequiresPublicFields<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T> { }
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestGenericMethod ()
{
GenericMethodRequiresPublicMethods<TUnknown> ();
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestGenericMethodMismatch ()
{
GenericMethodRequiresPublicMethods<TPublicProperties> ();
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestGenericType ()
{
new GenericTypeRequiresPublicFields<TUnknown> ();
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestMakeGenericTypeWithStaticTypes ()
{
typeof (GenericTypeRequiresPublicFields<>).MakeGenericType (typeof (TUnknown));
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestMakeGenericTypeWithDynamicTypes ()
{
typeof (GenericTypeRequiresPublicFields<>).MakeGenericType (_unknownType);
}
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static void TestMakeGenericMethod ()
{
typeof (SuppressGenericParameters<TUnknown, TPublicProperties>)
@@ -234,6 +260,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestGenericMethod ();
@@ -292,6 +319,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class BaseType
{
[RequiresUnreferencedCode ("Message for --BaseType.VirtualMethodRequires--")]
+ [RequiresAssemblyFiles ("Message for --BaseType.VirtualMethodRequires--")]
public virtual void VirtualMethodRequires ()
{
}
@@ -300,12 +328,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class TypeWhichOverridesMethod : BaseType
{
[RequiresUnreferencedCode ("Message for --TypeWhichOverridesMethod.VirtualMethodRequires--")]
+ [RequiresAssemblyFiles ("Message for --TypeWhichOverridesMethod.VirtualMethodRequires--")]
public override void VirtualMethodRequires ()
{
}
}
[ExpectedWarning ("IL2026", "--BaseType.VirtualMethodRequires--")]
+ [ExpectedWarning ("IL3002", "--BaseType.VirtualMethodRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestBaseTypeVirtualMethodRequires ()
{
var tmp = new BaseType ();
@@ -314,6 +344,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[LogDoesNotContain ("TypeWhichOverridesMethod.VirtualMethodRequires")]
[ExpectedWarning ("IL2026", "--BaseType.VirtualMethodRequires--")]
+ [ExpectedWarning ("IL3002", "--BaseType.VirtualMethodRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestTypeWhichOverridesMethodVirtualMethodRequires ()
{
var tmp = new TypeWhichOverridesMethod ();
@@ -322,6 +353,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[LogDoesNotContain ("TypeWhichOverridesMethod.VirtualMethodRequires")]
[ExpectedWarning ("IL2026", "--BaseType.VirtualMethodRequires--")]
+ [ExpectedWarning ("IL3002", "--BaseType.VirtualMethodRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestTypeWhichOverridesMethodVirtualMethodRequiresOnBase ()
{
BaseType tmp = new TypeWhichOverridesMethod ();
@@ -330,19 +362,25 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class PropertyBaseType
{
- public virtual int VirtualPropertyRequires { [RequiresUnreferencedCode ("Message for --PropertyBaseType.VirtualPropertyRequires--")] get; }
+ public virtual int VirtualPropertyRequires {
+ [RequiresUnreferencedCode ("Message for --PropertyBaseType.VirtualPropertyRequires--")]
+ [RequiresAssemblyFiles ("Message for --PropertyBaseType.VirtualPropertyRequires--")]
+ get;
+ }
}
class TypeWhichOverridesProperty : PropertyBaseType
{
public override int VirtualPropertyRequires {
[RequiresUnreferencedCode ("Message for --TypeWhichOverridesProperty.VirtualPropertyRequires--")]
+ [RequiresAssemblyFiles ("Message for --TypeWhichOverridesProperty.VirtualPropertyRequires--")]
get { return 1; }
}
}
[LogDoesNotContain ("TypeWhichOverridesProperty.VirtualPropertyRequires")]
[ExpectedWarning ("IL2026", "--PropertyBaseType.VirtualPropertyRequires--")]
+ [ExpectedWarning ("IL3002", "--PropertyBaseType.VirtualPropertyRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestTypeWhichOverridesVirtualPropertyRequires ()
{
var tmp = new TypeWhichOverridesProperty ();
@@ -382,6 +420,8 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
struct StaticCCtorForFieldAccess
{
+ // TODO: Analyzer still allows RUC/RAF on static constructor with no warning
+ // https://github.com/dotnet/linker/issues/2347
[ExpectedWarning ("IL2116", "StaticCCtorForFieldAccess..cctor()", ProducedBy = ProducedBy.Trimmer)]
[RequiresUnreferencedCode ("Message for --StaticCCtorForFieldAccess.cctor--")]
static StaticCCtorForFieldAccess () { }
@@ -397,9 +437,11 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class TypeIsBeforeFieldInit
{
[ExpectedWarning ("IL2026", "Message from --TypeIsBeforeFieldInit.AnnotatedMethod--", ProducedBy = ProducedBy.Analyzer)]
+ [ExpectedWarning ("IL3002", "Message from --TypeIsBeforeFieldInit.AnnotatedMethod--", ProducedBy = ProducedBy.Analyzer)]
public static int field = AnnotatedMethod ();
[RequiresUnreferencedCode ("Message from --TypeIsBeforeFieldInit.AnnotatedMethod--")]
+ [RequiresAssemblyFiles ("Message from --TypeIsBeforeFieldInit.AnnotatedMethod--")]
public static int AnnotatedMethod () => 42;
}
@@ -416,19 +458,24 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class StaticCtorTriggeredByMethodCall
{
+ // TODO: Analyzer still allows RUC/RAF on static constructor with no warning
+ // https://github.com/dotnet/linker/issues/2347
[ExpectedWarning ("IL2116", "StaticCtorTriggeredByMethodCall..cctor()", ProducedBy = ProducedBy.Trimmer)]
[RequiresUnreferencedCode ("Message for --StaticCtorTriggeredByMethodCall.Cctor--")]
+ [RequiresAssemblyFiles ("Message for --StaticCtorTriggeredByMethodCall.Cctor--")]
static StaticCtorTriggeredByMethodCall ()
{
}
[RequiresUnreferencedCode ("Message for --StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking--")]
+ [RequiresAssemblyFiles ("Message for --StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking--")]
public void TriggerStaticCtorMarking ()
{
}
}
[ExpectedWarning ("IL2026", "--StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking--")]
+ [ExpectedWarning ("IL3002", "--StaticCtorTriggeredByMethodCall.TriggerStaticCtorMarking--", ProducedBy = ProducedBy.Analyzer)]
static void TestStaticCtorTriggeredByMethodCall ()
{
new StaticCtorTriggeredByMethodCall ().TriggerStaticCtorMarking ();
@@ -449,6 +496,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[LogDoesNotContain ("ImplementationClass.MethodWithRequires")]
[ExpectedWarning ("IL2026", "--IRequires.MethodWithRequires--")]
+ [ExpectedWarning ("IL3002", "--IRequires.MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestInterfaceMethodWithRequires ()
{
IRequires inst = new ImplementationClass ();
@@ -461,12 +509,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
interface IRequires
{
[RequiresUnreferencedCode ("Message for --IRequires.MethodWithRequires--")]
+ [RequiresAssemblyFiles ("Message for --IRequires.MethodWithRequires--")]
public void MethodWithRequires ();
}
class ImplementationClass : IRequires
{
[RequiresUnreferencedCode ("Message for --ImplementationClass.RequiresMethod--")]
+ [RequiresAssemblyFiles ("Message for --ImplementationClass.RequiresMethod--")]
public void MethodWithRequires ()
{
}
@@ -475,12 +525,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
abstract class CovariantReturnBase
{
[RequiresUnreferencedCode ("Message for --CovariantReturnBase.GetRequires--")]
+ [RequiresAssemblyFiles ("Message for --CovariantReturnBase.GetRequires--")]
public abstract BaseReturnType GetRequires ();
}
class CovariantReturnDerived : CovariantReturnBase
{
[RequiresUnreferencedCode ("Message for --CovariantReturnDerived.GetRequires--")]
+ [RequiresAssemblyFiles ("Message for --CovariantReturnDerived.GetRequires--")]
public override DerivedReturnType GetRequires ()
{
return null;
@@ -489,6 +541,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[LogDoesNotContain ("--CovariantReturnBase.GetRequires--")]
[ExpectedWarning ("IL2026", "--CovariantReturnDerived.GetRequires--")]
+ [ExpectedWarning ("IL3002", "--CovariantReturnDerived.GetRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestCovariantReturnCallOnDerived ()
{
var tmp = new CovariantReturnDerived ();
@@ -496,6 +549,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--Method--")]
+ [ExpectedWarning ("IL3002", "--Method--", ProducedBy = ProducedBy.Analyzer)]
static void TestRequiresInMethodFromCopiedAssembly ()
{
var tmp = new RequiresInCopyAssembly ();
@@ -516,11 +570,13 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Message for --RequiresInDynamicDependency--")]
+ [RequiresAssemblyFiles ("Message for --RequiresInDynamicDependency--")]
static void RequiresInDynamicDependency ()
{
}
[ExpectedWarning ("IL2026", "--RequiresInDynamicDependency--")]
+ [ExpectedWarning ("IL3002", "--RequiresInDynamicDependency--", ProducedBy = ProducedBy.Analyzer)]
[DynamicDependency ("RequiresInDynamicDependency")]
static void TestRequiresInDynamicDependency ()
{
@@ -528,22 +584,27 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Linker adds a trailing period to this message")]
+ [RequiresAssemblyFiles ("Linker adds a trailing period to this message")]
static void WarningMessageWithoutEndingPeriod ()
{
}
[ExpectedWarning ("IL2026", "Linker adds a trailing period to this message.")]
+ [ExpectedWarning ("IL3002", "Linker adds a trailing period to this message.", ProducedBy = ProducedBy.Analyzer)]
static void TestThatTrailingPeriodIsAddedToMessage ()
{
WarningMessageWithoutEndingPeriod ();
}
[RequiresUnreferencedCode ("Linker does not add a period to this message.")]
+ [RequiresAssemblyFiles ("Linker does not add a period to this message.")]
static void WarningMessageEndsWithPeriod ()
{
}
+ [LogDoesNotContain ("Linker does not add a period to this message..")]
[ExpectedWarning ("IL2026", "Linker does not add a period to this message.")]
+ [ExpectedWarning ("IL3002", "Linker does not add a period to this message.", ProducedBy = ProducedBy.Analyzer)]
static void TestThatTrailingPeriodIsNotDuplicatedInWarningMessage ()
{
WarningMessageEndsWithPeriod ();
@@ -570,6 +631,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class AttributeWhichRequiresAttribute : Attribute
{
[RequiresUnreferencedCode ("Message for --AttributeWhichRequiresAttribute.ctor--")]
+ [RequiresAssemblyFiles ("Message for --AttributeWhichRequiresAttribute.ctor--")]
public AttributeWhichRequiresAttribute ()
{
}
@@ -585,17 +647,20 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
get => false;
[RequiresUnreferencedCode ("--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")]
+ [RequiresAssemblyFiles ("--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")]
set { }
}
}
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = ProducedBy.Analyzer)]
class GenericTypeWithAttributedParameter<[AttributeWhichRequires] T>
{
public static void TestMethod () { }
}
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = ProducedBy.Analyzer)]
static void GenericMethodWithAttributedParameter<[AttributeWhichRequires] T> () { }
static void TestRequiresOnAttributeOnGenericParameter ()
@@ -605,7 +670,9 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = ProducedBy.Analyzer)]
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = ProducedBy.Analyzer)]
[AttributeWhichRequires]
[AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)]
class TypeWithAttributeWhichRequires
@@ -613,19 +680,25 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = ProducedBy.Analyzer)]
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = ProducedBy.Analyzer)]
[AttributeWhichRequires]
[AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)]
static void MethodWithAttributeWhichRequires () { }
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = ProducedBy.Analyzer)]
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = ProducedBy.Analyzer)]
[AttributeWhichRequires]
[AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)]
static int _fieldWithAttributeWhichRequires;
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", ProducedBy = ProducedBy.Analyzer)]
[ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")]
+ [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", ProducedBy = ProducedBy.Analyzer)]
[AttributeWhichRequires]
[AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)]
static bool PropertyWithAttributeWhichRequires { get; set; }
@@ -633,9 +706,11 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[AttributeWhichRequires]
[AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)]
[RequiresUnreferencedCode ("--MethodWhichRequiresWithAttributeWhichRequires--")]
+ [RequiresAssemblyFiles ("--MethodWhichRequiresWithAttributeWhichRequires--")]
static void MethodWhichRequiresWithAttributeWhichRequires () { }
[ExpectedWarning ("IL2026", "--MethodWhichRequiresWithAttributeWhichRequires--")]
+ [ExpectedWarning ("IL3002", "--MethodWhichRequiresWithAttributeWhichRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestMethodWhichRequiresWithAttributeWhichRequires ()
{
MethodWhichRequiresWithAttributeWhichRequires ();
@@ -662,10 +737,12 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class GenericWithStaticMethod<T>
{
[RequiresUnreferencedCode ("Message for --GenericTypeWithStaticMethodWhichRequires--")]
+ [RequiresAssemblyFiles ("Message for --GenericTypeWithStaticMethodWhichRequires--")]
public static void GenericTypeWithStaticMethodWhichRequires () { }
}
[ExpectedWarning ("IL2026", "--GenericTypeWithStaticMethodWhichRequires--")]
+ [ExpectedWarning ("IL3002", "--GenericTypeWithStaticMethodWhichRequires--", ProducedBy = ProducedBy.Analyzer)]
public static void GenericTypeWithStaticMethodViaLdftn ()
{
var _ = new Action (GenericWithStaticMethod<TestType>.GenericTypeWithStaticMethodWhichRequires);
@@ -682,12 +759,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
abstract class Base
{
[RequiresUnreferencedCode ("Message for --CovariantReturnViaLdftn.Base.GetRequires--")]
+ [RequiresAssemblyFiles ("Message for --CovariantReturnViaLdftn.Base.GetRequires--")]
public abstract BaseReturnType GetRequires ();
}
class Derived : Base
{
[RequiresUnreferencedCode ("Message for --CovariantReturnViaLdftn.Derived.GetRequires--")]
+ [RequiresAssemblyFiles ("Message for --CovariantReturnViaLdftn.Derived.GetRequires--")]
public override DerivedReturnType GetRequires ()
{
return null;
@@ -695,6 +774,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--CovariantReturnViaLdftn.Derived.GetRequires--")]
+ [ExpectedWarning ("IL3002", "--CovariantReturnViaLdftn.Derived.GetRequires--", ProducedBy = ProducedBy.Analyzer)]
public static void Test ()
{
var tmp = new Derived ();
@@ -748,18 +828,22 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
static event EventHandler EventToTestRemove {
add { }
[RequiresUnreferencedCode ("Message for --EventToTestRemove.remove--")]
+ [RequiresAssemblyFiles ("Message for --EventToTestRemove.remove--")]
remove { }
}
[ExpectedWarning ("IL2026", "--EventToTestAdd.add--", ProducedBy = ProducedBy.Trimmer)]
static event EventHandler EventToTestAdd {
[RequiresUnreferencedCode ("Message for --EventToTestAdd.add--")]
+ [RequiresAssemblyFiles ("Message for --EventToTestAdd.add--")]
add { }
remove { }
}
[ExpectedWarning ("IL2026", "--EventToTestRemove.remove--")]
+ [ExpectedWarning ("IL3002", "--EventToTestRemove.remove--", ProducedBy = ProducedBy.Analyzer)]
[ExpectedWarning ("IL2026", "--EventToTestAdd.add--")]
+ [ExpectedWarning ("IL3002", "--EventToTestAdd.add--", ProducedBy = ProducedBy.Analyzer)]
public static void Test ()
{
EventToTestRemove -= (sender, e) => { };
@@ -772,12 +856,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class NewConstraintTestType
{
[RequiresUnreferencedCode ("Message for --NewConstraintTestType.ctor--")]
+ [RequiresAssemblyFiles ("Message for --NewConstraintTestType.ctor--")]
public NewConstraintTestType () { }
}
static void GenericMethod<T> () where T : new() { }
[ExpectedWarning ("IL2026", "--NewConstraintTestType.ctor--")]
+ [ExpectedWarning ("IL3002", "--NewConstraintTestType.ctor--", ProducedBy = ProducedBy.Analyzer)]
public static void Test ()
{
GenericMethod<NewConstraintTestType> ();
@@ -793,12 +879,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--NewConstraintTestType.ctor--")]
+ [ExpectedWarning ("IL3002", "--NewConstraintTestType.ctor--", ProducedBy = ProducedBy.Analyzer)]
public static void TestNewConstraintOnTypeParameter ()
{
_ = new NewConstaintOnTypeParameter<NewConstraintTestType> ();
}
[ExpectedWarning ("IL2026", "--NewConstraintTestType.ctor--")]
+ [ExpectedWarning ("IL3002", "--NewConstraintTestType.ctor--", ProducedBy = ProducedBy.Analyzer)]
public static void TestNewConstraintOnTypeParameterOfStaticType ()
{
NewConstraintOnTypeParameterOfStaticType<NewConstraintTestType>.DoNothing ();
@@ -809,18 +897,283 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
{
static bool PropertyWithLdToken {
[RequiresUnreferencedCode ("Message for --PropertyWithLdToken.get--")]
+ [RequiresAssemblyFiles ("Message for --PropertyWithLdToken.get--")]
get {
return false;
}
}
[ExpectedWarning ("IL2026", "--PropertyWithLdToken.get--")]
+ [ExpectedWarning ("IL3002", "--PropertyWithLdToken.get--", ProducedBy = ProducedBy.Analyzer)]
public static void Test ()
{
Expression<Func<bool>> getter = () => PropertyWithLdToken;
}
}
+ class AttributeMismatch
+ {
+ static void RequirePublicMethods ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type)
+ {
+ }
+
+ class BaseClassWithRequires
+ {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ public virtual void VirtualMethod ()
+ {
+ }
+
+ public virtual string VirtualPropertyAnnotationInAccesor {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ get;
+ set;
+ }
+
+ [RequiresAssemblyFiles ("Message")]
+ public virtual string VirtualPropertyAnnotationInProperty { get; set; }
+ }
+
+ class BaseClassWithoutRequires
+ {
+ public virtual void VirtualMethod ()
+ {
+ }
+
+ public virtual string VirtualPropertyAnnotationInAccesor { get; set; }
+
+ public virtual string VirtualPropertyAnnotationInProperty { get; set; }
+ }
+
+ class DerivedClassWithRequires : BaseClassWithoutRequires
+ {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL2046", "DerivedClassWithRequires.VirtualMethod()", "BaseClassWithoutRequires.VirtualMethod()")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithRequires.VirtualMethod()", "BaseClassWithoutRequires.VirtualMethod()", ProducedBy = ProducedBy.Analyzer)]
+ public override void VirtualMethod ()
+ {
+ }
+
+ private string name;
+ public override string VirtualPropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "DerivedClassWithRequires.VirtualPropertyAnnotationInAccesor.get", "BaseClassWithoutRequires.VirtualPropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithRequires.VirtualPropertyAnnotationInAccesor.get", "BaseClassWithoutRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithRequires.VirtualPropertyAnnotationInProperty", "BaseClassWithoutRequires.VirtualPropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ public override string VirtualPropertyAnnotationInProperty { get; set; }
+ }
+
+ class DerivedClassWithoutRequires : BaseClassWithRequires
+ {
+ [ExpectedWarning ("IL2046", "DerivedClassWithoutRequires.VirtualMethod()", "BaseClassWithRequires.VirtualMethod()")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithoutRequires.VirtualMethod()", "BaseClassWithRequires.VirtualMethod()", ProducedBy = ProducedBy.Analyzer)]
+ public override void VirtualMethod ()
+ {
+ }
+
+ private string name;
+ public override string VirtualPropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "DerivedClassWithoutRequires.VirtualPropertyAnnotationInAccesor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "DerivedClassWithoutRequires.VirtualPropertyAnnotationInAccesor.get", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [ExpectedWarning ("IL3003", "DerivedClassWithoutRequires.VirtualPropertyAnnotationInProperty", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ public override string VirtualPropertyAnnotationInProperty { get; set; }
+ }
+
+ public interface IBaseWithRequires
+ {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ void Method ();
+
+ string PropertyAnnotationInAccesor {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ get;
+ set;
+ }
+
+ [RequiresAssemblyFiles ("Message")]
+ string PropertyAnnotationInProperty { get; set; }
+ }
+
+ public interface IBaseWithoutRequires
+ {
+ void Method ();
+
+ string PropertyAnnotationInAccesor { get; set; }
+
+ string PropertyAnnotationInProperty { get; set; }
+ }
+
+ class ImplementationClassWithRequires : IBaseWithoutRequires
+ {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL2046", "ImplementationClassWithRequires.Method()", "IBaseWithoutRequires.Method()")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequires.Method()", "IBaseWithoutRequires.Method()", ProducedBy = ProducedBy.Analyzer)]
+ public void Method ()
+ {
+ }
+
+ private string name;
+ public string PropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "ImplementationClassWithRequires.PropertyAnnotationInAccesor.get", "IBaseWithoutRequires.PropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequires.PropertyAnnotationInAccesor.get", "IBaseWithoutRequires.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequires.PropertyAnnotationInProperty", "IBaseWithoutRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ public string PropertyAnnotationInProperty { get; set; }
+ }
+
+ class ExplicitImplementationClassWithRequires : IBaseWithoutRequires
+ {
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL2046", "ExplicitImplementationClassWithRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithoutRequires.Method()", "IBaseWithoutRequires.Method()")]
+ [ExpectedWarning ("IL3003", "ExplicitImplementationClassWithRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithoutRequires.Method()", "IBaseWithoutRequires.Method()", ProducedBy = ProducedBy.Analyzer)]
+ void IBaseWithoutRequires.Method ()
+ {
+ }
+
+ private string name;
+ string IBaseWithoutRequires.PropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "PropertyAnnotationInAccesor.get", "IBaseWithoutRequires.PropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "PropertyAnnotationInAccesor.get", "IBaseWithoutRequires.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [RequiresAssemblyFiles ("Message")]
+ [ExpectedWarning ("IL3003", "ExplicitImplementationClassWithRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithoutRequires.PropertyAnnotationInProperty", "IBaseWithoutRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ string IBaseWithoutRequires.PropertyAnnotationInProperty { get; set; }
+ }
+
+ class ImplementationClassWithoutRequires : IBaseWithRequires
+ {
+ [ExpectedWarning ("IL2046", "ImplementationClassWithoutRequires.Method()", "IBaseWithRequires.Method()")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequires.Method()", "IBaseWithRequires.Method()", ProducedBy = ProducedBy.Analyzer)]
+ public void Method ()
+ {
+ }
+
+ private string name;
+ public string PropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "ImplementationClassWithoutRequires.PropertyAnnotationInAccesor.get", "IBaseWithRequires.PropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequires.PropertyAnnotationInAccesor.get", "IBaseWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequires.PropertyAnnotationInProperty", "IBaseWithRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ public string PropertyAnnotationInProperty { get; set; }
+ }
+
+ class ExplicitImplementationClassWithoutRequires : IBaseWithRequires
+ {
+ [ExpectedWarning ("IL2046", "IBaseWithRequires.Method()", "ExplicitImplementationClassWithoutRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithRequires.Method()")]
+ [ExpectedWarning ("IL3003", "IBaseWithRequires.Method()", "ExplicitImplementationClassWithoutRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithRequires.Method()", ProducedBy = ProducedBy.Analyzer)]
+ void IBaseWithRequires.Method ()
+ {
+ }
+
+ private string name;
+ string IBaseWithRequires.PropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "PropertyAnnotationInAccesor.get", "IBaseWithRequires.PropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "PropertyAnnotationInAccesor.get", "IBaseWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [ExpectedWarning ("IL3003", "ExplicitImplementationClassWithoutRequires.Mono.Linker.Tests.Cases.RequiresCapability.RequiresCapability.AttributeMismatch.IBaseWithRequires.PropertyAnnotationInProperty", "IBaseWithRequires.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ string IBaseWithRequires.PropertyAnnotationInProperty { get; set; }
+ }
+
+ class ImplementationClassWithoutRequiresInSource : ReferenceInterfaces.IBaseWithRequiresInReference
+ {
+ [ExpectedWarning ("IL2046", "ImplementationClassWithoutRequiresInSource.Method()", "IBaseWithRequiresInReference.Method()")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequiresInSource.Method()", "IBaseWithRequiresInReference.Method()", ProducedBy = ProducedBy.Analyzer)]
+ public void Method ()
+ {
+ }
+
+ private string name;
+ public string PropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "ImplementationClassWithoutRequiresInSource.PropertyAnnotationInAccesor.get", "IBaseWithRequiresInReference.PropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequiresInSource.PropertyAnnotationInAccesor.get", "IBaseWithRequiresInReference.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [ExpectedWarning ("IL3003", "ImplementationClassWithoutRequiresInSource.PropertyAnnotationInProperty", "IBaseWithRequiresInReference.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ public string PropertyAnnotationInProperty { get; set; }
+ }
+
+ class ImplementationClassWithRequiresInSource : ReferenceInterfaces.IBaseWithoutRequiresInReference
+ {
+ [ExpectedWarning ("IL2046", "ImplementationClassWithRequiresInSource.Method()", "IBaseWithoutRequiresInReference.Method()")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequiresInSource.Method()", "IBaseWithoutRequiresInReference.Method()", ProducedBy = ProducedBy.Analyzer)]
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ public void Method ()
+ {
+ }
+
+ private string name;
+ public string PropertyAnnotationInAccesor {
+ [ExpectedWarning ("IL2046", "ImplementationClassWithRequiresInSource.PropertyAnnotationInAccesor.get", "IBaseWithoutRequiresInReference.PropertyAnnotationInAccesor.get")]
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequiresInSource.PropertyAnnotationInAccesor.get", "IBaseWithoutRequiresInReference.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Analyzer)]
+ [RequiresUnreferencedCode ("Message")]
+ [RequiresAssemblyFiles ("Message")]
+ get { return name; }
+ set { name = value; }
+ }
+
+ [ExpectedWarning ("IL3003", "ImplementationClassWithRequiresInSource.PropertyAnnotationInProperty", "IBaseWithoutRequiresInReference.PropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
+ [RequiresAssemblyFiles ("Message")]
+ public string PropertyAnnotationInProperty { get; set; }
+ }
+
+ [ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Trimmer)]
+ [ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualMethod()", ProducedBy = ProducedBy.Trimmer)]
+ [ExpectedWarning ("IL2026", "IBaseWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = ProducedBy.Trimmer)]
+ [ExpectedWarning ("IL2026", "IBaseWithRequires.Method()", ProducedBy = ProducedBy.Trimmer)]
+ public static void Test ()
+ {
+ RequirePublicMethods (typeof (BaseClassWithRequires));
+ RequirePublicMethods (typeof (BaseClassWithoutRequires));
+ RequirePublicMethods (typeof (DerivedClassWithRequires));
+ RequirePublicMethods (typeof (DerivedClassWithoutRequires));
+ RequirePublicMethods (typeof (IBaseWithRequires));
+ RequirePublicMethods (typeof (IBaseWithoutRequires));
+ RequirePublicMethods (typeof (ImplementationClassWithRequires));
+ RequirePublicMethods (typeof (ImplementationClassWithoutRequires));
+ RequirePublicMethods (typeof (ExplicitImplementationClassWithRequires));
+ RequirePublicMethods (typeof (ExplicitImplementationClassWithoutRequires));
+ RequirePublicMethods (typeof (ImplementationClassWithoutRequiresInSource));
+ RequirePublicMethods (typeof (ImplementationClassWithRequiresInSource));
+ }
+ }
+
class RequiresOnClass
{
[RequiresUnreferencedCode ("Message for --ClassWithRequires--")]
@@ -1572,7 +1925,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
public static int field;
// `field` cannot be used as named attribute argument because is static, and if accessed via
- // a property the property will be the one generating the warning, but then the warning will
+ // a property the property will be the one generating the warning, but then the warning will
// be suppresed by the Requires on the declaring type
public int PropertyOnAttribute {
get { return field; }
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapabilityFromCopiedAssembly.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapabilityFromCopiedAssembly.cs
index b30833564..6036d7044 100644
--- a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapabilityFromCopiedAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresCapabilityFromCopiedAssembly.cs
@@ -11,6 +11,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[SetupCompileBefore ("lib.dll", new[] { "Dependencies/RequiresInCopyAssembly.cs" })]
[KeptAllTypesAndMembersInAssembly ("lib.dll")]
[LogDoesNotContain ("IL2026")]
+ [LogDoesNotContain ("IL3002")]
[LogDoesNotContain ("IL2027")]
public class RequiresCapabilityFromCopiedAssembly
{
diff --git a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInCompilerGeneratedCode.cs b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInCompilerGeneratedCode.cs
index 26777a1a8..0adbae0d6 100644
--- a/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInCompilerGeneratedCode.cs
+++ b/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInCompilerGeneratedCode.cs
@@ -44,6 +44,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class WarnInIteratorBody
{
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static IEnumerable<int> TestCallBeforeYieldReturn ()
{
MethodWithRequires ();
@@ -51,6 +52,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static IEnumerable<int> TestCallAfterYieldReturn ()
{
yield return 0;
@@ -68,6 +70,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static IEnumerable<int> TestLdftn ()
{
yield return 0;
@@ -75,6 +78,18 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
var action = new Action (MethodWithRequires);
}
+ // Cannot annotate fields either with RUC nor RAF therefore the warning persists
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static IEnumerable<int> TestLazyDelegate ()
+ {
+ yield return 0;
+ yield return 1;
+ _ = _default.Value;
+ }
+
[ExpectedWarning ("IL2026", "--TypeWithMethodWithRequires.MethodWithRequires--", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
static IEnumerable<int> TestDynamicallyAccessedMethod ()
{
@@ -89,6 +104,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
TestCallAfterYieldReturn ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
}
}
@@ -96,6 +112,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class SuppressInIteratorBody
{
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestCall ()
{
MethodWithRequires ();
@@ -105,6 +122,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestReflectionAccess ()
{
yield return 0;
@@ -115,6 +133,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestLdftn ()
{
yield return 0;
@@ -122,7 +141,20 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
var action = new Action (MethodWithRequires);
}
+ // Cannot annotate fields either with RUC nor RAF therefore the warning persists
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static IEnumerable<int> TestLazyDelegate ()
+ {
+ yield return 0;
+ yield return 1;
+ _ = _default.Value;
+ }
+
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestDynamicallyAccessedMethod ()
{
typeof (TypeWithMethodWithRequires).RequiresNonPublicMethods ();
@@ -131,6 +163,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestMethodParameterWithRequirements (Type unknownType = null)
{
unknownType.RequiresNonPublicMethods ();
@@ -138,6 +171,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestGenericMethodParameterRequirement<TUnknown> ()
{
MethodWithGenericWhichRequiresMethods<TUnknown> ();
@@ -145,6 +179,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestGenericTypeParameterRequirement<TUnknown> ()
{
new TypeWithGenericWhichRequiresNonPublicFields<TUnknown> ();
@@ -152,11 +187,13 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestCall ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
TestMethodParameterWithRequirements ();
TestGenericMethodParameterRequirement<TestType> ();
@@ -167,6 +204,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class WarnInAsyncBody
{
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static async void TestCallBeforeYieldReturn ()
{
MethodWithRequires ();
@@ -174,6 +212,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static async void TestCallAfterYieldReturn ()
{
await MethodAsync ();
@@ -191,12 +230,23 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static async void TestLdftn ()
{
await MethodAsync ();
var action = new Action (MethodWithRequires);
}
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static async void TestLazyDelegate ()
+ {
+ await MethodAsync ();
+ _ = _default.Value;
+ }
+
[ExpectedWarning ("IL2026", "--TypeWithMethodWithRequires.MethodWithRequires--", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
static async void TestDynamicallyAccessedMethod ()
{
@@ -210,6 +260,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
TestCallAfterYieldReturn ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
}
}
@@ -217,6 +268,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class SuppressInAsyncBody
{
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestCall ()
{
MethodWithRequires ();
@@ -226,6 +278,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestReflectionAccess ()
{
await MethodAsync ();
@@ -236,13 +289,26 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestLdftn ()
{
await MethodAsync ();
var action = new Action (MethodWithRequires);
}
+ // Cannot annotate fields either with RUC nor RAF therefore the warning persists
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static async void TestLazyDelegate ()
+ {
+ await MethodAsync ();
+ _ = _default.Value;
+ }
+
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestDynamicallyAccessedMethod ()
{
typeof (TypeWithMethodWithRequires).RequiresNonPublicMethods ();
@@ -250,6 +316,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestMethodParameterWithRequirements (Type unknownType = null)
{
unknownType.RequiresNonPublicMethods ();
@@ -257,6 +324,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestGenericMethodParameterRequirement<TUnknown> ()
{
MethodWithGenericWhichRequiresMethods<TUnknown> ();
@@ -264,6 +332,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestGenericTypeParameterRequirement<TUnknown> ()
{
new TypeWithGenericWhichRequiresNonPublicFields<TUnknown> ();
@@ -271,11 +340,13 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestCall ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
TestMethodParameterWithRequirements ();
TestGenericMethodParameterRequirement<TestType> ();
@@ -286,6 +357,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class WarnInAsyncIteratorBody
{
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static async IAsyncEnumerable<int> TestCallBeforeYieldReturn ()
{
await MethodAsync ();
@@ -294,6 +366,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static async IAsyncEnumerable<int> TestCallAfterYieldReturn ()
{
yield return 0;
@@ -314,6 +387,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static async IAsyncEnumerable<int> TestLdftn ()
{
await MethodAsync ();
@@ -321,6 +395,17 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
var action = new Action (MethodWithRequires);
}
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static async IAsyncEnumerable<int> TestLazyDelegate ()
+ {
+ await MethodAsync ();
+ yield return 0;
+ _ = _default.Value;
+ }
+
[ExpectedWarning ("IL2026", "--TypeWithMethodWithRequires.MethodWithRequires--", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
static async IAsyncEnumerable<int> TestDynamicallyAccessedMethod ()
{
@@ -335,6 +420,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
TestCallAfterYieldReturn ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
}
}
@@ -342,6 +428,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class SuppressInAsyncIteratorBody
{
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async IAsyncEnumerable<int> TestCall ()
{
MethodWithRequires ();
@@ -352,6 +439,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async IAsyncEnumerable<int> TestReflectionAccess ()
{
await MethodAsync ();
@@ -364,6 +452,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async IAsyncEnumerable<int> TestLdftn ()
{
await MethodAsync ();
@@ -371,7 +460,20 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
yield return 0;
}
+ // Cannot annotate fields either with RUC nor RAF therefore the warning persists
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static async IAsyncEnumerable<int> TestLazyDelegate ()
+ {
+ await MethodAsync ();
+ yield return 0;
+ _ = _default.Value;
+ }
+
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async IAsyncEnumerable<int> TestDynamicallyAccessedMethod ()
{
typeof (TypeWithMethodWithRequires).RequiresNonPublicMethods ();
@@ -380,6 +482,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async IAsyncEnumerable<int> TestMethodParameterWithRequirements (Type unknownType = null)
{
unknownType.RequiresNonPublicMethods ();
@@ -388,6 +491,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async IAsyncEnumerable<int> TestGenericMethodParameterRequirement<TUnknown> ()
{
yield return 0;
@@ -396,6 +500,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async IAsyncEnumerable<int> TestGenericTypeParameterRequirement<TUnknown> ()
{
new TypeWithGenericWhichRequiresNonPublicFields<TUnknown> ();
@@ -404,11 +509,13 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestCall ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
TestMethodParameterWithRequirements ();
TestGenericMethodParameterRequirement<TestType> ();
@@ -419,6 +526,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class WarnInLocalFunction
{
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestCall ()
{
LocalFunction ();
@@ -427,6 +535,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestCallWithClosure (int p = 0)
{
LocalFunction ();
@@ -449,6 +558,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestLdftn ()
{
LocalFunction ();
@@ -459,6 +569,20 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
}
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static void TestLazyDelegate ()
+ {
+ LocalFunction ();
+
+ void LocalFunction ()
+ {
+ _ = _default.Value;
+ }
+ }
+
[ExpectedWarning ("IL2026", "--TypeWithMethodWithRequires.MethodWithRequires--", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
static void TestDynamicallyAccessedMethod ()
{
@@ -473,6 +597,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
TestCallWithClosure ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
}
}
@@ -483,20 +608,24 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
// so its suppression effect also doesn't propagate
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestCall ()
{
LocalFunction ();
[ExpectedWarning ("IL2026")]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
void LocalFunction () => MethodWithRequires ();
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestCallWithClosure (int p = 0)
{
LocalFunction ();
[ExpectedWarning ("IL2026")]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
void LocalFunction ()
{
p++;
@@ -505,38 +634,59 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestReflectionAccess ()
{
LocalFunction ();
[ExpectedWarning ("IL2026")]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
void LocalFunction () => typeof (RequiresInCompilerGeneratedCode)
.GetMethod ("MethodWithRequires", System.Reflection.BindingFlags.NonPublic)
.Invoke (null, new object[] { });
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestLdftn ()
{
LocalFunction ();
[ExpectedWarning ("IL2026")]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
void LocalFunction ()
{
var action = new Action (MethodWithRequires);
}
}
+ [ExpectedWarning ("IL2026", "Message from --MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "Message from --MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static void TestLazyDelegate ()
+ {
+ LocalFunction ();
+
+ void LocalFunction ()
+ {
+ _ = _default.Value;
+ }
+ }
+
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestDynamicallyAccessedMethod ()
{
LocalFunction ();
[ExpectedWarning ("IL2026")]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
void LocalFunction () => typeof (TypeWithMethodWithRequires).RequiresNonPublicMethods ();
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestMethodParameterWithRequirements (Type unknownType = null)
{
LocalFunction ();
@@ -546,6 +696,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestGenericMethodParameterRequirement<TUnknown> ()
{
LocalFunction ();
@@ -555,6 +706,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestGenericTypeParameterRequirement<TUnknown> ()
{
LocalFunction ();
@@ -564,6 +716,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestGenericLocalFunction<TUnknown> ()
{
LocalFunction<TUnknown> ();
@@ -575,6 +728,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestGenericLocalFunctionInner<TUnknown> ()
{
LocalFunction<TUnknown> ();
@@ -611,22 +765,26 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestCallMethodWithRequiresInLtftnLocalFunction ()
{
var _ = new Action (LocalFunction);
[ExpectedWarning ("IL2026")]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
void LocalFunction () => MethodWithRequires ();
}
class DynamicallyAccessedLocalFunction
{
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
public static void TestCallMethodWithRequiresInDynamicallyAccessedLocalFunction ()
{
typeof (DynamicallyAccessedLocalFunction).RequiresNonPublicMethods ();
[ExpectedWarning ("IL2026")]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
void LocalFunction () => MethodWithRequires ();
}
}
@@ -640,6 +798,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
LocalFunction (); // This will produce a warning since the location function has Requires on it
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
void LocalFunction (Type unknownType = null)
{
MethodWithRequires ();
@@ -648,11 +807,13 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestSuppressionOnOuterAndLocalFunction ()
{
LocalFunction ();
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
void LocalFunction (Type unknownType = null)
{
MethodWithRequires ();
@@ -661,12 +822,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestCall ();
TestCallWithClosure ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestMethodParameterWithRequirements ();
TestDynamicallyAccessedMethod ();
TestGenericMethodParameterRequirement<TestType> ();
@@ -685,12 +848,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class WarnInLambda
{
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestCall ()
{
Action _ = () => MethodWithRequires ();
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestCallWithClosure (int p = 0)
{
Action _ = () => {
@@ -710,6 +875,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static void TestLdftn ()
{
Action _ = () => {
@@ -717,6 +883,17 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
};
}
+ [ExpectedWarning ("IL2026", "--MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static void TestLazyDelegate ()
+ {
+ Action _ = () => {
+ var action = _default.Value;
+ };
+ }
+
[ExpectedWarning ("IL2026", "--TypeWithMethodWithRequires.MethodWithRequires--", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
static void TestDynamicallyAccessedMethod ()
{
@@ -731,6 +908,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
TestCallWithClosure ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
}
}
@@ -744,7 +922,9 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
// - Would be useful for testing - have to use the CompilerGeneratedCode = true trick instead
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestCall ()
{
Action _ = () => MethodWithRequires ();
@@ -752,6 +932,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL2067", CompilerGeneratedCode = true)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestCallWithReflectionAnalysisWarning ()
{
// This should not produce warning because the Requires
@@ -759,7 +940,9 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestCallWithClosure (int p = 0)
{
Action _ = () => {
@@ -771,6 +954,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
// Analyzer doesn't recognize reflection access - so doesn't warn in this case
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestReflectionAccess ()
{
Action _ = () => {
@@ -781,7 +965,9 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestLdftn ()
{
Action _ = () => {
@@ -789,9 +975,21 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
};
}
+ [ExpectedWarning ("IL2026", "--MethodWithRequiresAndReturns--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequiresAndReturns--", ProducedBy = ProducedBy.Analyzer)]
+ public static Lazy<string> _default = new Lazy<string> (MethodWithRequiresAndReturns);
+
+ static void TestLazyDelegate ()
+ {
+ Action _ = () => {
+ var action = _default.Value;
+ };
+ }
+
// Analyzer doesn't apply DAM - so won't see this warnings
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestDynamicallyAccessedMethod ()
{
Action _ = () => {
@@ -804,6 +1002,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL2077", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
[ExpectedWarning ("IL2067", ProducedBy = ProducedBy.Analyzer)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestMethodParameterWithRequirements (Type unknownType = null)
{
Action _ = () => unknownType.RequiresNonPublicMethods ();
@@ -811,6 +1010,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
[ExpectedWarning ("IL2091", CompilerGeneratedCode = true)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestGenericMethodParameterRequirement<TUnknown> ()
{
Action _ = () => {
@@ -821,6 +1021,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
// The warning is currently not detected by roslyn analyzer since it doesn't analyze DAM yet
[ExpectedWarning ("IL2091", CompilerGeneratedCode = true, ProducedBy = ProducedBy.Trimmer)]
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static void TestGenericTypeParameterRequirement<TUnknown> ()
{
Action _ = () => {
@@ -829,6 +1030,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestCall ();
@@ -836,6 +1038,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
TestCallWithClosure ();
TestReflectionAccess ();
TestLdftn ();
+ TestLazyDelegate ();
TestDynamicallyAccessedMethod ();
TestMethodParameterWithRequirements ();
TestGenericMethodParameterRequirement<TestType> ();
@@ -846,6 +1049,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class WarnInComplex
{
[ExpectedWarning ("IL2026", "--MethodWithRequires--", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", "--MethodWithRequires--", ProducedBy = ProducedBy.Analyzer)]
static async void TestIteratorLocalFunctionInAsync ()
{
await MethodAsync ();
@@ -877,6 +1081,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class SuppressInComplex
{
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestIteratorLocalFunctionInAsync ()
{
await MethodAsync ();
@@ -884,6 +1089,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
await MethodAsync ();
[RequiresUnreferencedCode ("Suppress in local function")]
+ [RequiresAssemblyFiles ("Suppress in local function")]
IEnumerable<int> LocalFunction ()
{
yield return 0;
@@ -893,6 +1099,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static async void TestIteratorLocalFunctionInAsyncWithoutInner ()
{
await MethodAsync ();
@@ -900,6 +1107,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
await MethodAsync ();
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
IEnumerable<int> LocalFunction ()
{
yield return 0;
@@ -909,6 +1117,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Suppress in body")]
+ [RequiresAssemblyFiles ("Suppress in body")]
static IEnumerable<int> TestDynamicallyAccessedMethodViaGenericMethodParameterInIterator ()
{
MethodWithGenericWhichRequiresMethods<TypeWithMethodWithRequires> ();
@@ -916,6 +1125,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[UnconditionalSuppressMessage ("Trimming", "IL2026")]
+ [UnconditionalSuppressMessage ("SingleFile", "IL3002")]
public static void Test ()
{
TestIteratorLocalFunctionInAsync ();
@@ -927,6 +1137,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class StateMachinesOnlyReferencedViaReflection
{
[RequiresUnreferencedCode ("Requires to suppress")]
+ [RequiresAssemblyFiles ("Requires to suppress")]
static IEnumerable<int> TestIteratorOnlyReferencedViaReflectionWhichShouldSuppress ()
{
yield return 0;
@@ -934,6 +1145,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("Requires to suppress")]
+ [RequiresAssemblyFiles ("Requires to suppress")]
static async void TestAsyncOnlyReferencedViaReflectionWhichShouldSuppress ()
{
await MethodAsync ();
@@ -941,6 +1153,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
static IEnumerable<int> TestIteratorOnlyReferencedViaReflectionWhichShouldWarn ()
{
yield return 0;
@@ -948,6 +1161,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", CompilerGeneratedCode = true)]
+ [ExpectedWarning ("IL3002", ProducedBy = ProducedBy.Analyzer)]
static async void TestAsyncOnlyReferencedViaReflectionWhichShouldWarn ()
{
await MethodAsync ();
@@ -969,12 +1183,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
public class AsyncBodyCallingMethodWithRequires
{
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static Task<object> MethodWithRequiresAsync (Type type)
{
return Task.FromResult (new object ());
}
[RequiresUnreferencedCode ("ParentSuppression")]
+ [RequiresAssemblyFiles ("ParentSuppression")]
static async Task<object> AsyncMethodCallingRequires (Type type)
{
using (var diposable = await GetDisposableAsync ()) {
@@ -983,6 +1199,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "ParentSuppression")]
+ [ExpectedWarning ("IL3002", "ParentSuppression", ProducedBy = ProducedBy.Analyzer)]
public static void Test ()
{
AsyncMethodCallingRequires (typeof (object));
@@ -992,12 +1209,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
public class GenericAsyncBodyCallingMethodWithRequires
{
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
static ValueTask<TValue> MethodWithRequiresAsync<TValue> ()
{
return ValueTask.FromResult (default (TValue));
}
[RequiresUnreferencedCode ("ParentSuppression")]
+ [RequiresAssemblyFiles ("ParentSuppression")]
static async Task<T> AsyncMethodCallingRequires<T> ()
{
using (var disposable = await GetDisposableAsync ()) {
@@ -1006,6 +1225,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "ParentSuppression")]
+ [ExpectedWarning ("IL3002", "ParentSuppression", ProducedBy = ProducedBy.Analyzer)]
public static void Test ()
{
AsyncMethodCallingRequires<object> ();
@@ -1017,12 +1237,14 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class RequiresOnCtor
{
[RequiresUnreferencedCode ("")]
+ [RequiresAssemblyFiles ("")]
public RequiresOnCtor ()
{
}
}
[RequiresUnreferencedCode ("ParentSuppression")]
+ [RequiresAssemblyFiles ("ParentSuppression")]
static IAsyncEnumerable<TValue> AsyncEnumMethodCallingRequires<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] TValue> ()
{
@@ -1038,6 +1260,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[ExpectedWarning ("IL2026", "ParentSuppression")]
+ [ExpectedWarning ("IL3002", "ParentSuppression", ProducedBy = ProducedBy.Analyzer)]
public static void Test ()
{
AsyncEnumMethodCallingRequires<object> ();
@@ -1055,6 +1278,7 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
}
[RequiresUnreferencedCode ("--MethodWithRequires--")]
+ [RequiresAssemblyFiles ("--MethodWithRequires--")]
static void MethodWithRequires ()
{
}
@@ -1062,11 +1286,19 @@ namespace Mono.Linker.Tests.Cases.RequiresCapability
class TypeWithMethodWithRequires
{
[RequiresUnreferencedCode ("--TypeWithMethodWithRequires.MethodWithRequires--")]
+ [RequiresAssemblyFiles ("--TypeWithMethodWithRequires.MethodWithRequires--")]
static void MethodWithRequires ()
{
}
}
+ [RequiresUnreferencedCode ("Message from --MethodWithRequiresAndReturns--")]
+ [RequiresAssemblyFiles ("Message from --MethodWithRequiresAndReturns--")]
+ public static string MethodWithRequiresAndReturns ()
+ {
+ return "string";
+ }
+
static void MethodWithGenericWhichRequiresMethods<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicMethods)] T> ()
{
}