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:
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedForwarderAttribute.cs15
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/CoreLinkAttribute.cs13
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerActionAttribute.cs18
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs20
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj4
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs3
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs2
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/ImplementationLibrary.cs4
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/TypeForwarderMissingReference.il37
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/MissingTargetReference.cs23
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesKept.cs4
-rw-r--r--linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesRemoved.cs2
-rw-r--r--linker/Tests/TestCasesRunner/LinkerArgumentBuilder.cs21
-rw-r--r--linker/Tests/TestCasesRunner/ResultChecker.cs21
-rw-r--r--linker/Tests/TestCasesRunner/TestCaseLinkerOptions.cs8
-rw-r--r--linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs15
-rw-r--r--linker/Tests/TestCasesRunner/TestRunner.cs9
20 files changed, 186 insertions, 39 deletions
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedForwarderAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedForwarderAttribute.cs
new file mode 100644
index 000000000..645a01bdc
--- /dev/null
+++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Assertions/RemovedForwarderAttribute.cs
@@ -0,0 +1,15 @@
+using System;
+namespace Mono.Linker.Tests.Cases.Expectations.Assertions
+{
+ [AttributeUsage (AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
+ public class RemovedForwarderAttribute : BaseInAssemblyAttribute
+ {
+ public RemovedForwarderAttribute (string assemblyFileName, string typeName)
+ {
+ if (string.IsNullOrEmpty (assemblyFileName))
+ throw new ArgumentException ("Value cannot be null or empty.", nameof (assemblyFileName));
+ if (string.IsNullOrEmpty (typeName))
+ throw new ArgumentException ("Value cannot be null or empty.", nameof (typeName));
+ }
+ }
+}
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/CoreLinkAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/CoreLinkAttribute.cs
deleted file mode 100644
index e287d5a56..000000000
--- a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/CoreLinkAttribute.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-
-namespace Mono.Linker.Tests.Cases.Expectations.Metadata {
- [AttributeUsage (AttributeTargets.Class)]
- public class CoreLinkAttribute : BaseMetadataAttribute {
-
- public CoreLinkAttribute (string value)
- {
- if (string.IsNullOrEmpty (value))
- throw new ArgumentException ("Value cannot be null or empty.", nameof (value));
- }
- }
-} \ No newline at end of file
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerActionAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerActionAttribute.cs
new file mode 100644
index 000000000..d0d68193e
--- /dev/null
+++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerActionAttribute.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace Mono.Linker.Tests.Cases.Expectations.Metadata
+{
+ [AttributeUsage (AttributeTargets.Class, AllowMultiple = true)]
+ public class SetupLinkerActionAttribute : BaseMetadataAttribute
+ {
+ public SetupLinkerActionAttribute (string action, string assembly)
+ {
+ switch (action) {
+ case "link": case "copy": case "skip":
+ break;
+ default:
+ throw new ArgumentOutOfRangeException (nameof (action));
+ }
+ }
+ }
+}
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs
new file mode 100644
index 000000000..c60bc59b2
--- /dev/null
+++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs
@@ -0,0 +1,20 @@
+using System;
+
+namespace Mono.Linker.Tests.Cases.Expectations.Metadata
+{
+ [AttributeUsage (AttributeTargets.Class, AllowMultiple = false)]
+ public class SetupLinkerCoreActionAttribute : BaseMetadataAttribute
+ {
+ public SetupLinkerCoreActionAttribute (string action)
+ {
+ switch (action) {
+ case "link":
+ case "copy":
+ case "skip":
+ break;
+ default:
+ throw new ArgumentOutOfRangeException (nameof (action));
+ }
+ }
+ }
+}
diff --git a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj
index 20c4a9479..5c063734c 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj
+++ b/linker/Tests/Mono.Linker.Tests.Cases.Expectations/Mono.Linker.Tests.Cases.Expectations.csproj
@@ -53,7 +53,6 @@
<Compile Include="Metadata\BaseMetadataAttribute.cs" />
<Compile Include="Metadata\SetupCompileAfterAttribute.cs" />
<Compile Include="Metadata\SetupCompileBeforeAttribute.cs" />
- <Compile Include="Metadata\CoreLinkAttribute.cs" />
<Compile Include="Metadata\DefineAttribute.cs" />
<Compile Include="Metadata\IncludeBlacklistStepAttribute.cs" />
<Compile Include="Metadata\Il8nAttribute.cs" />
@@ -64,6 +63,9 @@
<Compile Include="Assertions\KeptBaseTypeAttribute.cs" />
<Compile Include="Assertions\KeptInterfaceAttribute.cs" />
<Compile Include="Assertions\KeptAttributeAttribute.cs" />
+ <Compile Include="Assertions\RemovedForwarderAttribute.cs" />
+ <Compile Include="Metadata\SetupLinkerActionAttribute.cs" />
+ <Compile Include="Metadata\SetupLinkerCoreActionAttribute.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs b/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs
index 498c88378..a46a6deb5 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs
@@ -4,7 +4,8 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.CoreLink
{
- [CoreLink ("copy")]
+ [SetupLinkerCoreAction ("copy")]
+
[KeptAssembly ("mscorlib.dll")]
// These types are normally removed when the core libraries are linked
[KeptTypeInAssembly ("mscorlib.dll", typeof (ConsoleKeyInfo))]
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs b/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs
index 5f2db3ddb..5a39b04aa 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs
@@ -6,7 +6,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.CoreLink
{
- [CoreLink ("link")]
+ [SetupLinkerCoreAction ("link")]
[KeptAssembly ("mscorlib.dll")]
[KeptMemberInAssembly ("mscorlib.dll", typeof (Stack), ".ctor(System.Int32)", "Pop()", "Push(System.Object)")]
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs b/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs
index b7edac39e..9a0d90f53 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs
@@ -4,7 +4,7 @@ using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.CoreLink {
- [CoreLink ("link")]
+ [SetupLinkerCoreAction ("link")]
[Reference("System.dll")]
[KeptAssembly ("mscorlib.dll")]
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj b/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
index 9601bca40..b293bb5fb 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
+++ b/linker/Tests/Mono.Linker.Tests.Cases/Mono.Linker.Tests.Cases.csproj
@@ -138,6 +138,8 @@
<Compile Include="VirtualMethods\TypeGetsMarkedThatImplementsAlreadyMarkedInterfaceMethod.cs" />
<Compile Include="VirtualMethods\VirtualMethodGetsPerservedIfBaseMethodGetsInvoked.cs" />
<Compile Include="VirtualMethods\VirtualMethodGetsStrippedIfImplementingMethodGetsInvokedDirectly.cs" />
+ <Compile Include="TypeForwarding\MissingTargetReference.cs" />
+ <None Include="TypeForwarding\Dependencies\TypeForwarderMissingReference.il" />
</ItemGroup>
<ItemGroup>
<Content Include="LinkXml\TypeWithPreserveFieldsHasBackingFieldsOfPropertiesRemoved.xml" />
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs
index d54ba5c21..f0a7a3f03 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs
@@ -3,7 +3,7 @@ using Mono.Linker.Tests.Cases.Expectations.Assertions;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
namespace Mono.Linker.Tests.Cases.References {
- [CoreLink ("link")]
+ [SetupLinkerCoreAction ("link")]
// Il8n & the blacklist step pollute the results with extra stuff that didn't need to be
// preserved for this test case so we need to disable them
[Il8n ("none")]
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/ImplementationLibrary.cs b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/ImplementationLibrary.cs
index f26aaa3b5..35c2252f4 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/ImplementationLibrary.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/ImplementationLibrary.cs
@@ -1,8 +1,10 @@
using System;
+using System.Reflection;
using Mono.Linker.Tests.Cases.Expectations.Metadata;
+[assembly: AssemblyVersion ("2.0")]
+
namespace Mono.Linker.Tests.Cases.TypeForwarding.Dependencies {
- [NotATestCase]
public class ImplementationLibrary {
public string GetSomeValue ()
{
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/TypeForwarderMissingReference.il b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/TypeForwarderMissingReference.il
new file mode 100644
index 000000000..0f8a1e93d
--- /dev/null
+++ b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/Dependencies/TypeForwarderMissingReference.il
@@ -0,0 +1,37 @@
+.assembly extern mscorlib
+{
+}
+.assembly extern 'missing-reference'
+{
+ .ver 0:0:0:0
+}
+
+.assembly 'TypeForwarderMissingReference'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+
+.class extern forwarder C
+{
+ .assembly extern 'missing-reference'
+}
+.class extern forwarder G`1
+{
+ .assembly extern 'missing-reference'
+}
+
+.module 'TypeForwarderMissingReference.dll'
+
+
+.class public auto ansi beforefieldinit DummyClass
+ extends [mscorlib]System.Object
+{
+ .method public hidebysig specialname rtspecialname
+ instance void .ctor() cil managed
+ {
+ IL_0000: ldarg.0
+ IL_0001: call instance void [mscorlib]System.Object::.ctor()
+ IL_0006: ret
+ }
+} \ No newline at end of file
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/MissingTargetReference.cs b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/MissingTargetReference.cs
new file mode 100644
index 000000000..07f43ef32
--- /dev/null
+++ b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/MissingTargetReference.cs
@@ -0,0 +1,23 @@
+using System;
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Metadata;
+
+namespace Mono.Linker.Tests.Cases.TypeForwarding
+{
+ [Define ("IL_ASSEMBLY_AVAILABLE")]
+ [SetupCompileBefore ("TypeForwarderMissingReference.dll", new [] { "Dependencies/TypeForwarderMissingReference.il" })]
+ [SetupLinkerAction ("link", "TypeForwarderMissingReference.dll")]
+
+ [KeptMemberInAssembly ("TypeForwarderMissingReference.dll", "DummyClass", ".ctor()")]
+ [RemovedForwarder ("TypeForwarderMissingReference.dll", "C")]
+ [RemovedForwarder ("TypeForwarderMissingReference.dll", "G<>")]
+ public class MissingTargetReference
+ {
+ public static void Main ()
+ {
+#if IL_ASSEMBLY_AVAILABLE
+ Console.WriteLine (new DummyClass ());
+#endif
+ }
+ }
+}
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesKept.cs b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesKept.cs
index e986def6a..e8a41a259 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesKept.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesKept.cs
@@ -13,13 +13,11 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding {
[SetupCompileAfter ("Implementation.dll", new[] { "Dependencies/ImplementationLibrary.cs" })]
[SetupCompileAfter ("Forwarder.dll", new[] { "Dependencies/ForwarderLibrary.cs" }, references: new[] { "Implementation.dll" })]
- [KeptAssembly ("Library.dll")]
- [KeptAssembly ("Implementation.dll")]
[KeptAssembly ("Forwarder.dll")]
[KeptMemberInAssembly ("Library.dll", typeof (LibraryUsingForwarder), "GetValueFromOtherAssembly()")]
[KeptMemberInAssembly ("Implementation.dll", typeof (ImplementationLibrary), "GetSomeValue()")]
public class TypeForwarderOnlyAssembliesKept {
- static void Main ()
+ public static void Main ()
{
Console.WriteLine (new ImplementationLibrary ().GetSomeValue ());
Console.WriteLine (new LibraryUsingForwarder ().GetValueFromOtherAssembly ());
diff --git a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesRemoved.cs b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesRemoved.cs
index 78c7fc571..91ddd58ee 100644
--- a/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesRemoved.cs
+++ b/linker/Tests/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwarderOnlyAssembliesRemoved.cs
@@ -14,8 +14,6 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
[SetupCompileAfter ("Implementation.dll", new[] { "Dependencies/ImplementationLibrary.cs" })]
[SetupCompileAfter ("Forwarder.dll", new[] { "Dependencies/ForwarderLibrary.cs" }, references: new[] { "Implementation.dll" })]
- [KeptAssembly ("Library.dll")]
- [KeptAssembly ("Implementation.dll")]
[RemovedAssembly ("Forwarder.dll")]
[KeptMemberInAssembly ("Implementation.dll", typeof (ImplementationLibrary), "GetSomeValue()")]
[KeptMemberInAssembly ("Library.dll", typeof (LibraryUsingForwarder), "GetValueFromOtherAssembly()")]
diff --git a/linker/Tests/TestCasesRunner/LinkerArgumentBuilder.cs b/linker/Tests/TestCasesRunner/LinkerArgumentBuilder.cs
index ce86808c7..3b095f5c3 100644
--- a/linker/Tests/TestCasesRunner/LinkerArgumentBuilder.cs
+++ b/linker/Tests/TestCasesRunner/LinkerArgumentBuilder.cs
@@ -29,6 +29,12 @@ namespace Mono.Linker.Tests.TestCasesRunner {
Append (value);
}
+ public virtual void LinkFromAssembly (string fileName)
+ {
+ Append ("-a");
+ Append (fileName);
+ }
+
public virtual void IncludeBlacklist (bool value)
{
Append ("-z");
@@ -47,6 +53,13 @@ namespace Mono.Linker.Tests.TestCasesRunner {
Append ("-t");
}
+ public virtual void AddAssemblyAction (string action, string assembly)
+ {
+ Append ("-p");
+ Append (action);
+ Append (assembly);
+ }
+
public string [] ToArgs ()
{
return _arguments.ToArray ();
@@ -59,7 +72,13 @@ namespace Mono.Linker.Tests.TestCasesRunner {
public virtual void ProcessOptions (TestCaseLinkerOptions options)
{
- AddCoreLink (options.CoreLink);
+ if (options.CoreAssembliesAction != null)
+ AddCoreLink (options.CoreAssembliesAction);
+
+ if (options.AssembliesAction != null) {
+ foreach (var entry in options.AssembliesAction)
+ AddAssemblyAction (entry.Key, entry.Value);
+ }
// Running the blacklist step causes a ton of stuff to be preserved. That's good for normal use cases, but for
// our test cases that pollutes the results
diff --git a/linker/Tests/TestCasesRunner/ResultChecker.cs b/linker/Tests/TestCasesRunner/ResultChecker.cs
index fcc175346..1deef5870 100644
--- a/linker/Tests/TestCasesRunner/ResultChecker.cs
+++ b/linker/Tests/TestCasesRunner/ResultChecker.cs
@@ -107,24 +107,35 @@ namespace Mono.Linker.Tests.TestCasesRunner {
var expectedTypeName = checkAttrInAssembly.ConstructorArguments [1].Value.ToString ();
var linkedType = linkedAssembly.MainModule.GetType (expectedTypeName);
- if (checkAttrInAssembly.AttributeType.Name == nameof (RemovedTypeInAssemblyAttribute)) {
+ switch (checkAttrInAssembly.AttributeType.Name) {
+ case nameof (RemovedTypeInAssemblyAttribute):
if (linkedType != null)
Assert.Fail ($"Type `{expectedTypeName}' should have been removed");
- } else if (checkAttrInAssembly.AttributeType.Name == nameof (KeptTypeInAssemblyAttribute)) {
+ break;
+ case nameof (KeptTypeInAssemblyAttribute):
if (linkedType == null)
Assert.Fail ($"Type `{expectedTypeName}' should have been kept");
- } else if (checkAttrInAssembly.AttributeType.Name == nameof (RemovedMemberInAssemblyAttribute)) {
+ break;
+ case nameof (RemovedMemberInAssemblyAttribute):
if (linkedType == null)
continue;
VerifyRemovedMemberInAssembly (checkAttrInAssembly, linkedType);
- } else if (checkAttrInAssembly.AttributeType.Name == nameof (KeptMemberInAssemblyAttribute)) {
+ break;
+ case nameof (KeptMemberInAssemblyAttribute):
if (linkedType == null)
Assert.Fail ($"Type `{expectedTypeName}' should have been kept");
VerifyKeptMemberInAssembly (checkAttrInAssembly, linkedType);
- } else {
+ break;
+ case nameof (RemovedForwarderAttribute):
+ if (linkedAssembly.MainModule.ExportedTypes.Any (l => l.Name == expectedTypeName))
+ Assert.Fail ($"Forwarder `{expectedTypeName}' should have been removed");
+
+ break;
+ default:
UnhandledOtherAssemblyAssertion (expectedTypeName, checkAttrInAssembly, linkedType);
+ break;
}
}
}
diff --git a/linker/Tests/TestCasesRunner/TestCaseLinkerOptions.cs b/linker/Tests/TestCasesRunner/TestCaseLinkerOptions.cs
index 4fdb8dee2..f47a4e0c4 100644
--- a/linker/Tests/TestCasesRunner/TestCaseLinkerOptions.cs
+++ b/linker/Tests/TestCasesRunner/TestCaseLinkerOptions.cs
@@ -1,7 +1,11 @@
-namespace Mono.Linker.Tests.TestCasesRunner {
+using System.Collections.Generic;
+
+namespace Mono.Linker.Tests.TestCasesRunner {
public class TestCaseLinkerOptions
{
- public string CoreLink;
+ public string CoreAssembliesAction;
+ public List<KeyValuePair<string, string>> AssembliesAction = new List<KeyValuePair<string, string>> ();
+
public string Il8n;
public bool IncludeBlacklistStep;
public string KeepTypeForwarderOnlyAssemblies;
diff --git a/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs
index 46b981793..fbd5f0fe3 100644
--- a/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs
+++ b/linker/Tests/TestCasesRunner/TestCaseMetadaProvider.cs
@@ -26,13 +26,20 @@ namespace Mono.Linker.Tests.TestCasesRunner {
public virtual TestCaseLinkerOptions GetLinkerOptions ()
{
- return new TestCaseLinkerOptions
- {
- CoreLink = GetOptionAttributeValue (nameof (CoreLinkAttribute), "skip"),
+ var tclo = new TestCaseLinkerOptions {
Il8n = GetOptionAttributeValue (nameof (Il8nAttribute), string.Empty),
IncludeBlacklistStep = GetOptionAttributeValue (nameof (IncludeBlacklistStepAttribute), false),
- KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue (nameof (KeepTypeForwarderOnlyAssembliesAttribute), string.Empty)
+ KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue (nameof (KeepTypeForwarderOnlyAssembliesAttribute), string.Empty),
+ CoreAssembliesAction = GetOptionAttributeValue<string> (nameof (SetupLinkerCoreActionAttribute), null)
};
+
+ foreach (var assemblyAction in _testCaseTypeDefinition.CustomAttributes.Where (attr => attr.AttributeType.Name == nameof (SetupLinkerActionAttribute)))
+ {
+ var ca = assemblyAction.ConstructorArguments;
+ tclo.AssembliesAction.Add (new KeyValuePair<string, string> ((string)ca [0].Value, (string)ca [1].Value));
+ }
+
+ return tclo;
}
public virtual IEnumerable<string> GetReferencedAssemblies (NPath workingDirectory)
diff --git a/linker/Tests/TestCasesRunner/TestRunner.cs b/linker/Tests/TestCasesRunner/TestRunner.cs
index 9693eeaf7..b9255435a 100644
--- a/linker/Tests/TestCasesRunner/TestRunner.cs
+++ b/linker/Tests/TestCasesRunner/TestRunner.cs
@@ -23,7 +23,7 @@ namespace Mono.Linker.Tests.TestCasesRunner {
var sandbox = Sandbox (testCase, metadataProvider);
var compilationResult = Compile (sandbox, metadataProvider);
- PrepForLink (sandbox, compilationResult);
+// PrepForLink (sandbox, compilationResult);
return Link (testCase, sandbox, compilationResult, metadataProvider);
}
}
@@ -47,13 +47,13 @@ namespace Mono.Linker.Tests.TestCasesRunner {
var expectationsAssemblyPath = compiler.CompileTestIn (sandbox.ExpectationsDirectory, "test.exe", sourceFiles, references, new [] { "INCLUDE_EXPECTATIONS" });
return new ManagedCompilationResult (inputAssemblyPath, expectationsAssemblyPath);
}
-
+/*
private void PrepForLink (TestCaseSandbox sandbox, ManagedCompilationResult compilationResult)
{
var entryPointLinkXml = sandbox.InputDirectory.Combine ("entrypoint.xml");
LinkXmlHelpers.WriteXmlFileToPreserveEntryPoint (compilationResult.InputAssemblyPath, entryPointLinkXml);
}
-
+*/
private LinkedTestCaseResult Link (TestCase testCase, TestCaseSandbox sandbox, ManagedCompilationResult compilationResult, TestCaseMetadaProvider metadataProvider)
{
var linker = _factory.CreateLinker ();
@@ -72,6 +72,9 @@ namespace Mono.Linker.Tests.TestCasesRunner {
AddAdditionalLinkOptions (builder, metadataProvider);
+ // TODO: Should be overridable
+ builder.LinkFromAssembly (compilationResult.InputAssemblyPath.ToString ());
+
linker.Link (builder.ToArgs ());
return new LinkedTestCaseResult (testCase, compilationResult.InputAssemblyPath, sandbox.OutputDirectory.Combine (compilationResult.InputAssemblyPath.FileName), compilationResult.ExpectationsAssemblyPath);