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-05-31 21:28:55 +0300
committerGitHub <noreply@github.com>2021-05-31 21:28:55 +0300
commit493a448586c1fad68efc2126836f5bb9b5f9ad20 (patch)
tree6043095317001e2a40ca8eb23cf5cbd3a1bd8007 /test/Mono.Linker.Tests.Cases
parent6c33faaf912c3161f75d205da54b93847d647fe4 (diff)
Use full MessageOrigin when reporting data flow warnings (#2070)
Recent chaneg introduced a scope stack to marking which carries `MessageOrigin` around so that warnings can be reported with precise origin. The one exception to this was the `ReflectionMethodBodyScanner`. This change integrates the scope stack with `ReflectionMethodBodyScanner`. The visible result is more precise reporting of some warnings. This change will be needed for the work around compiler generated code (since then MessageOrigin will carry even more information than it does currently). The main API change is addition of the `MessageOrigin` parameter to the `IReflectionPatternRecorder.UnrecognizedReflectionAccessPattern`. There are plans to remove this interface completely, so there' not much need to clean it up right now (so I left the potentially duplicated `origin` and `source` arguments as is). The rest of the change is just correctly flowing the information around. I also improved the test infra to be able to correctly handle `ExpectedWarning` with source/line info on all warnings. There are visible changes in the `SourceLines` test where some warnings changed location (more precise now).
Diffstat (limited to 'test/Mono.Linker.Tests.Cases')
-rw-r--r--test/Mono.Linker.Tests.Cases/Logging/SourceLines.cs17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Logging/SourceLines.cs b/test/Mono.Linker.Tests.Cases/Logging/SourceLines.cs
index a55f5cecf..c2e3766e3 100644
--- a/test/Mono.Linker.Tests.Cases/Logging/SourceLines.cs
+++ b/test/Mono.Linker.Tests.Cases/Logging/SourceLines.cs
@@ -7,11 +7,12 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.Logging
{
[SkipKeptItemsValidation]
- [SetupCompileBefore ("FakeSystemAssembly.dll", new[] { "../PreserveDependencies/Dependencies/PreserveDependencyAttribute.cs" })]
[SetupCompileArgument ("/debug:full")]
- [LogContains ("(33,4): Trim analysis warning IL2074")]
- [LogContains ("(34,4): Trim analysis warning IL2074")]
- [LogContains ("(38,3): Trim analysis warning IL2091")]
+ [ExpectedNoWarnings]
+ [ExpectedWarning ("IL2074", FileName = "", SourceLine = 34, SourceColumn = 4)]
+ [ExpectedWarning ("IL2074", FileName = "", SourceLine = 35, SourceColumn = 4)]
+ [ExpectedWarning ("IL2091", FileName = "", SourceLine = 44, SourceColumn = 4)]
+ [ExpectedWarning ("IL2089", FileName = "", SourceLine = 48, SourceColumn = 36)]
public class SourceLines
{
public static void Main ()
@@ -30,8 +31,8 @@ namespace Mono.Linker.Tests.Cases.Logging
static void UnrecognizedReflectionPattern ()
{
- type = GetUnknownType ();
- type = GetUnknownType ();
+ type = GetUnknownType (); // IL2074
+ type = GetUnknownType (); // IL2074
}
static IEnumerable<int> GenericMethodIteratorWithRequirement<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] TOuterMethod> ()
@@ -40,11 +41,11 @@ namespace Mono.Linker.Tests.Cases.Logging
// but this T doesn't inherit the DAM annotation.
// So calling the LocationFunction which requires the DAM on T will generate a warning
// but that warning comes from compiler generated code - there's no user code doing that.
- LocalFunction ();
+ LocalFunction (); // IL2091 - The issue with attributes not propagating to the iterator generics
yield return 1;
// The generator code for LocalFunction inherits the DAM on the T
- static void LocalFunction () => type = typeof (TOuterMethod);
+ static void LocalFunction () => type = typeof (TOuterMethod); // IL2089 - TOuterMethod is PublicMethods, but type is PublicConstructors
}
}
}