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:
authorMike Voorhees <mrvoorhe@users.noreply.github.com>2020-04-03 14:56:17 +0300
committerGitHub <noreply@github.com>2020-04-03 14:56:17 +0300
commiteab8c894dade982cb95c9ccf1bd2cab1e3d7584c (patch)
tree66d7d74b35e1f48f9f19a5ba8349e2a9ea55f0b6 /test/Mono.Linker.Tests
parentb5e64137f890c9f9247f6cac8c0897da360c35fc (diff)
Open up ReflectionPatternRecorder more (#1049)
We implement detection of methods such as IsAssignableFrom which requires marking of an InterfaceImplementation. An InterfaceImplementation is not an IMemberDefinition so I was unable to record this reflection pattern. Changing RecognizedReflectionAccessPattern to accept an IMetadataTokenProvider allows us to record this detection.
Diffstat (limited to 'test/Mono.Linker.Tests')
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs25
-rw-r--r--test/Mono.Linker.Tests/TestCasesRunner/TestReflectionPatternRecorder.cs4
2 files changed, 16 insertions, 13 deletions
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
index 8660a0807..a84a64fbe 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
@@ -778,7 +778,7 @@ namespace Mono.Linker.Tests.TestCasesRunner {
return fullName;
}
- static string GetFullMemberNameFromDefinition (IMemberDefinition member)
+ static string GetFullMemberNameFromDefinition (IMetadataTokenProvider member)
{
// Method which basically returns the same as member.ToString() but without the return type
// of a method (if it's a method).
@@ -786,19 +786,22 @@ namespace Mono.Linker.Tests.TestCasesRunner {
// as it would have to actually resolve the referenced method, which is very expensive and no necessary
// for the tests to work (the return types are redundant piece of information anyway).
- if (member is TypeDefinition) {
- return member.FullName;
- }
+ if (member is IMemberDefinition memberDefinition) {
+ if (memberDefinition is TypeDefinition) {
+ return memberDefinition.FullName;
+ }
- string fullName = member.DeclaringType.FullName + "::";
- if (member is MethodDefinition method) {
- fullName += method.GetSignature ();
- }
- else {
- fullName += member.Name;
+ string fullName = memberDefinition.DeclaringType.FullName + "::";
+ if (memberDefinition is MethodDefinition method) {
+ fullName += method.GetSignature ();
+ } else {
+ fullName += memberDefinition.Name;
+ }
+
+ return fullName;
}
- return fullName;
+ throw new NotImplementedException ($"Getting the full member name has not been implemented for {member}");
}
static string RecognizedReflectionAccessPatternToString (TestReflectionPatternRecorder.ReflectionAccessPattern pattern)
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestReflectionPatternRecorder.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestReflectionPatternRecorder.cs
index 88b78ec3b..9073808c3 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/TestReflectionPatternRecorder.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/TestReflectionPatternRecorder.cs
@@ -9,14 +9,14 @@ namespace Mono.Linker.Tests.TestCasesRunner
{
public MethodDefinition SourceMethod;
public MethodDefinition ReflectionMethod;
- public IMemberDefinition AccessedItem;
+ public IMetadataTokenProvider AccessedItem;
public string Message;
}
public List<ReflectionAccessPattern> RecognizedPatterns = new List<ReflectionAccessPattern> ();
public List<ReflectionAccessPattern> UnrecognizedPatterns = new List<ReflectionAccessPattern> ();
- public void RecognizedReflectionAccessPattern (MethodDefinition sourceMethod, MethodDefinition reflectionMethod, IMemberDefinition accessedItem)
+ public void RecognizedReflectionAccessPattern (MethodDefinition sourceMethod, MethodDefinition reflectionMethod, IMetadataTokenProvider accessedItem)
{
RecognizedPatterns.Add (new ReflectionAccessPattern {
SourceMethod = sourceMethod,