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
path: root/test
diff options
context:
space:
mode:
authorVitek Karas <10670590+vitek-karas@users.noreply.github.com>2022-04-22 23:58:08 +0300
committerGitHub <noreply@github.com>2022-04-22 23:58:08 +0300
commitdec9a23c4c164111df76d427656357113c0d705a (patch)
treecd4202c74f229449a513f54cb803fbe4dd81a709 /test
parent137b7b994e410843b783cb5b04c92a6ca693b2e8 (diff)
Fix handling of special intrinsics in analyzer (#2756)
Some intrinsics require generic instantiation handling. Currently the shared code doesn't have the abitlity to do this, so we leave it as a special case and analyzer/linker have special code to handle it. In the analyzer this code was missing from the diagnsotic reporting part and thus the intrinsic was handled as a normal method call - which caused problems with TypeDelegator. Added tests for TypeDelegator which cover these issues.
Diffstat (limited to 'test')
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/ReflectionTests.cs6
-rw-r--r--test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/ReflectionTests.g.cs6
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/TypeDelegator.cs30
3 files changed, 29 insertions, 13 deletions
diff --git a/test/ILLink.RoslynAnalyzer.Tests/ReflectionTests.cs b/test/ILLink.RoslynAnalyzer.Tests/ReflectionTests.cs
index 605a37e47..b0f719ac8 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/ReflectionTests.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/ReflectionTests.cs
@@ -169,6 +169,12 @@ namespace ILLink.RoslynAnalyzer.Tests
}
[Fact]
+ public Task TypeDelegator ()
+ {
+ return RunTest ();
+ }
+
+ [Fact]
public Task TypeHierarchyReflectionWarnings ()
{
// https://github.com/dotnet/linker/issues/2578
diff --git a/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/ReflectionTests.g.cs b/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/ReflectionTests.g.cs
index 353ac8968..08642e90e 100644
--- a/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/ReflectionTests.g.cs
+++ b/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/ReflectionTests.g.cs
@@ -62,12 +62,6 @@ namespace ILLink.RoslynAnalyzer.Tests
}
[Fact]
- public Task TypeDelegator ()
- {
- return RunTest (allowMissingWarnings: true);
- }
-
- [Fact]
public Task TypeHierarchyLibraryModeSuppressions ()
{
return RunTest (allowMissingWarnings: true);
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/TypeDelegator.cs b/test/Mono.Linker.Tests.Cases/Reflection/TypeDelegator.cs
index fb7f61b04..4f5d0542c 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/TypeDelegator.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/TypeDelegator.cs
@@ -7,9 +7,11 @@ using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Text;
using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Helpers;
namespace Mono.Linker.Tests.Cases.Reflection
{
+ [ExpectedNoWarnings]
public class TypeDelegator
{
public static void Main ()
@@ -17,6 +19,8 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestTypeUsedWithDelegator ();
TestNullValue ();
TestNoValue ();
+ TestDataFlowPropagation ();
+ TestDataFlowOfUnannotated ();
}
[Kept]
@@ -38,7 +42,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
static void TestNullValue ()
{
var typeDelegator = new System.Reflection.TypeDelegator (null);
- RequireAll (typeDelegator);
+ typeDelegator.RequiresAll ();
}
[Kept]
@@ -47,15 +51,27 @@ namespace Mono.Linker.Tests.Cases.Reflection
Type t = null;
Type noValue = Type.GetTypeFromHandle (t.TypeHandle);
var typeDelegator = new System.Reflection.TypeDelegator (noValue);
- RequireAll (typeDelegator);
+ typeDelegator.RequiresAll ();
}
[Kept]
- public static void RequireAll (
+ [ExpectedWarning ("IL2067", nameof (DataFlowTypeExtensions.RequiresPublicFields))]
+ static void TestDataFlowPropagation (
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
- [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)]
- System.Reflection.TypeDelegator t
- )
- { }
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ Type typeWithPublicMethods = null)
+ {
+ var typeDelegator = new System.Reflection.TypeDelegator (typeWithPublicMethods);
+ typeDelegator.RequiresPublicMethods (); // Should not warn
+ typeDelegator.RequiresPublicFields (); // Should warn
+ }
+
+ [Kept]
+ [ExpectedWarning ("IL2067", nameof (DataFlowTypeExtensions.RequiresPublicMethods))]
+ static void TestDataFlowOfUnannotated (Type unknownType = null)
+ {
+ var typeDelegator = new System.Reflection.TypeDelegator (unknownType);
+ unknownType.RequiresPublicMethods ();
+ }
}
}