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 15:04:44 +0300
committerGitHub <noreply@github.com>2021-06-17 15:04:44 +0300
commitbee7f73564e495e6ab8627e7c595dacc32a4b096 (patch)
treeefa4d4c7116898b736223e24b431843f124bb668 /test/Mono.Linker.Tests.Cases.Expectations/Assertions
parent4f68312aeb4b8b906bee4e06438020ad6721c522 (diff)
Warning suppressions in compiler generated code (#2075)
This change implements the following high-level functionality: * `UnconditionalSuppressMessage` applies to the entire method body even for iterators, async methods * `RequiresUnreferencedCode` automatically suppresses trim analysis warnings from entire method body for iterators, async methods Solution approach: * Detect compiler generated code by using the `IteratorStateMachineAttribute`, `AsyncStateMachineAttribute` and `AyncIteratorStateMachineAttribute`. * When a method which is compiler generated (detected by looing for `<` in its name) is processed the original "user method" is determined by looking for a method with the "state machine" attribute pointing to the compiler generated type. * This information is cached to avoid duplication of relatively expensive detection logic. * Looks for `UnconditionalSuppressMessage` and `RequriesUnreferencedCode` in: * If the warning origin is not a compiler generated code - simply use the warning origin (method) - existing behavior * If the warning origin is compiler generated use both the origin as well as the user defined method (non-compiler-generated) which is the source of the code for the compiler generated origin This is done by storing additional `SuppressionContextMember` on `MessageOrigin` which should always point to non-compiler-generated item. Added lot of new tests for these scenarios. This implements warning suppression part of https://github.com/mono/linker/issues/2001 for state machines.
Diffstat (limited to 'test/Mono.Linker.Tests.Cases.Expectations/Assertions')
-rw-r--r--test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedWarningAttribute.cs2
1 files changed, 2 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedWarningAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedWarningAttribute.cs
index 85bd85d67..04ba3fdcb 100644
--- a/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedWarningAttribute.cs
+++ b/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectedWarningAttribute.cs
@@ -18,5 +18,7 @@ namespace Mono.Linker.Tests.Cases.Expectations.Assertions
// Set to true if the warning only applies to global analysis (ILLinker, as opposed to Roslyn Analyzer)
public bool GlobalAnalysisOnly { get; set; }
+
+ public bool CompilerGeneratedCode { get; set; }
}
}