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:
-rw-r--r--test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs29
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs25
2 files changed, 54 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs
index 1b19ef3b7..a036b9fb9 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsInMembersAndTypes.cs
@@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Helpers;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
@@ -27,6 +28,8 @@ namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
int propertyThatTriggersWarning = suppressWarningsInMembers.Property;
NestedType.Warning ();
+
+ SuppressOnTypeMarkedEntirely.Test ();
}
public static Type TriggerUnrecognizedPattern ()
@@ -97,4 +100,30 @@ namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
}
}
}
+
+ class SuppressOnTypeMarkedEntirely
+ {
+ // https://github.com/mono/linker/issues/2095
+ // [LogDoesNotContain (nameof(TypeWithSuppression) + " has more than one unconditional suppression")]
+ [LogContains (nameof (TypeWithSuppression) + " has more than one unconditional suppression")]
+ [UnconditionalSuppressMessage ("Test", "IL2026")]
+ class TypeWithSuppression
+ {
+ [ExpectedNoWarnings]
+ public TypeWithSuppression ()
+ {
+ MethodWithRUC ();
+ }
+
+ int _field;
+ }
+
+ public static void Test ()
+ {
+ typeof (TypeWithSuppression).RequiresAll ();
+ }
+
+ [RequiresUnreferencedCode ("")]
+ static void MethodWithRUC () { }
+ }
} \ No newline at end of file
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs
index e528328df..12735c6e3 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs
@@ -113,6 +113,12 @@ namespace Mono.Linker.Tests.TestCasesRunner
context.LogMessages = true;
};
}
+
+ if (ValidatesLogMessages (_testCaseTypeDefinition)) {
+ customizations.CustomizeContext += context => {
+ context.LogMessages = true;
+ };
+ }
}
bool ValidatesReflectionAccessPatterns (TypeDefinition testCaseTypeDefinition)
@@ -135,6 +141,25 @@ namespace Mono.Linker.Tests.TestCasesRunner
return false;
}
+ bool ValidatesLogMessages (TypeDefinition testCaseTypeDefinition)
+ {
+ if (testCaseTypeDefinition.HasNestedTypes) {
+ var nestedTypes = new Queue<TypeDefinition> (testCaseTypeDefinition.NestedTypes.ToList ());
+ while (nestedTypes.Count > 0) {
+ if (ValidatesLogMessages (nestedTypes.Dequeue ()))
+ return true;
+ }
+ }
+
+ if (testCaseTypeDefinition.AllMembers ().Concat (testCaseTypeDefinition.AllDefinedTypes ()).Append (testCaseTypeDefinition)
+ .Any (m => m.CustomAttributes.Any (attr =>
+ attr.AttributeType.Name == nameof (LogContainsAttribute) ||
+ attr.AttributeType.Name == nameof (LogDoesNotContainAttribute))))
+ return true;
+
+ return false;
+ }
+
public virtual IEnumerable<string> GetCommonReferencedAssemblies (NPath workingDirectory)
{
yield return workingDirectory.Combine ("Mono.Linker.Tests.Cases.Expectations.dll").ToString ();