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>2021-06-17 14:26:49 +0300
committerGitHub <noreply@github.com>2021-06-17 14:26:49 +0300
commit4f68312aeb4b8b906bee4e06438020ad6721c522 (patch)
treeb684a3c48662b487ecc5a7ff0152af003918d44a /test/Mono.Linker.Tests
parentfb9ef5b60a953842a597f0c71ffb862ecaae4af7 (diff)
Add a test for case where we report double suppression incorrectly (#2096)
Diffstat (limited to 'test/Mono.Linker.Tests')
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs25
1 files changed, 25 insertions, 0 deletions
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 ();