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:
authorVitek Karas <vitek.karas@microsoft.com>2020-08-13 13:29:44 +0300
committerGitHub <noreply@github.com>2020-08-13 13:29:44 +0300
commit2b04c065c84aa8f30600e3b1989c537fc77de95b (patch)
tree31b6b6d9917eeb48f0a9102d15a89e9721525d80 /test/Mono.Linker.Tests.Cases/DataFlow
parentfc5e4aa86ad543ab3a730e0e0e8dacc6a379d4a5 (diff)
Warnings cleanup (#1385)
The most important change is to make warning codes and messages unique - that is for each code there's exactly one message. This means adding quite a few new codes as we were sharing them rather heavily. We also try to avoid logic when constructing messages (to allow for better localization), so instead of having smaller pieces concatenated we introduce several similar warnings. This change also adds more tests for some of the warnings. Infra changes: * Add the warning code parameter to unrecognized reflection call on the interface * Add a new ExpectedWarning test attribute which validates the code, the location and optionally parts of the message * Improved the unrecognized reflection pattern attribute to accept only parts of the message (and to accept more than one) * Add the ability to validat the warning code for unrecognised reflection patterns * Refactor source context for annotated values Makes the source context required by making it a a .ctor argument for all annotated nodes. Make it IMetadataTokenProvider. Fixes the problem with AnnotatedStringValue which was reported as "unknown" in warning messages. This also slightly changes what is stored in the SourceContext - now it's the actual thing (so ParameterDefinition, MethodReturnType and so on) - so printing it out doesn't require knowing which value node it came from. This is cleaner because the SourceContext describes where the value came from, not what the value is (that's the job of the ValueNode). In warnings we typically don't want to print out what the value is since in most cases we don't know the actual value (we just know things about it), so we can rely on SourceContext to simplify some code. Co-authored-by: Sven Boemer <sbomer@gmail.com>
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/DataFlow')
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs10
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs4
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/DynamicDependencyDataflow.cs4
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs6
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs58
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs224
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs24
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/LocalDataFlow.cs159
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs47
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs61
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs133
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs47
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.cs6
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.xml2
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs60
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.cs4
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.xml2
17 files changed, 511 insertions, 340 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs
index 0de17059c..91435ae06 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs
@@ -18,8 +18,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
TestConstructors ();
}
- [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequirePublicConstructors), new Type[] { typeof (string) })]
- [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequireNonPublicConstructors), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequirePublicConstructors), new Type[] { typeof (string) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequireNonPublicConstructors), new Type[] { typeof (string) }, messageCode: "IL2072")]
static void TestPublicParameterlessConstructor ()
{
string type = GetTypeWithPublicParameterlessConstructor ().AssemblyQualifiedName;
@@ -29,7 +29,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequireNonPublicConstructors), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequireNonPublicConstructors), new Type[] { typeof (string) }, messageCode: "IL2072")]
static void TestPublicConstructors ()
{
string type = GetTypeWithPublicConstructors ().AssemblyQualifiedName;
@@ -39,8 +39,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (string) })]
- [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequirePublicConstructors), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (string) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (AssemblyQualifiedNameDataflow), nameof (RequirePublicConstructors), new Type[] { typeof (string) }, messageCode: "IL2072")]
static void TestConstructors ()
{
string type = GetTypeWithNonPublicConstructors ().AssemblyQualifiedName;
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs
index 2775f82ea..abb12a5bf 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs
@@ -41,14 +41,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow
static Type s_typeWithPublicParameterlessConstructor;
[Kept]
- [UnrecognizedReflectionAccessPattern (typeof (ByRefDataflow), nameof (MethodWithRefParameter), new string[] { "System.Type&" })]
+ [UnrecognizedReflectionAccessPattern (typeof (ByRefDataflow), nameof (MethodWithRefParameter), new string[] { "System.Type&" }, messageCode: "IL2077")]
public static void PassRefToField ()
{
MethodWithRefParameter (ref s_typeWithPublicParameterlessConstructor);
}
[Kept]
- [UnrecognizedReflectionAccessPattern (typeof (ByRefDataflow), nameof (MethodWithRefParameter), new string[] { "System.Type&" })]
+ [UnrecognizedReflectionAccessPattern (typeof (ByRefDataflow), nameof (MethodWithRefParameter), new string[] { "System.Type&" }, messageCode: "IL2067")]
public static void PassRefToParameter (Type parameter)
{
MethodWithRefParameter (ref parameter);
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/DynamicDependencyDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/DynamicDependencyDataflow.cs
index af0760d85..9c1cd8ed8 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/DynamicDependencyDataflow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/DynamicDependencyDataflow.cs
@@ -18,7 +18,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
static Type TypeWithPublicMethods;
[Kept]
- [UnrecognizedReflectionAccessPattern (typeof (Type), "GetField", new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), "GetField", new Type[] { typeof (string) }, messageCode: "IL2080")]
[DynamicDependency ("DynamicDependencyTo")]
static void DynamicDependencyFrom ()
{
@@ -26,7 +26,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[Kept]
- [UnrecognizedReflectionAccessPattern (typeof (Type), "GetProperty", new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), "GetProperty", new Type[] { typeof (string) }, messageCode: "IL2080")]
static void DynamicDependencyTo ()
{
_ = TypeWithPublicMethods.GetProperty ("p");
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs
index ea3c8640e..0fe6f8104 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/EmptyArrayIntrinsicsDataFlow.cs
@@ -19,21 +19,21 @@ namespace Mono.Linker.Tests.Cases.DataFlow
TestGetPublicParameterlessConstructorWithUnknownArray ();
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetMethod), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetMethod), new Type[] { typeof (string) }, messageCode: "IL2080")]
static void TestGetPublicParameterlessConstructorWithEmptyTypes ()
{
s_typeWithKeptPublicParameterlessConstructor.GetConstructor (Type.EmptyTypes);
s_typeWithKeptPublicParameterlessConstructor.GetMethod ("Foo");
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetMethod), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetMethod), new Type[] { typeof (string) }, messageCode: "IL2080")]
static void TestGetPublicParameterlessConstructorWithArrayEmpty ()
{
s_typeWithKeptPublicParameterlessConstructor.GetConstructor (Array.Empty<Type> ());
s_typeWithKeptPublicParameterlessConstructor.GetMethod ("Foo");
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetConstructor), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetConstructor), new Type[] { typeof (Type[]) }, messageCode: "IL2080")]
static void TestGetPublicParameterlessConstructorWithUnknownArray ()
{
s_typeWithKeptPublicParameterlessConstructor.GetConstructor (s_localEmptyArrayInvisibleToAnalysis);
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs
index 9cfcf4efd..21b96b9b8 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs
@@ -30,6 +30,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
instance.ReadFromStaticFieldOnADifferentClass ();
instance.WriteToStaticFieldOnADifferentClass ();
+
+ instance.WriteUnknownValue ();
}
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
@@ -38,13 +40,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
static Type _staticTypeWithPublicParameterlessConstructor;
+ static Type _staticTypeWithoutRequirements;
+
[UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) },
- "The field 'System.Type Mono.Linker.Tests.Cases.DataFlow.FieldDataFlow::_typeWithPublicParameterlessConstructor' " +
- "with dynamically accessed member kinds 'PublicParameterlessConstructor' is passed into " +
- "the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.FieldDataFlow.RequirePublicConstructors(Type)' " +
- "which requires dynamically accessed member kinds 'PublicConstructors'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicConstructors'.")]
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ messageCode: "IL2077", message: new string[] { "_typeWithPublicParameterlessConstructor", "type", "RequirePublicConstructors(Type)" })]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
private void ReadFromInstanceField ()
{
RequirePublicParameterlessConstructor (_typeWithPublicParameterlessConstructor);
@@ -53,8 +53,12 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (_typeWithPublicParameterlessConstructor);
}
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_typeWithPublicParameterlessConstructor))]
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_typeWithPublicParameterlessConstructor))]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_typeWithPublicParameterlessConstructor),
+ messageCode: "IL2074", message: new string[] {
+ nameof (GetUnkownType),
+ nameof (_typeWithPublicParameterlessConstructor)
+ })]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_typeWithPublicParameterlessConstructor), messageCode: "IL2074")]
private void WriteToInstanceField ()
{
_typeWithPublicParameterlessConstructor = GetTypeWithPublicParameterlessConstructor ();
@@ -63,8 +67,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
_typeWithPublicParameterlessConstructor = GetUnkownType ();
}
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
private void ReadFromInstanceFieldOnADifferentClass ()
{
var store = new TypeStore ();
@@ -75,8 +79,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (store._typeWithPublicParameterlessConstructor);
}
- [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._typeWithPublicParameterlessConstructor))]
- [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._typeWithPublicParameterlessConstructor))]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._typeWithPublicParameterlessConstructor), messageCode: "IL2074")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._typeWithPublicParameterlessConstructor), messageCode: "IL2074")]
private void WriteToInstanceFieldOnADifferentClass ()
{
var store = new TypeStore ();
@@ -87,8 +91,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
store._typeWithPublicParameterlessConstructor = GetUnkownType ();
}
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
private void ReadFromStaticField ()
{
RequirePublicParameterlessConstructor (_staticTypeWithPublicParameterlessConstructor);
@@ -97,18 +101,24 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (_staticTypeWithPublicParameterlessConstructor);
}
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_staticTypeWithPublicParameterlessConstructor))]
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_staticTypeWithPublicParameterlessConstructor))]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_staticTypeWithPublicParameterlessConstructor), messageCode: "IL2074")]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_staticTypeWithPublicParameterlessConstructor), messageCode: "IL2074")]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (_staticTypeWithPublicParameterlessConstructor),
+ messageCode: "IL2079", message: new string[] {
+ nameof(_staticTypeWithoutRequirements),
+ nameof(_staticTypeWithPublicParameterlessConstructor)
+ })]
private void WriteToStaticField ()
{
_staticTypeWithPublicParameterlessConstructor = GetTypeWithPublicParameterlessConstructor ();
_staticTypeWithPublicParameterlessConstructor = GetTypeWithPublicConstructors ();
_staticTypeWithPublicParameterlessConstructor = GetTypeWithNonPublicConstructors ();
_staticTypeWithPublicParameterlessConstructor = GetUnkownType ();
+ _staticTypeWithPublicParameterlessConstructor = _staticTypeWithoutRequirements;
}
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
+ [UnrecognizedReflectionAccessPattern (typeof (FieldDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
private void ReadFromStaticFieldOnADifferentClass ()
{
RequirePublicParameterlessConstructor (TypeStore._staticTypeWithPublicParameterlessConstructor);
@@ -117,8 +127,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (TypeStore._staticTypeWithPublicParameterlessConstructor);
}
- [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._staticTypeWithPublicParameterlessConstructor))]
- [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._staticTypeWithPublicParameterlessConstructor))]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._staticTypeWithPublicParameterlessConstructor), messageCode: "IL2074")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._staticTypeWithPublicParameterlessConstructor), messageCode: "IL2074")]
private void WriteToStaticFieldOnADifferentClass ()
{
TypeStore._staticTypeWithPublicParameterlessConstructor = GetTypeWithPublicParameterlessConstructor ();
@@ -127,6 +137,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow
TypeStore._staticTypeWithPublicParameterlessConstructor = GetUnkownType ();
}
+ [UnrecognizedReflectionAccessPattern (typeof (TypeStore), nameof (TypeStore._staticTypeWithPublicParameterlessConstructor), messageCode: "IL2064", message: nameof (TypeStore._staticTypeWithPublicParameterlessConstructor))]
+ private void WriteUnknownValue ()
+ {
+ var array = new object[1];
+ array[0] = this.GetType ();
+ TypeStore._staticTypeWithPublicParameterlessConstructor = (Type) array[0];
+ }
+
private static void RequirePublicParameterlessConstructor (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Type type)
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs
index 2350c95d2..e2d589f7e 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs
@@ -30,6 +30,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
TestMakeGenericMethod ();
TestNewConstraintSatisfiesParameterlessConstructor<object> ();
+
+ TestGenericParameterFlowsToField ();
+ TestGenericParameterFlowsToReturnValue ();
}
static void TestSingleGenericParameterOnType ()
@@ -41,22 +44,86 @@ namespace Mono.Linker.Tests.Cases.DataFlow
TypeRequiresNothingPassThrough<TestType>.Test ();
}
+ static void TestGenericParameterFlowsToField ()
+ {
+ TypeRequiresPublicFields<TestType>.TestFields ();
+ }
+
+ static void TestGenericParameterFlowsToReturnValue ()
+ {
+ _ = TypeRequiresPublicFields<TestType>.ReturnRequiresPublicFields ();
+ _ = TypeRequiresPublicFields<TestType>.ReturnRequiresPublicMethods ();
+ _ = TypeRequiresPublicFields<TestType>.ReturnRequiresNothing ();
+ }
+
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)]
+ static Type FieldRequiresPublicFields;
+
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ static Type FieldRequiresPublicMethods;
+
+ static Type FieldRequiresNothing;
+
class TypeRequiresPublicFields<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T>
{
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) },
+ messageCode: "IL2087", message: new string[] {
+ nameof (T),
+ nameof (TypeRequiresPublicFields <T>),
+ nameof (RequiresPublicMethods)
+ })]
public static void Test ()
{
RequiresPublicFields (typeof (T));
RequiresPublicMethods (typeof (T));
RequiresNothing (typeof (T));
}
+
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (FieldRequiresPublicMethods),
+ messageCode: "IL2089", message: new string[] {
+ nameof (T),
+ nameof (TypeRequiresPublicFields <T>),
+ nameof (FieldRequiresPublicMethods)
+ })]
+ public static void TestFields ()
+ {
+ FieldRequiresPublicFields = typeof (T);
+ FieldRequiresPublicMethods = typeof (T);
+ FieldRequiresNothing = typeof (T);
+ }
+
+
+ [RecognizedReflectionAccessPattern]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)]
+ public static Type ReturnRequiresPublicFields ()
+ {
+ return typeof (T);
+ }
+
+
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicFields<>), nameof (ReturnRequiresPublicMethods), new Type[] { }, returnType: typeof (Type),
+ messageCode: "IL2088", message: new string[] {
+ nameof (T),
+ nameof (TypeRequiresPublicFields<T>),
+ nameof (ReturnRequiresPublicMethods)
+ })]
+ [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ public static Type ReturnRequiresPublicMethods ()
+ {
+ return typeof (T);
+ }
+
+ public static Type ReturnRequiresNothing ()
+ {
+ return typeof (T);
+ }
}
class TypeRequiresPublicMethods<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T>
{
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
public static void Test ()
{
RequiresPublicFields (typeof (T));
@@ -67,8 +134,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
class TypeRequiresNothing<T>
{
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) }, messageCode: "IL2087")]
public static void Test ()
{
RequiresPublicFields (typeof (T));
@@ -78,25 +145,26 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
class TypeRequiresPublicFieldsPassThrough<
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T>
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] TSource>
{
[UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T",
- message: "The generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeRequiresPublicFieldsPassThrough<T>' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeRequiresPublicMethods<T>' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2091", message: new string[] {
+ nameof(TSource),
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeRequiresPublicFieldsPassThrough<TSource>",
+ "T",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeRequiresPublicMethods<T>" })]
public static void Test ()
{
- TypeRequiresPublicFields<T>.Test ();
- TypeRequiresPublicMethods<T>.Test ();
- TypeRequiresNothing<T>.Test ();
+ TypeRequiresPublicFields<TSource>.Test ();
+ TypeRequiresPublicMethods<TSource>.Test ();
+ TypeRequiresNothing<TSource>.Test ();
}
}
class TypeRequiresNothingPassThrough<T>
{
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicFields<>), "T")]
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicFields<>), "T", messageCode: "IL2091")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")]
public static void Test ()
{
TypeRequiresPublicFields<T>.Test ();
@@ -133,7 +201,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (TNothing));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) }, messageCode: "IL2087")]
public static void TestFields ()
{
RequiresPublicFields (typeof (TFields));
@@ -141,7 +209,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (TFields));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
public static void TestMethods ()
{
RequiresPublicFields (typeof (TMethods));
@@ -157,8 +225,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (TBoth));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) }, messageCode: "IL2087")]
public static void TestNothing ()
{
RequiresPublicFields (typeof (TNothing));
@@ -188,7 +256,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericBaseTypeWithRequirements<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericBaseTypeWithRequirements<>), "T", messageCode: "IL2091")]
class DerivedTypeWithOpenGenericOnBase<T> : GenericBaseTypeWithRequirements<T>
{
}
@@ -215,7 +283,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
- [UnrecognizedReflectionAccessPattern (typeof (IGenericInterfaceTypeWithRequirements<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (IGenericInterfaceTypeWithRequirements<>), "T", messageCode: "IL2091")]
class InterfaceImplementationTypeWithOpenGenericOnBase<T> : IGenericInterfaceTypeWithRequirements<T>
{
}
@@ -239,11 +307,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// The message is not ideal since we report the TRoot to come from RootTypeWithRequirements/InnerTypeWIthNoAddedGenerics
// while it originates on RootTypeWithRequirements, but it's correct from IL's point of view.
[UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) },
- message: "The generic parameter 'TRoot' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.RootTypeWithRequirements<TRoot>.InnerTypeWithNoAddedGenerics' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.RequiresPublicMethods(Type)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2087", message: new string[] {
+ nameof(TRoot),
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.RootTypeWithRequirements<TRoot>.InnerTypeWithNoAddedGenerics",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.RequiresPublicMethods(Type)" })]
public static void TestAccess ()
{
RequiresPublicFields (typeof (TRoot));
@@ -281,7 +349,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[RecognizedReflectionAccessPattern]
public TypeRequiresPublicFields<TOuter> PublicFieldsField;
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")]
public TypeRequiresPublicMethods<TOuter> PublicMethodsField;
public TypeRequiresPublicFields<TOuter> PublicFieldsProperty {
@@ -291,21 +359,21 @@ namespace Mono.Linker.Tests.Cases.DataFlow
set;
}
public TypeRequiresPublicMethods<TOuter> PublicMethodsProperty {
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")]
get;
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")]
set;
}
[RecognizedReflectionAccessPattern]
public void PublicFieldsMethodParameter (TypeRequiresPublicFields<TOuter> param) { }
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")]
public void PublicMethodsMethodParameter (TypeRequiresPublicMethods<TOuter> param) { }
[RecognizedReflectionAccessPattern]
public TypeRequiresPublicFields<TOuter> PublicFieldsMethodReturnValue () { return null; }
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")] // Return value
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")] // Compiler generated local variable
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")] // Return value
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")] // Compiler generated local variable
public TypeRequiresPublicMethods<TOuter> PublicMethodsMethodReturnValue () { return null; }
[RecognizedReflectionAccessPattern]
@@ -313,7 +381,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
TypeRequiresPublicFields<TOuter> t = null;
}
- [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T")]
+ [UnrecognizedReflectionAccessPattern (typeof (TypeRequiresPublicMethods<>), "T", messageCode: "IL2091")]
public void PublicMethodsMethodLocalVariable ()
{
TypeRequiresPublicMethods<TOuter> t = null;
@@ -347,7 +415,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
- [UnrecognizedReflectionAccessPattern (typeof (BaseForPartialInstantiation<,>), "TMethods")]
+ [UnrecognizedReflectionAccessPattern (typeof (BaseForPartialInstantiation<,>), "TMethods", messageCode: "IL2091")]
class PartialyInstantiatedMethods<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] TOuter>
: BaseForPartialInstantiation<TestType, TOuter>
{
@@ -368,7 +436,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
MethodRequiresNothingPassThrough<TestType> ();
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) }, messageCode: "IL2087")]
static void MethodRequiresPublicFields<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T> ()
{
@@ -377,7 +445,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (T));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
static void MethodRequiresPublicMethods<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T> ()
{
@@ -386,8 +454,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (T));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) }, messageCode: "IL2087")]
static void MethodRequiresNothing<T> ()
{
RequiresPublicFields (typeof (T));
@@ -395,7 +463,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (T));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (MethodRequiresPublicMethods) + "<T>()::T")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (MethodRequiresPublicMethods) + "<T>()::T", messageCode: "IL2091")]
static void MethodRequiresPublicFieldsPassThrough<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T> ()
{
@@ -404,8 +472,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
MethodRequiresNothing<T> ();
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (MethodRequiresPublicFields) + "<T>()::T")]
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (MethodRequiresPublicMethods) + "<T>()::T")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (MethodRequiresPublicFields) + "<T>()::T", messageCode: "IL2091")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (MethodRequiresPublicMethods) + "<T>()::T", messageCode: "IL2091")]
static void MethodRequiresNothingPassThrough<T> ()
{
MethodRequiresPublicFields<T> ();
@@ -478,10 +546,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
: BaseTypeWithGenericMethod, IInterfaceWithGenericMethod
{
[UnrecognizedReflectionAccessPattern (typeof (BaseTypeWithGenericMethod), nameof (BaseTypeWithGenericMethod.StaticRequiresPublicMethods) + "<T>()::T",
- message: "The generic parameter 'TInner' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>.StaticRequiresPublicFields<TInner>()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.StaticRequiresPublicMethods<T>()' which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2091", message: new string[] {
+ "TInner",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>.StaticRequiresPublicFields<TInner>()",
+ "T",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.StaticRequiresPublicMethods<T>()" })]
public static void StaticRequiresPublicFields<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] TInner> ()
{
StaticRequiresPublicFields<TInner> ();
@@ -489,10 +558,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (BaseTypeWithGenericMethod), nameof (BaseTypeWithGenericMethod.StaticRequiresPublicMethods) + "<T>()::T",
- message: "The generic parameter 'TOuter' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.StaticRequiresPublicMethods<T>()' which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2091", message: new string[] {
+ "TOuter",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>",
+ "T",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.StaticRequiresPublicMethods<T>()" })]
public static void StaticRequiresPublicFieldsNonGeneric ()
{
StaticRequiresPublicFields<TOuter> ();
@@ -506,20 +576,22 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (BaseTypeWithGenericMethod), nameof (BaseTypeWithGenericMethod.StaticRequiresMultipleGenericParams) + "<TFields,TMethods>()::TMethods",
- message: "The generic parameter 'TOuter' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the generic parameter 'TMethods' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.StaticRequiresMultipleGenericParams<TFields,TMethods>()' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2091", message: new string[] {
+ "TOuter",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>",
+ "TMethods",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.StaticRequiresMultipleGenericParams<TFields,TMethods>()" })]
public static void StaticPartialInstantiationUnrecognized ()
{
StaticRequiresMultipleGenericParams<TestType, TOuter> ();
}
[UnrecognizedReflectionAccessPattern (typeof (BaseTypeWithGenericMethod), nameof (BaseTypeWithGenericMethod.InstanceRequiresPublicMethods) + "<T>()::T",
- message: "The generic parameter 'TInner' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>.InstanceRequiresPublicFields<TInner>()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.InstanceRequiresPublicMethods<T>()' which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2091", message: new string[] {
+ "TInner",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>.InstanceRequiresPublicFields<TInner>()",
+ "T",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.InstanceRequiresPublicMethods<T>()" })]
public void InstanceRequiresPublicFields<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] TInner> ()
{
InstanceRequiresPublicFields<TInner> ();
@@ -527,10 +599,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (BaseTypeWithGenericMethod), nameof (BaseTypeWithGenericMethod.InstanceRequiresPublicMethods) + "<T>()::T",
- message: "The generic parameter 'TOuter' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.InstanceRequiresPublicMethods<T>()' which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2091", message: new string[] {
+ "TOuter",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>",
+ "T",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.BaseTypeWithGenericMethod.InstanceRequiresPublicMethods<T>()" })]
public void InstanceRequiresPublicFieldsNonGeneric ()
{
InstanceRequiresPublicFields<TOuter> ();
@@ -562,10 +635,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (IInterfaceWithGenericMethod), nameof (IInterfaceWithGenericMethod.InterfaceRequiresPublicMethods) + "<T>()::T",
- message: "The generic parameter 'TOuter' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.IInterfaceWithGenericMethod.InterfaceRequiresPublicMethods<T>()' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2091", message: new string[] {
+ "TOuter",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.TypeWithInstantiatedGenericMethodViaGenericParameter<TOuter>",
+ "T",
+ "Mono.Linker.Tests.Cases.DataFlow.GenericParameterDataFlow.IInterfaceWithGenericMethod.InterfaceRequiresPublicMethods<T>()" })]
public void CallInterface ()
{
IInterfaceWithGenericMethod interfaceInstance = (IInterfaceWithGenericMethod) this;
@@ -601,7 +675,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (TNothing));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) }, messageCode: "IL2087")]
static void MethodMultipleWithDifferentRequirements_TestFields<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] TFields,
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] TMethods,
@@ -613,7 +687,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (TFields));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
static void MethodMultipleWithDifferentRequirements_TestMethods<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] TFields,
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] TMethods,
@@ -636,8 +710,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequiresNothing (typeof (TBoth));
}
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicFields), new Type[] { typeof (Type) }, messageCode: "IL2087")]
+ [UnrecognizedReflectionAccessPattern (typeof (GenericParameterDataFlow), nameof (RequiresPublicMethods), new Type[] { typeof (Type) }, messageCode: "IL2087")]
static void MethodMultipleWithDifferentRequirements_TestNothing<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] TFields,
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] TMethods,
@@ -689,7 +763,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
nullType.MakeGenericType (typeof (TestType));
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) }, messageCode: "IL2055")]
static void TestMakeGenericTypeUnknownInput (Type inputType)
{
inputType.MakeGenericType (typeof (TestType));
@@ -705,7 +779,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) }, messageCode: "IL2055")]
static void TestMakeGenericWithRequirements ()
{
// Currently this is not analyzable since we don't track array elements.
@@ -713,14 +787,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow
typeof (TypeMakeGenericWithPublicFieldsArgument<>).MakeGenericType (typeof (TestType));
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) }, messageCode: "IL2055")]
static void TestMakeGenericWithRequirementsFromParam (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] Type type)
{
typeof (TypeMakeGenericWithPublicFieldsArgument<>).MakeGenericType (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) }, messageCode: "IL2055")]
static void TestMakeGenericWithRequirementsFromGenericParam<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T> ()
{
@@ -747,7 +821,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.MakeGenericType), new Type[] { typeof (Type[]) }, messageCode: "IL2055")]
static void TestMakeGenericWithMultipleArgumentsWithRequirements ()
{
typeof (TypeMakeGenericWithMultipleArgumentsWithRequirements<,>).MakeGenericType (typeof (TestType), typeof (TestType));
@@ -765,7 +839,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
TestMakeGenericMethodWithNoRequirements ();
}
- [UnrecognizedReflectionAccessPattern (typeof (System.Reflection.MethodInfo), nameof (System.Reflection.MethodInfo.MakeGenericMethod), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (System.Reflection.MethodInfo), nameof (System.Reflection.MethodInfo.MakeGenericMethod), new Type[] { typeof (Type[]) }, messageCode: "IL2060")]
static void TestMakeGenericMethodWithRequirements ()
{
typeof (GenericParameterDataFlow).GetMethod (nameof (MethodMakeGenericWithRequirements), BindingFlags.Static | BindingFlags.NonPublic)
@@ -776,7 +850,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
- [UnrecognizedReflectionAccessPattern (typeof (System.Reflection.MethodInfo), nameof (System.Reflection.MethodInfo.MakeGenericMethod), new Type[] { typeof (Type[]) })]
+ [UnrecognizedReflectionAccessPattern (typeof (System.Reflection.MethodInfo), nameof (System.Reflection.MethodInfo.MakeGenericMethod), new Type[] { typeof (Type[]) }, messageCode: "IL2060")]
static void TestMakeGenericMethodWithNoRequirements ()
{
typeof (GenericParameterDataFlow).GetMethod (nameof (MethodMakeGenericWithNoRequirements), BindingFlags.Static | BindingFlags.NonPublic)
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs
index 050bc9d11..14af1cfe3 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/GetTypeDataFlow.cs
@@ -34,8 +34,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// Type.GetType over two params
}
- [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
static void TestPublicParameterlessConstructor ()
{
Type type = Type.GetType (GetStringTypeWithPublicParameterlessConstructor ());
@@ -45,7 +45,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
static void TestPublicConstructors ()
{
Type type = Type.GetType (GetStringTypeWithPublicConstructors ());
@@ -55,8 +55,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
static void TestConstructors ()
{
Type type = Type.GetType (GetStringTypeWithNonPublicConstructors ());
@@ -66,13 +66,13 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (GetType), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), nameof (GetType), new Type[] { typeof (string) }, messageCode: "IL2057")]
static void TestUnknownType ()
{
Type type = Type.GetType (GetStringUnkownType ());
}
- [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
static void TestTypeNameFromParameter (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
string typeName)
@@ -83,7 +83,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
static string _typeNameWithPublicParameterlessConstructor;
- [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
static void TestTypeNameFromField ()
{
RequirePublicConstructors (Type.GetType (_typeNameWithPublicParameterlessConstructor));
@@ -113,13 +113,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (GetTypeDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) },
- "The method return value with dynamically accessed member kinds 'PublicParameterlessConstructor' is passed into " +
- "the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.GetTypeDataFlow.RequireNonPublicConstructors(Type)' " +
- "which requires dynamically accessed member kinds 'NonPublicConstructors'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'NonPublicConstructors'.")]
+ messageCode: "IL2072", message: "GetType")]
[UnrecognizedReflectionAccessPattern (typeof (Type), nameof (Type.GetType), new Type[] { typeof (string) },
- "Reflection call 'System.Type.GetType(String)' inside 'Mono.Linker.Tests.Cases.DataFlow.GetTypeDataFlow.TestMultipleMixedValues()' " +
- "was detected with unknown value for the type name.")]
+ messageCode: "IL2057", message: "System.Type.GetType(String)")]
static void TestMultipleMixedValues ()
{
string typeName = null;
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/LocalDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/LocalDataFlow.cs
index f864da9c4..1cf63d79d 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/LocalDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/LocalDataFlow.cs
@@ -38,17 +38,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)' " +
- "which requires dynamically accessed member kinds 'PublicFields'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicFields'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)"})]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)"})]
public static void TestBranchMergeGoto ()
{
string str = GetWithPublicMethods ();
@@ -62,17 +60,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)' " +
- "which requires dynamically accessed member kinds 'PublicFields'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicFields'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)" })]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)" })]
public static void TestBranchMergeIf ()
{
string str = GetWithPublicMethods ();
@@ -84,17 +80,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)' " +
- "which requires dynamically accessed member kinds 'PublicFields'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicFields'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)" })]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)" })]
public static void TestBranchMergeIfElse ()
{
string str = null;
@@ -110,23 +104,20 @@ namespace Mono.Linker.Tests.Cases.DataFlow
static int _switchOnField;
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequireNonPublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequireNonPublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'NonPublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'NonPublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequireNonPublicMethods(String)" })]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequireNonPublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequireNonPublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'NonPublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'NonPublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequireNonPublicMethods(String)" })]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequireNonPublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicConstructors()' " +
- "with dynamically accessed member kinds 'PublicConstructors' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequireNonPublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'NonPublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'NonPublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicConstructors()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequireNonPublicMethods(String)" })]
public static void TestBranchMergeSwitch ()
{
string str = null;
@@ -148,17 +139,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)' " +
- "which requires dynamically accessed member kinds 'PublicFields'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicFields'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)" })]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)" })]
public static void TestBranchMergeTry ()
{
string str = GetWithPublicMethods ();
@@ -174,17 +163,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)' " +
- "which requires dynamically accessed member kinds 'PublicFields'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicFields'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)" })]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)" })]
public static void TestBranchMergeCatch ()
{
string str = GetWithPublicMethods ();
@@ -199,17 +186,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)' " +
- "which requires dynamically accessed member kinds 'PublicFields'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicFields'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicMethods()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicFields(String)" })]
[UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()' " +
- "with dynamically accessed member kinds 'PublicFields' " +
- "is passed into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
+ messageCode: "IL2072", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.GetWithPublicFields()",
+ "type",
+ "Mono.Linker.Tests.Cases.DataFlow.LocalDataFlow.RequirePublicMethods(String)" })]
public static void TestBranchMergeFinally ()
{
string str = GetWithPublicMethods ();
@@ -224,7 +209,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequirePublicMethods (str); // warns for GetWithPublicFields
}
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchGoto ()
{
string str = GetWithPublicMethods ();
@@ -236,7 +221,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
return;
}
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchIf ()
{
string str = GetWithPublicMethods ();
@@ -246,7 +231,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchIfElse ()
{
string str;
@@ -261,12 +246,12 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequireNonPublicMethods), new Type[] { typeof (string) })]
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) })]
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) })]
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (string) })]
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (string) })]
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequireNonPublicMethods), new Type[] { typeof (string) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicMethods), new Type[] { typeof (string) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (string) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (string) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchSwitch ()
{
string str = null;
@@ -290,7 +275,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchTry ()
{
string str = GetWithPublicMethods ();
@@ -304,7 +289,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchCatch ()
{
string str = GetWithPublicMethods ();
@@ -317,7 +302,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) })]
+ [UnrecognizedReflectionAccessPattern (typeof (LocalDataFlow), nameof (RequirePublicFields), new Type[] { typeof (string) }, messageCode: "IL2072")]
public static void TestBranchFinally ()
{
string str = GetWithPublicMethods ();
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs
index c6d287d42..ce2c49047 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs
@@ -39,22 +39,18 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// Validate the error message when annotated parameter is passed to another annotated parameter
[UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) },
- "The parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.MethodParametersDataFlow.PublicParameterlessConstructorParameter(Type)' " +
- "with dynamically accessed member kinds 'PublicParameterlessConstructor' is passed into the parameter 'type' " +
- "of method 'Mono.Linker.Tests.Cases.DataFlow.MethodParametersDataFlow.RequirePublicConstructors(Type)' " +
- "which requires dynamically accessed member kinds 'PublicConstructors'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicConstructors'.")]
- [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ messageCode: "IL2067", message: new string[] { "sourceType", "PublicParameterlessConstructorParameter(Type)", "type", "RequirePublicConstructors(Type)" })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2067")]
private static void PublicParameterlessConstructorParameter (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
- Type type)
+ Type sourceType)
{
- RequirePublicParameterlessConstructor (type);
- RequirePublicConstructors (type);
- RequireNonPublicConstructors (type);
+ RequirePublicParameterlessConstructor (sourceType);
+ RequirePublicConstructors (sourceType);
+ RequireNonPublicConstructors (sourceType);
}
- [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2067")]
private static void PublicConstructorsParameter (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
Type type)
@@ -64,8 +60,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNonPublicConstructors (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (Type) }, messageCode: "IL2067")]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2067")]
private static void NonPublicConstructorsParameter (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)]
Type type)
@@ -75,7 +71,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNonPublicConstructors (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2067")]
private void InstanceMethod (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Type type)
@@ -84,7 +80,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequirePublicConstructors (type);
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), "type")]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), "type", messageCode: "IL2072")]
private void WriteToParameterOnInstanceMethod (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)]
Type type)
@@ -92,7 +88,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
type = ReturnThingsWithPublicParameterlessConstructor ();
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), "type")]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), "type", messageCode: "IL2072")]
private static void WriteToParameterOnStaticMethod (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)]
Type type)
@@ -100,7 +96,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
type = ReturnThingsWithPublicParameterlessConstructor ();
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), "type")]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), "type", messageCode: "IL2072")]
private void LongWriteToParameterOnInstanceMethod (
int a, int b, int c, int d,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)]
@@ -109,7 +105,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
type = ReturnThingsWithPublicParameterlessConstructor ();
}
- [UnrecognizedReflectionAccessPattern (typeof (Type), "type")]
+ [UnrecognizedReflectionAccessPattern (typeof (Type), "type", messageCode: "IL2072")]
private static void LongWriteToParameterOnStaticMethod (
int a, int b, int c, int d,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)]
@@ -124,7 +120,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
return null;
}
- [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2067")]
private void TwoAnnotatedParameters (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Type type,
@@ -137,7 +133,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequirePublicConstructors (type2);
}
- [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2067")]
private void TwoAnnotatedParametersIntoOneValue (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Type type,
@@ -151,11 +147,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// Validate the error message for the case of unannotated method return value passed to an annotated parameter.
[UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (Type) },
- "The parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.MethodParametersDataFlow.NoAnnotation(Type)' " +
- "with dynamically accessed member kinds 'None' is passed into " +
- "the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.MethodParametersDataFlow.RequirePublicParameterlessConstructor(Type)' " +
- "which requires dynamically accessed member kinds 'PublicParameterlessConstructor'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicParameterlessConstructor'.")]
+ messageCode: "IL2067", message: new string[] { "type", "NoAnnotation(Type)", "type", "RequirePublicParameterlessConstructor(Type)" })]
private void NoAnnotation (Type type)
{
RequirePublicParameterlessConstructor (type);
@@ -163,10 +155,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// Validate error message when untracable value is passed to an annotated parameter.
[UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (Type) },
- "A value from unknown source is passed " +
- "into the parameter 'type' of method 'Mono.Linker.Tests.Cases.DataFlow.MethodParametersDataFlow.RequirePublicParameterlessConstructor(Type)' " +
- "which requires dynamically accessed member kinds 'PublicParameterlessConstructor'. " +
- "It's not possible to guarantee that these requirements are met by the application.")]
+ messageCode: "IL2062", message: new string[] { "type", "RequirePublicParameterlessConstructor" })]
private void UnknownValue ()
{
var array = new object[1];
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs
index 2c11fc8a5..5cebf613e 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs
@@ -28,10 +28,12 @@ namespace Mono.Linker.Tests.Cases.DataFlow
instance.ReturnPublicParameterlessConstructorFromNull ();
instance.ReturnPublicConstructorsFailure (null);
instance.ReturnNonPublicConstructorsFailure (null);
+ instance.ReturnUnknownValue ();
// Validation that value comming from return value of a method is correctly propagated
instance.PropagateReturnPublicParameterlessConstructor ();
instance.PropagateReturnPublicParameterlessConstructorFromConstant ();
+ instance.PropagateReturnToReturn (0);
}
private static Type NoRequirements ()
@@ -40,7 +42,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnPublicParameterlessConstructor),
- new Type[] { typeof (Type), typeof (Type), typeof (Type) }, returnType: typeof (Type))]
+ new Type[] { typeof (Type), typeof (Type), typeof (Type) }, returnType: typeof (Type), messageCode: "IL2068")]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
private Type ReturnPublicParameterlessConstructor (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
@@ -65,7 +67,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnPublicParameterlessConstructorFromUnknownType),
- new Type[] { typeof (Type) }, returnType: typeof (Type))]
+ new Type[] { typeof (Type) }, returnType: typeof (Type), messageCode: "IL2068")]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
private Type ReturnPublicParameterlessConstructorFromUnknownType (Type unknownType)
{
@@ -86,14 +88,18 @@ namespace Mono.Linker.Tests.Cases.DataFlow
return null;
}
+ private Type ReturnTypeWithNoRequirements ()
+ {
+ return null;
+ }
+
// Validate error message when insufficiently annotated value is returned from a method
[UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnPublicConstructorsFailure),
- new Type[] { typeof (Type) },
- "The parameter 'publicParameterlessConstructorType' of method 'Mono.Linker.Tests.Cases.DataFlow.MethodReturnParameterDataFlow.ReturnPublicConstructorsFailure(Type)' " +
- "with dynamically accessed member kinds 'PublicParameterlessConstructor' is " +
- "passed into the return value of method 'Mono.Linker.Tests.Cases.DataFlow.MethodReturnParameterDataFlow.ReturnPublicConstructorsFailure(Type)' " +
- "which requires dynamically accessed member kinds 'PublicConstructors'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicConstructors'.", typeof (Type))]
+ new Type[] { typeof (Type) }, returnType: typeof (Type),
+ messageCode: "IL2068", message: new string[] {
+ "publicParameterlessConstructorType",
+ "MethodReturnParameterDataFlow.ReturnPublicConstructorsFailure",
+ "MethodReturnParameterDataFlow.ReturnPublicConstructorsFailure" })]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
private Type ReturnPublicConstructorsFailure (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
@@ -103,7 +109,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnNonPublicConstructorsFailure),
- new Type[] { typeof (Type) }, returnType: typeof (Type))]
+ new Type[] { typeof (Type) }, returnType: typeof (Type), messageCode: "IL2068")]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicConstructors)]
private Type ReturnNonPublicConstructorsFailure (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
@@ -112,8 +118,19 @@ namespace Mono.Linker.Tests.Cases.DataFlow
return publicConstructorsType;
}
- [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnUnknownValue),
+ new Type[] { }, returnType: typeof (Type),
+ messageCode: "IL2063", message: nameof (ReturnUnknownValue))]
+ [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
+ private Type ReturnUnknownValue ()
+ {
+ var array = new object[1];
+ array[0] = this.GetType ();
+ return (Type) array[0];
+ }
+
+ [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
private void PropagateReturnPublicParameterlessConstructor ()
{
Type t = ReturnPublicParameterlessConstructor (typeof (TestType), typeof (TestType), typeof (TestType));
@@ -123,8 +140,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (t);
}
- [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
private void PropagateReturnPublicParameterlessConstructorFromConstant ()
{
Type t = ReturnPublicParameterlessConstructorFromConstant ();
@@ -134,6 +151,24 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (t);
}
+ [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (PropagateReturnToReturn), new Type[] { typeof (int) }, returnType: typeof (Type),
+ messageCode: "IL2073", message: new string[] {
+ nameof (ReturnTypeWithNoRequirements),
+ nameof (PropagateReturnToReturn)
+ })]
+ [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
+ private Type PropagateReturnToReturn (int n)
+ {
+ switch (n) {
+ case 0:
+ return ReturnPublicParameterlessConstructorFromConstant ();
+ case 1:
+ return ReturnTypeWithNoRequirements ();
+ }
+
+ return null;
+ }
+
private static void PublicParameterlessConstructorConstructor (
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Type type)
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs
index 4c9fc215d..e04fb56e1 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs
@@ -22,15 +22,18 @@ namespace Mono.Linker.Tests.Cases.DataFlow
PropagateToThisWithSetters ();
TestAnnotationOnNonTypeMethod ();
+ TestUnknownThis ();
+ TestFromParameterToThis (null);
+ TestFromFieldToThis ();
+ TestFromThisToOthers ();
+ TestFromGenericParameterToThis<MethodThisDataFlow> ();
}
[UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.RequireThisPublicMethods), new Type[] { },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()' " +
- "with dynamically accessed member kinds 'NonPublicMethods' " +
- "is passed into the implicit 'this' parameter of method 'System.MethodThisDataFlowTypeTest.RequireThisPublicMethods()' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
- [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.RequireThisNonPublicMethods), new Type[] { })]
+ messageCode: "IL2075", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()",
+ "System.MethodThisDataFlowTypeTest.RequireThisPublicMethods()" })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.RequireThisNonPublicMethods), new Type[] { }, messageCode: "IL2075")]
static void PropagateToThis ()
{
GetWithPublicMethods ().RequireThisPublicMethods ();
@@ -41,12 +44,10 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "get_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods), new Type[] { },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()' " +
- "with dynamically accessed member kinds 'NonPublicMethods' " +
- "is passed into the implicit 'this' parameter of method 'System.MethodThisDataFlowTypeTest.get_PropertyRequireThisPublicMethods()' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
- [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "get_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods), new Type[] { })]
+ messageCode: "IL2075", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()",
+ "System.MethodThisDataFlowTypeTest.get_PropertyRequireThisPublicMethods()" })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "get_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods), new Type[] { }, messageCode: "IL2075")]
static void PropagateToThisWithGetters ()
{
_ = GetWithPublicMethods ().PropertyRequireThisPublicMethods;
@@ -57,12 +58,10 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
[UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "set_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods), new Type[] { typeof (Object) },
- "The return value of method 'Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()' " +
- "with dynamically accessed member kinds 'NonPublicMethods' " +
- "is passed into the implicit 'this' parameter of method 'System.MethodThisDataFlowTypeTest.set_PropertyRequireThisPublicMethods(Object)' " +
- "which requires dynamically accessed member kinds 'PublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicMethods'.")]
- [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "set_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods), new Type[] { typeof (Object) })]
+ messageCode: "IL2075", message: new string[] {
+ "Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()",
+ "System.MethodThisDataFlowTypeTest.set_PropertyRequireThisPublicMethods(Object)" })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "set_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods), new Type[] { typeof (Object) }, messageCode: "IL2075")]
static void PropagateToThisWithSetters ()
{
GetWithPublicMethods ().PropertyRequireThisPublicMethods = null;
@@ -88,20 +87,62 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
var t = new NonTypeType ();
t.GetMethod ("foo");
+ NonTypeType.StaticMethod ();
+ }
+
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.RequireThisNonPublicMethods), new Type[] { },
+ messageCode: "IL2065", message: nameof (MethodThisDataFlowTypeTest.RequireThisNonPublicMethods))]
+ static void TestUnknownThis ()
+ {
+ var array = new object[1];
+ array[0] = array.GetType ();
+ ((MethodThisDataFlowTypeTest) array[0]).RequireThisNonPublicMethods ();
+ }
+
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.RequireThisPublicMethods), new Type[] { },
+ messageCode: "IL2070", message: new string[] { "sourceType", nameof (TestFromParameterToThis), nameof (MethodThisDataFlowTypeTest.RequireThisPublicMethods) })]
+ static void TestFromParameterToThis (MethodThisDataFlowTypeTest sourceType)
+ {
+ sourceType.RequireThisPublicMethods ();
+ }
+
+ static MethodThisDataFlowTypeTest _typeField;
+
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.RequireThisPublicMethods), new Type[] { },
+ messageCode: "IL2080", message: new string[] { nameof (_typeField), nameof (MethodThisDataFlowTypeTest.RequireThisPublicMethods) })]
+ static void TestFromFieldToThis ()
+ {
+ _typeField.RequireThisPublicMethods ();
+ }
+
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.RequireThisPublicMethods), new Type[] { },
+ messageCode: "IL2090", message: new string[] {
+ "TSource",
+ "TestFromGenericParameterToThis<TSource>",
+ nameof (MethodThisDataFlowTypeTest.RequireThisPublicMethods)
+ })]
+ static void TestFromGenericParameterToThis<TSource> ()
+ {
+ ((MethodThisDataFlowTypeTest) typeof (TSource)).RequireThisPublicMethods ();
+ }
+
+ static void TestFromThisToOthers ()
+ {
+ GetWithPublicMethods ().PropagateToReturn ();
+ GetWithPublicMethods ().PropagateToField ();
+ GetWithPublicMethods ().PropagateToThis ();
}
class NonTypeType
{
- [LogContains ("warning IL2041: Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.NonTypeType.GetMethod(String): " +
- "The DynamicallyAccessedMembersAttribute is only allowed on method parameters, return value or generic parameters.")]
+ [ExpectedWarning ("IL2041")]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
public MethodInfo GetMethod (string name)
{
return null;
}
- [LogContains ("warning IL2041: Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.NonTypeType.StaticMethod(): " +
- "The DynamicallyAccessedMembersAttribute is only allowed on method parameters, return value or generic parameters.")]
+ [ExpectedWarning ("IL2041")]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
public static void StaticMethod ()
{
@@ -116,11 +157,9 @@ namespace System
{
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
[UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (RequireNonPublicMethods), new Type[] { typeof (Type) },
- "The implicit 'this' parameter of method 'System.MethodThisDataFlowTypeTest.RequireThisPublicMethods()' " +
- "with dynamically accessed member kinds 'PublicMethods' " +
- "is passed into the parameter 'type' of method 'System.MethodThisDataFlowTypeTest.RequireNonPublicMethods(Type)' " +
- "which requires dynamically accessed member kinds 'NonPublicMethods'. " +
- "To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'NonPublicMethods'.")]
+ messageCode: "IL2082", message: new string[] {
+ "implicit 'this' parameter of method 'System.MethodThisDataFlowTypeTest.RequireThisPublicMethods()'",
+ "parameter 'type' of method 'System.MethodThisDataFlowTypeTest.RequireNonPublicMethods(Type)'" })]
public void RequireThisPublicMethods ()
{
RequirePublicMethods (this);
@@ -128,13 +167,51 @@ namespace System
}
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicMethods)]
- [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (RequirePublicMethods), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (RequirePublicMethods), new Type[] { typeof (Type) },
+ messageCode: "IL2082")]
public void RequireThisNonPublicMethods ()
{
RequirePublicMethods (this);
RequireNonPublicMethods (this);
}
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (PropagateToReturn), new Type[] { }, returnType: typeof (Type),
+ messageCode: "IL2083", message: new string[] {
+ nameof(PropagateToReturn),
+ nameof(PropagateToReturn)
+ })]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
+ public Type PropagateToReturn ()
+ {
+ return this;
+ }
+
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
+ Type _requiresPublicConstructors;
+
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (_requiresPublicConstructors),
+ messageCode: "IL2084", message: new string[] {
+ nameof (PropagateToField),
+ nameof (_requiresPublicConstructors)
+ })]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ public void PropagateToField ()
+ {
+ _requiresPublicConstructors = this;
+ }
+
+ [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (RequireThisNonPublicMethods), new Type[] { },
+ messageCode: "IL2085", message: new string[] {
+ nameof (PropagateToThis),
+ nameof (RequireThisNonPublicMethods)
+ })]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ public void PropagateToThis ()
+ {
+ this.RequireThisNonPublicMethods ();
+ }
+
public object PropertyRequireThisPublicMethods {
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
get {
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs
index 4cef0c7a4..2d7e7363b 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs
@@ -43,7 +43,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
static Type StaticPropertyWithPublicConstructor { get; set; }
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
private void ReadFromInstanceProperty ()
{
RequirePublicParameterlessConstructor (PropertyWithPublicConstructor);
@@ -52,7 +52,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (PropertyWithPublicConstructor);
}
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")]
private void ReadFromStaticProperty ()
{
RequirePublicParameterlessConstructor (StaticPropertyWithPublicConstructor);
@@ -61,9 +61,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
RequireNothing (StaticPropertyWithPublicConstructor);
}
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")]
private void WriteToInstanceProperty ()
{
PropertyWithPublicConstructor = GetTypeWithPublicParameterlessConstructor ();
@@ -72,9 +72,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
PropertyWithPublicConstructor = GetUnkownType ();
}
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")]
private void WriteToStaticProperty ()
{
StaticPropertyWithPublicConstructor = GetTypeWithPublicParameterlessConstructor ();
@@ -107,7 +107,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
return _fieldWithPublicConstructors;
}
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (_fieldWithPublicConstructors))]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (_fieldWithPublicConstructors),
+ messageCode: "IL2069", message: new string[] { "value", "set_" + nameof (PropertyPublicParameterlessConstructorWithExplicitAccessors), nameof (_fieldWithPublicConstructors) })]
[param: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
set {
_fieldWithPublicConstructors = value;
@@ -116,13 +117,16 @@ namespace Mono.Linker.Tests.Cases.DataFlow
Type PropertyNonPublicConstructorsWithExplicitAccessors {
[UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "get_" + nameof (PropertyNonPublicConstructorsWithExplicitAccessors),
- new Type[] { }, returnType: typeof (Type))]
+ new Type[] { }, returnType: typeof (Type), messageCode: "IL2078", message: new string[] {
+ nameof (_fieldWithPublicConstructors),
+ "get_" + nameof (PropertyNonPublicConstructorsWithExplicitAccessors)
+ })]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicConstructors)]
get {
return _fieldWithPublicConstructors;
}
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (_fieldWithPublicConstructors))]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (_fieldWithPublicConstructors), messageCode: "IL2069")]
[param: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicConstructors)]
set {
_fieldWithPublicConstructors = value;
@@ -143,7 +147,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
class TestAutomaticPropagationType
{
// Fully implicit property should work
- [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), "set_" + nameof (ImplicitProperty), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), "set_" + nameof (ImplicitProperty), new Type[] { typeof (Type) }, messageCode: "IL2072")]
public void TestImplicitProperty ()
{
RequirePublicConstructors (ImplicitProperty);
@@ -156,7 +160,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
// Simple getter is not enough - we do detect the field, but we require the field to be compiler generated for this to work
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
// Make sure we don't warn about the field in context of property annotation propagation.
[LogDoesNotContain ("Could not find a unique backing field for property 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithSimpleGetter()'")]
public void TestPropertyWithSimpleGetter ()
@@ -169,7 +173,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
static Type PropertyWithSimpleGetter {
- [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), "get_" + nameof (PropertyWithSimpleGetter), new Type[] { }, returnType: typeof (Type))]
+ [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), "get_" + nameof (PropertyWithSimpleGetter), new Type[] { }, returnType: typeof (Type), messageCode: "IL2078")]
get {
return PropertyWithSimpleGetter_Field;
}
@@ -193,7 +197,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
// Make sure we don't warn about the field in context of property annotation propagation.
[LogDoesNotContain ("Could not find a unique backing field for property 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::InstancePropertyWithStaticField()'")]
public void TestInstancePropertyWithStaticField ()
@@ -215,10 +219,6 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [LogContains ("Could not find a unique backing field for property 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithDifferentBackingFields()' " +
- "to propagate DynamicallyAccessedMembersAttribute. " +
- "The backing fields from getter 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithDifferentBackingFields_GetterField' " +
- "and setter 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithDifferentBackingFields_SetterField' are not the same.")]
public void TestPropertyWithDifferentBackingFields ()
{
_ = PropertyWithDifferentBackingFields;
@@ -230,6 +230,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[CompilerGenerated]
private Type PropertyWithDifferentBackingFields_SetterField;
+ [ExpectedWarning ("IL2042",
+ "System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithDifferentBackingFields()")]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
Type PropertyWithDifferentBackingFields {
get {
@@ -241,23 +243,24 @@ namespace Mono.Linker.Tests.Cases.DataFlow
}
}
- [LogContains ("Trying to propagate DynamicallyAccessedMemberAttribute from property 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithExistingAttributes()' to its field 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithExistingAttributes_Field', but it already has such attribute.")]
- [LogContains ("Trying to propagate DynamicallyAccessedMemberAttribute from property 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithExistingAttributes()' to its setter 'Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow.TestAutomaticPropagationType.set_PropertyWithExistingAttributes(Type)', but it already has such attribute on the 'value' parameter.")]
- [LogContains ("Trying to propagate DynamicallyAccessedMemberAttribute from property 'System.Type Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow/TestAutomaticPropagationType::PropertyWithExistingAttributes()' to its getter 'Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow.TestAutomaticPropagationType.get_PropertyWithExistingAttributes()', but it already has such attribute on the return value.")]
public void TestPropertyWithExistingAttributes ()
{
_ = PropertyWithExistingAttributes;
PropertyWithExistingAttributes = null;
}
+ [ExpectedWarning ("IL2056", "PropertyWithExistingAttributes", "PropertyWithExistingAttributes_Field")]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
[CompilerGenerated]
Type PropertyWithExistingAttributes_Field;
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
Type PropertyWithExistingAttributes {
+ [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "get_PropertyWithExistingAttributes")]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
get { return PropertyWithExistingAttributes_Field; }
+
+ [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "set_PropertyWithExistingAttributes")]
[param: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
set { PropertyWithExistingAttributes_Field = value; }
}
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.cs b/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.cs
index ed99137ca..903eeca10 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.cs
@@ -13,7 +13,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
[SkipKeptItemsValidation]
[SetupLinkAttributesFile ("SuppressWarningWithLinkAttributes.xml")]
- [LogDoesNotContain ("Trim analysis warning IL2006: Mono.Linker.Tests.Cases.DataFlow.SuppressWarningWithLinkAttributes::ReadFromInstanceField()")]
+ [LogDoesNotContain ("Trim analysis warning IL2067: Mono.Linker.Tests.Cases.DataFlow.SuppressWarningWithLinkAttributes::ReadFromInstanceField()")]
class SuppressWarningWithLinkAttributes
{
public static void Main ()
@@ -27,8 +27,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
Type PropertyWithPublicParameterlessConstructor { get; set; }
- [UnrecognizedReflectionAccessPattern (typeof (SuppressWarningWithLinkAttributes), nameof (RequirePublicConstructors), new Type[] { typeof (Type) })]
- [UnrecognizedReflectionAccessPattern (typeof (SuppressWarningWithLinkAttributes), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) })]
+ [UnrecognizedReflectionAccessPattern (typeof (SuppressWarningWithLinkAttributes), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
+ [UnrecognizedReflectionAccessPattern (typeof (SuppressWarningWithLinkAttributes), nameof (RequireNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2077")]
[RecognizedReflectionAccessPattern]
private void ReadFromInstanceField ()
{
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.xml b/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.xml
index 335a2e521..57889aafd 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.xml
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/SuppressWarningWithLinkAttributes.xml
@@ -3,7 +3,7 @@
<assembly fullname="Test">
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>Test</argument>
- <argument>IL2006</argument>
+ <argument>IL2067</argument>
</attribute>
<type fullname="Mono.Linker.Tests.Cases.DataFlow.SuppressWarningWithLinkAttributes">
<field name="_typeWithPublicParameterlessConstructor">
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs b/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs
index bf1418882..d28d2c815 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs
@@ -137,10 +137,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
[LogDoesNotContain ("DerivedClass.ReturnValueBaseWithoutDerivedWithout")]
public override Type ReturnValueBaseWithoutDerivedWithout () => null;
- [LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.ReturnValueBaseWithoutDerivedWith()' " +
- "don't match overridden return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.ReturnValueBaseWithoutDerivedWith()'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ [ExpectedWarning ("IL2093", "BaseClass.ReturnValueBaseWithoutDerivedWith", "DerivedClass.ReturnValueBaseWithoutDerivedWith")]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public override Type ReturnValueBaseWithoutDerivedWith () => null;
@@ -153,10 +150,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// === Method parameters ===
- [LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.SingleParameterBaseWithDerivedWithout(Type)' " +
- "don't match overridden parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.SingleParameterBaseWithDerivedWithout(Type)'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ [ExpectedWarning ("IL2092",
+ "p", "Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.SingleParameterBaseWithDerivedWithout(Type)",
+ "p", "Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.SingleParameterBaseWithDerivedWithout(Type)")]
public override void SingleParameterBaseWithDerivedWithout (Type p) { }
[LogDoesNotContain ("DerivedClass.SingleParameterBaseWithDerivedWith_")]
@@ -166,9 +162,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{ }
[LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.SingleParameterBaseWithoutDerivedWith_(Type)' " +
+ "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.SingleParameterBaseWithoutDerivedWith_(Type)' " +
"don't match overridden parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.SingleParameterBaseWithoutDerivedWith_(Type)'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ "All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.")]
public override void SingleParameterBaseWithoutDerivedWith_ (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
Type p)
@@ -178,9 +174,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
public override void SingleParameterBaseWithoutDerivedWithout (Type p) { }
[LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.SingleParameterBaseWithDerivedWithDifferent(Type)' " +
+ "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.SingleParameterBaseWithDerivedWithDifferent(Type)' " +
"don't match overridden parameter 'p' of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.SingleParameterBaseWithDerivedWithDifferent(Type)'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ "All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.")]
public override void SingleParameterBaseWithDerivedWithDifferent (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)]
Type p)
@@ -231,16 +227,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{ }
// === Generic methods ===
- [LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.GenericBaseWithDerivedWithout<T>()' " +
- "don't match overridden generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.GenericBaseWithDerivedWithout<T>()'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ [ExpectedWarning ("IL2095",
+ "T", "Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.GenericBaseWithDerivedWithout<T>()",
+ "T", "Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.GenericBaseWithDerivedWithout<T>()")]
public override void GenericBaseWithDerivedWithout<T> () { }
[LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.GenericBaseWithoutDerivedWith<T>()' " +
- "don't match overridden generic parameter 'T' from 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.GenericBaseWithoutDerivedWith<T>()'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the generic parameter 'T' of 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.GenericBaseWithoutDerivedWith<T>()' " +
+ "don't match overridden generic parameter 'T' of 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.GenericBaseWithoutDerivedWith<T>()'. " +
+ "All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.")]
public override void GenericBaseWithoutDerivedWith<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]T> () { }
[LogDoesNotContain ("DerivedClass.GenericBaseWithDerivedWith_")]
@@ -254,9 +249,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// The warning is reported on the getter (or setter), which is not ideal, but it's probably good enough for now (we don't internally track annotations
// on properties themselves, only on methods).
[LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.get_PropertyBaseWithDerivedWithout()' " +
+ "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.get_PropertyBaseWithDerivedWithout()' " +
"don't match overridden return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.get_PropertyBaseWithDerivedWithout()'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ "All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.")]
public override Type PropertyBaseWithDerivedWithout { get; }
[LogDoesNotContain ("DerivedClass.get_PropertyBaseWithDerivedWith_")]
@@ -271,14 +266,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow
// === RequiresUnreferencedCode ===
[LogContains (
- "Presence of RequiresUnreferencedCodeAttribute on method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.RequiresUnreferencedCodeBaseWithDerivedWithout()' " +
+ "Presence of 'RequiresUnreferencedCodeAttribute' on method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.RequiresUnreferencedCodeBaseWithDerivedWithout()' " +
"doesn't match overridden method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.RequiresUnreferencedCodeBaseWithDerivedWithout()'. " +
- "All overridden methods must have RequiresUnreferencedCodeAttribute.")]
+ "All overridden methods must have 'RequiresUnreferencedCodeAttribute'.")]
public override void RequiresUnreferencedCodeBaseWithDerivedWithout () { }
[LogContains (
- "Presence of RequiresUnreferencedCodeAttribute on method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.RequiresUnreferencedCodeBaseWithoutDerivedWith_()' " +
+ "Presence of 'RequiresUnreferencedCodeAttribute' on method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.RequiresUnreferencedCodeBaseWithoutDerivedWith_()' " +
"doesn't match overridden method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.RequiresUnreferencedCodeBaseWithoutDerivedWith_()'. " +
- "All overridden methods must have RequiresUnreferencedCodeAttribute.")]
+ "All overridden methods must have 'RequiresUnreferencedCodeAttribute'.")]
[RequiresUnreferencedCode ("")]
public override void RequiresUnreferencedCodeBaseWithoutDerivedWith_ () { }
[LogDoesNotContain ("DerivedClass.RequiresUnreferencedCodeBaseWithDerivedWith_")]
@@ -297,9 +292,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
// === Return values ===
[LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.SuperDerivedClass.ReturnValueBaseWithSuperDerivedWithout()' " +
+ "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.SuperDerivedClass.ReturnValueBaseWithSuperDerivedWithout()' " +
"don't match overridden return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.ReturnValueBaseWithSuperDerivedWithout()'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ "All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.")]
public override Type ReturnValueBaseWithSuperDerivedWithout () => null;
// === RequiresUnreferencedCode ===
@@ -566,9 +561,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
class BaseImplementsInterfaceViaDerived
{
[LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseImplementsInterfaceViaDerived.ReturnValueBaseWithInterfaceWithout()' " +
+ "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseImplementsInterfaceViaDerived.ReturnValueBaseWithInterfaceWithout()' " +
"don't match overridden return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.IBaseImplementedInterface.ReturnValueBaseWithInterfaceWithout()'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ "All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.")]
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]
public virtual Type ReturnValueBaseWithInterfaceWithout () => null;
@@ -615,10 +610,9 @@ namespace System
class VirtualMethodHierarchyDataflowAnnotationValidationTypeTestDerived : VirtualMethodHierarchyDataflowAnnotationValidationTypeTestBase
{
- [LogContains (
- "DynamicallyAccessedMemberTypes in DynamicallyAccessedMembersAttribute on implicit 'this' parameter of method 'System.VirtualMethodHierarchyDataflowAnnotationValidationTypeTestDerived.ThisBaseWithDerivedWithout()' " +
- "don't match overridden implicit 'this' parameter of method 'System.VirtualMethodHierarchyDataflowAnnotationValidationTypeTestBase.ThisBaseWithDerivedWithout()'. " +
- "All overridden members must have the same DynamicallyAccessedMembersAttribute usage.")]
+ [ExpectedWarning ("IL2094",
+ "System.VirtualMethodHierarchyDataflowAnnotationValidationTypeTestDerived.ThisBaseWithDerivedWithout()",
+ "System.VirtualMethodHierarchyDataflowAnnotationValidationTypeTestBase.ThisBaseWithDerivedWithout()")]
public override void ThisBaseWithDerivedWithout () { }
[LogDoesNotContain ("VirtualMethodHierarchyDataflowAnnotationValidationTypeTestDerived.ThisBaseWithDerivedWith_")]
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.cs b/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.cs
index ac6e536f7..1e6fbd348 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.cs
@@ -13,8 +13,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
[SkipKeptItemsValidation]
[SetupLinkAttributesFile ("XmlAnnotations.xml")]
- [LogContains ("XmlAnnotations.xml: warning IL2031: Attribute type 'System.DoesNotExistAttribute' could not be found")]
- [LogDoesNotContain ("IL2006: Mono.Linker.Tests.Cases.DataFlow.XmlAnnotations.ReadFromInstanceField():*", true)]
+ [ExpectedWarning ("IL2031", "System.DoesNotExistAttribute", FileName = "XmlAnnotations.xml")]
+ [LogDoesNotContain ("IL2067: Mono.Linker.Tests.Cases.DataFlow.XmlAnnotations.ReadFromInstanceField():*", true)]
class XmlAnnotations
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.xml b/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.xml
index 2747c6263..46fb37653 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.xml
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/XmlAnnotations.xml
@@ -3,7 +3,7 @@
<assembly fullname="Test">
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<argument>ILLink</argument>
- <argument>IL2006</argument>
+ <argument>IL2067</argument>
<property name="Scope">member</property>
<property name="Target">M:Mono.Linker.Tests.Cases.DataFlow.XmlAnnotations.ReadFromInstanceField</property>
</attribute>