diff --git a/docs/error-codes.md b/docs/error-codes.md
index 3a66bde74bfa..c674f363c00b 100644
--- a/docs/error-codes.md
+++ b/docs/error-codes.md
@@ -129,6 +129,10 @@ the error code. For example:
#### `IL1038`: Exported type '{type.Name}' cannot be resolved
+#### `IL1039`: Reference assembly '{assemblyPath}' could not be loaded
+
+- A reference assembly input passed via -reference could not be loaded.
+
----
## Warning Codes
@@ -1510,6 +1514,15 @@ This is technically possible if a custom assembly defines `DynamicDependencyAttr
```
+#### `IL2102`: Invalid AssemblyMetadata("IsTrimmable", ...) attribute in assembly 'assembly'. Value must be "True"
+
+- AssemblyMetadataAttribute may be used at the assembly level to turn on trimming for the assembly. The only supported value is "True", but the attribute contained an unsupported value.
+
+ ``` C#
+ // IL2102: Invalid AssemblyMetadata("IsTrimmable", "False") attribute in assembly 'assembly'. Value must be "True"
+ [assembly: AssemblyMetadata("IsTrimmable", "False")]
+ ```
+
## Single-File Warning Codes
#### `IL3000`: 'member' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'
diff --git a/docs/illink-options.md b/docs/illink-options.md
index 52d1ea2f95e8..edd02d7cc7e1 100644
--- a/docs/illink-options.md
+++ b/docs/illink-options.md
@@ -58,22 +58,25 @@ The linker can do the following things on all or individual assemblies
- `delete`- remove them from the output
- `save` - save them in memory without linking
-You can specify an action per assembly using `-p` option like this:
+You can specify an action per assembly using `--action` option like this:
-`illink -p link Foo`
+`illink --action link Foo`
or
-`illink -p skip System.Windows.Forms`
+`illink --action skip System.Windows.Forms`
-Or you can specify what to do for the core assemblies.
+Or you can specify what to do for the trimmed assemblies.
-Core assemblies are the assemblies that belong to the base class library,
-like `System.Private.CoreLib.dll`, `System.dll` or `System.Windows.Forms.dll`.
+A trimmable assembly is any assembly that includes the attribute `System.Reflection.AssemblyMetadata("IsTrimmable", "True")`.
-You can specify what action to do on the core assemblies with the option:
+You can specify what action to do on the trimmed assemblies with the option:
-`-c skip|copy|link`
+`--trim-mode skip|copy|copyused|link`
+
+You can specify what action to do on assemblies without such an attribute with the option:
+
+`--action copy|link`
### The output directory
diff --git a/docs/illink-tasks.md b/docs/illink-tasks.md
index 50b8883ba5be..e6566f114523 100644
--- a/docs/illink-tasks.md
+++ b/docs/illink-tasks.md
@@ -58,7 +58,7 @@ The linker can be invoked as an MSBuild task, `ILLink`. We recommend not using t
RootAssemblyNames="@(LinkerRootAssemblies)"
RootDescriptorFiles="@(LinkerRootDescriptors)"
OutputDirectory="output"
- ExtraArgs="-t -c link" />
+ ExtraArgs="-t --trim-mode link" />
```
## Default Linking Behavior
diff --git a/src/ILLink.Tasks/LinkTask.cs b/src/ILLink.Tasks/LinkTask.cs
index a1bdf38b6281..164972dcd035 100644
--- a/src/ILLink.Tasks/LinkTask.cs
+++ b/src/ILLink.Tasks/LinkTask.cs
@@ -23,7 +23,7 @@ public class ILLink : ToolTask
/// UnusedInterfaces
/// IPConstProp
/// Sealer
- /// Maps to '-reference', and possibly '-p', '--enable-opt', '--disable-opt'
+ /// Maps to '-reference', and possibly '--action', '--enable-opt', '--disable-opt'
///
[Required]
public ITaskItem[] AssemblyPaths { get; set; }
@@ -31,7 +31,7 @@ public class ILLink : ToolTask
///
/// Paths to assembly files that are reference assemblies,
/// representing the surface area for compilation.
- /// Maps to '-reference', with action set to 'skip' via '-p'.
+ /// Maps to '-reference', with action set to 'skip' via '--action'.
///
public ITaskItem[] ReferenceAssemblyPaths { get; set; }
@@ -180,11 +180,16 @@ public class ILLink : ToolTask
bool? _removeSymbols;
///
- /// Sets the default action for assemblies.
- /// Maps to '-c' and '-u'.
+ /// Sets the default action for trimmable assemblies.
+ /// Maps to '--trim-mode'
///
public string TrimMode { get; set; }
+ ///
+ /// Sets the default action for assemblies which have not opted into trimming.
+ /// Maps to '--action'
+ public string DefaultAction { get; set; }
+
///
/// A list of custom steps to insert into the linker pipeline.
/// Each ItemSpec should be the path to the assembly containing the custom step.
@@ -296,7 +301,7 @@ protected override string GenerateResponseFileCommands ()
string trimMode = assembly.GetMetadata ("TrimMode");
if (!String.IsNullOrEmpty (trimMode)) {
- args.Append ("-p ");
+ args.Append ("--action ");
args.Append (trimMode);
args.Append (' ').AppendLine (Quote (assemblyName));
}
@@ -329,7 +334,7 @@ protected override string GenerateResponseFileCommands ()
// Treat reference assemblies as "skip". Ideally we
// would not even look at the IL, but only use them to
// resolve surface area.
- args.Append ("-p skip ").AppendLine (Quote (assemblyName));
+ args.Append ("--action skip ").AppendLine (Quote (assemblyName));
}
}
@@ -396,7 +401,10 @@ protected override string GenerateResponseFileCommands ()
args.AppendLine ("-b");
if (TrimMode != null)
- args.Append ("-c ").Append (TrimMode).Append (" -u ").AppendLine (TrimMode);
+ args.Append ("--trim-mode ").AppendLine (TrimMode);
+
+ if (DefaultAction != null)
+ args.Append ("--action ").AppendLine (DefaultAction);
if (CustomSteps != null) {
foreach (var customStep in CustomSteps) {
diff --git a/src/linker/Linker.Steps/MarkStep.cs b/src/linker/Linker.Steps/MarkStep.cs
index cc32af906022..d2bd25430b29 100644
--- a/src/linker/Linker.Steps/MarkStep.cs
+++ b/src/linker/Linker.Steps/MarkStep.cs
@@ -200,9 +200,6 @@ void Initialize ()
{
InitializeCorelibAttributeXml ();
- foreach (AssemblyDefinition assembly in _context.GetAssemblies ())
- InitializeAssembly (assembly);
-
ProcessMarkedPending ();
}
@@ -228,13 +225,6 @@ void InitializeCorelibAttributeXml ()
_context.CustomAttributes.PrimaryAttributeInfo.AddInternalAttributes (provider, annotations);
}
- protected virtual void InitializeAssembly (AssemblyDefinition assembly)
- {
- var action = _context.Annotations.GetAction (assembly);
- if (IsFullyPreservedAction (action))
- MarkAssembly (assembly, new DependencyInfo (DependencyKind.AssemblyAction, action));
- }
-
void Complete ()
{
foreach (var body in _unreachableBodies) {
@@ -386,7 +376,7 @@ bool MarkFullyPreservedAssemblies ()
// Fully mark any assemblies with copy/save action.
// Unresolved references could get the copy/save action if this is the default action.
- bool scanReferences = IsFullyPreservedAction (_context.CoreAction) || IsFullyPreservedAction (_context.UserAction);
+ bool scanReferences = IsFullyPreservedAction (_context.TrimAction) || IsFullyPreservedAction (_context.DefaultAction);
if (!scanReferences) {
// Unresolved references could get the copy/save action if it was set explicitly
@@ -1312,7 +1302,7 @@ protected void MarkAssembly (AssemblyDefinition assembly, DependencyInfo reason)
MarkExportedTypesTarget.ProcessAssembly (assembly, _context);
- if (IsFullyPreservedAction (_context.Annotations.GetAction (assembly))) {
+ if (ProcessReferencesStep.IsFullyPreservedAction (_context.Annotations.GetAction (assembly))) {
MarkEntireAssembly (assembly);
return;
}
diff --git a/src/linker/Linker.Steps/ProcessReferencesStep.cs b/src/linker/Linker.Steps/ProcessReferencesStep.cs
new file mode 100644
index 000000000000..4c329b37ca2d
--- /dev/null
+++ b/src/linker/Linker.Steps/ProcessReferencesStep.cs
@@ -0,0 +1,75 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections.Generic;
+using System.IO;
+
+namespace Mono.Linker.Steps
+{
+ public class ProcessReferencesStep : BaseStep
+ {
+ protected override void Process ()
+ {
+ // Walk over all -reference inputs and resolve any that may need to be rooted.
+
+ // For example:
+ // -reference dir/Unreferenced.dll --action copy --trim-mode copyused
+ // In this case we need to check whether Unreferenced has the
+ // IsTrimmable attribute, and root it if not.
+ // -reference dir/Unreferenced.dll --action copy --trim-mode copyused --action link Unreferenced
+ // The per-assembly action wins over the default --action or --trim-mode,
+ // so we don't need to load the assembly to check for IsTrimmable attribute.
+ // -reference dir/Unreferenced.dll --action link --trim-mode link
+ // In this case, we don't need to load the assembly up-front, because it will
+ // not get the copy/save action, regardless of the IsTrimmable attribute.
+
+ // Note that we don't do the same for assemblies which may be resolved from input directories - such
+ // assemblies will only be rooted if something loads them.
+ foreach (var assemblyPath in GetInputAssemblyPaths ()) {
+ var assemblyName = Path.GetFileNameWithoutExtension (assemblyPath);
+
+ // If there's no way that this reference could have the copy/save action,
+ // we don't need to load it up-front.
+ if (!MaybeIsFullyPreservedAssembly (assemblyName))
+ continue;
+
+ // For the remaining references, we need to resolve them (which looks for IsTrimmable attribute)
+ // to determine the action.
+ var assembly = Context.TryResolve (assemblyName);
+ if (assembly == null) {
+ Context.LogError ($"Reference assembly '{assemblyPath}' could not be loaded", 1039);
+ continue;
+ }
+
+ // If the assigned action (now taking into account the IsTrimmable attribute) requires us
+ // to root the assembly, do so.
+ if (IsFullyPreservedAction (Annotations.GetAction (assembly)))
+ Annotations.Mark (assembly.MainModule, new DependencyInfo (DependencyKind.AssemblyAction, assembly));
+ }
+ }
+
+ IEnumerable GetInputAssemblyPaths ()
+ {
+ var assemblies = new HashSet ();
+ foreach (var referencePath in Context.Resolver.GetReferencePaths ()) {
+ var assemblyName = Path.GetFileNameWithoutExtension (referencePath);
+ if (assemblies.Add (assemblyName))
+ yield return referencePath;
+ }
+ }
+
+ public static bool IsFullyPreservedAction (AssemblyAction action)
+ {
+ return action == AssemblyAction.Copy || action == AssemblyAction.Save;
+ }
+
+ bool MaybeIsFullyPreservedAssembly (string assemblyName)
+ {
+ if (Context.Actions.TryGetValue (assemblyName, out AssemblyAction action))
+ return IsFullyPreservedAction (action);
+
+ return IsFullyPreservedAction (Context.DefaultAction) || IsFullyPreservedAction (Context.TrimAction);
+ }
+ }
+}
diff --git a/src/linker/Linker/AssemblyResolver.cs b/src/linker/Linker/AssemblyResolver.cs
index 5fba31fbc113..4b6111a35efe 100644
--- a/src/linker/Linker/AssemblyResolver.cs
+++ b/src/linker/Linker/AssemblyResolver.cs
@@ -30,7 +30,6 @@
using System.Collections.Generic;
using System.IO;
using Mono.Cecil;
-using Mono.Collections.Generic;
namespace Mono.Linker
{
@@ -42,7 +41,7 @@ public class AssemblyResolver : DirectoryAssemblyResolver
HashSet _unresolvedAssemblies;
bool _ignoreUnresolved;
LinkContext _context;
- readonly Collection _references;
+ readonly List _references;
public IDictionary AssemblyCache {
@@ -57,7 +56,7 @@ public AssemblyResolver ()
public AssemblyResolver (Dictionary assembly_cache)
{
_assemblies = assembly_cache;
- _references = new Collection () { };
+ _references = new List () { };
}
public bool IgnoreUnresolved {
@@ -80,16 +79,18 @@ public string GetAssemblyFileName (AssemblyDefinition assembly)
return assembly.MainModule.FileName;
}
- AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, Collection references, ReaderParameters parameters)
+ AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, ReaderParameters parameters)
{
- var fileName = name.Name + ".dll";
- foreach (var reference in references) {
- if (Path.GetFileName (reference) != fileName)
- continue;
- try {
- return GetAssembly (reference, parameters);
- } catch (BadImageFormatException) {
- continue;
+ foreach (var reference in _references) {
+ foreach (var extension in DirectoryAssemblyResolver.Extensions) {
+ var fileName = name.Name + extension;
+ if (Path.GetFileName (reference) != fileName)
+ continue;
+ try {
+ return GetAssembly (reference, parameters);
+ } catch (BadImageFormatException) {
+ continue;
+ }
}
}
@@ -107,7 +108,7 @@ public override AssemblyDefinition Resolve (AssemblyNameReference name, ReaderPa
if (!_assemblies.TryGetValue (name.Name, out AssemblyDefinition asm) && (_unresolvedAssemblies == null || !_unresolvedAssemblies.Contains (name.Name))) {
try {
// Any full path explicit reference takes precedence over other look up logic
- asm = ResolveFromReferences (name, _references, parameters);
+ asm = ResolveFromReferences (name, parameters);
// Fall back to the base class resolution logic
if (asm == null)
@@ -139,6 +140,11 @@ public void AddReferenceAssembly (string referencePath)
_references.Add (referencePath);
}
+ public List GetReferencePaths ()
+ {
+ return _references;
+ }
+
protected override void Dispose (bool disposing)
{
foreach (var asm in _assemblies.Values) {
diff --git a/src/linker/Linker/DirectoryAssemblyResolver.cs b/src/linker/Linker/DirectoryAssemblyResolver.cs
index dc89390d45a8..7d17bf12fb54 100644
--- a/src/linker/Linker/DirectoryAssemblyResolver.cs
+++ b/src/linker/Linker/DirectoryAssemblyResolver.cs
@@ -83,11 +83,12 @@ public virtual AssemblyDefinition Resolve (AssemblyNameReference name, ReaderPar
throw new AssemblyResolutionException (name, new FileNotFoundException ($"Unable to find '{name.Name}.dll' or '{name.Name}.exe' file"));
}
+ public static string[] Extensions = new[] { ".dll", ".exe" };
+
AssemblyDefinition SearchDirectory (AssemblyNameReference name, IEnumerable directories, ReaderParameters parameters)
{
- var extensions = new[] { ".dll", ".exe" };
foreach (var directory in directories) {
- foreach (var extension in extensions) {
+ foreach (var extension in Extensions) {
string file = Path.Combine (directory, name.Name + extension);
if (!File.Exists (file))
continue;
diff --git a/src/linker/Linker/Driver.cs b/src/linker/Linker/Driver.cs
index afeedc5e6431..59c73b8a6321 100644
--- a/src/linker/Linker/Driver.cs
+++ b/src/linker/Linker/Driver.cs
@@ -261,6 +261,39 @@ protected int SetupContext (ILogger customLogger = null)
continue;
+ case "--action": {
+ AssemblyAction? action = null;
+ if (!GetStringParam (token, l => action = ParseAssemblyAction (l)))
+ return -1;
+
+ if (action == null)
+ return -1;
+
+ string assemblyName = GetNextStringValue ();
+ if (assemblyName == null) {
+ context.DefaultAction = action.Value;
+ continue;
+ }
+
+ if (!IsValidAssemblyName (assemblyName)) {
+ context.LogError ($"Invalid assembly name '{assemblyName}'", 1036);
+ return -1;
+ }
+
+ context.RegisterAssemblyAction (assemblyName, action.Value);
+ continue;
+ }
+ case "--trim-mode": {
+ AssemblyAction? action = null;
+ if (!GetStringParam (token, l => action = ParseAssemblyAction (l)))
+ return -1;
+
+ if (action == null)
+ return -1;
+
+ context.TrimAction = action.Value;
+ continue;
+ }
case "--custom-step":
if (!GetStringParam (token, l => custom_steps.Push (l)))
return -1;
@@ -493,47 +526,6 @@ protected int SetupContext (ILogger customLogger = null)
return -1;
continue;
- case "c": {
- AssemblyAction? action = null;
- if (!GetStringParam (token, l => action = ParseAssemblyAction (l)))
- return -1;
-
- if (action == null)
- return -1;
-
- context.CoreAction = action.Value;
- continue;
- }
- case "u": {
- AssemblyAction? action = null;
- if (!GetStringParam (token, l => action = ParseAssemblyAction (l)))
- return -1;
-
- if (action == null)
- return -1;
-
- context.UserAction = action.Value;
- continue;
- }
- case "p": {
- if (arguments.Count < 2) {
- ErrorMissingArgument (token);
- return -1;
- }
-
- var action = ParseAssemblyAction (arguments.Dequeue ());
- if (action == null)
- return -1;
-
- string assemblyName = arguments.Dequeue ();
- if (!IsValidAssemblyName (assemblyName)) {
- context.LogError ($"Invalid assembly name '{assemblyName}'", 1036);
- return -1;
- }
-
- context.RegisterAssemblyAction (assemblyName, action.Value);
- continue;
- }
case "t":
context.KeepTypeForwarderOnlyAssemblies = true;
continue;
@@ -1045,8 +1037,8 @@ string GetNextStringValue ()
protected virtual LinkContext GetDefaultContext (Pipeline pipeline, ILogger logger)
{
return new LinkContext (pipeline, logger ?? new ConsoleLogger ()) {
- CoreAction = AssemblyAction.Link,
- UserAction = AssemblyAction.Link,
+ TrimAction = AssemblyAction.Link,
+ DefaultAction = AssemblyAction.Link,
OutputDirectory = "output",
};
}
@@ -1086,15 +1078,15 @@ static void Usage ()
Console.WriteLine ();
Console.WriteLine ("Actions");
- Console.WriteLine (" -c ACTION Sets action for all framework assemblies. Defaults to 'link'");
- Console.WriteLine (" copy: Analyze whole assembly and save it to the output");
- Console.WriteLine (" copyused: Same as copy but only for assemblies which are needed");
- Console.WriteLine (" link: Remove any unused IL or metadata and optimizes the assembly");
- Console.WriteLine (" skip: Do not process the assembly");
- Console.WriteLine (" addbypassngen: Add BypassNGenAttribute to unused methods");
- Console.WriteLine (" addbypassngenused: Same as addbypassngen but unused assemblies are removed");
- Console.WriteLine (" -u ACTION Sets action for any user assembly. Defaults to 'link'");
- Console.WriteLine (" -p ACTION ASM Overrides the default action for specific assembly name");
+ Console.WriteLine (" --trim-mode ACTION Sets action for assemblies annotated with IsTrimmable attribute. Defaults to 'link'");
+ Console.WriteLine (" copy: Analyze whole assembly and save it to the output");
+ Console.WriteLine (" copyused: Same as copy but only for assemblies which are needed");
+ Console.WriteLine (" link: Remove any unused IL or metadata and optimizes the assembly");
+ Console.WriteLine (" skip: Do not process the assembly");
+ Console.WriteLine (" addbypassngen: Add BypassNGenAttribute to unused methods");
+ Console.WriteLine (" addbypassngenused: Same as addbypassngen but unused assemblies are removed");
+ Console.WriteLine (" --action ACTION Sets action for assemblies that have no IsTrimmable attribute. Defaults to 'link'");
+ Console.WriteLine (" --action ACTION ASM Overrides the default action for specific assembly name");
Console.WriteLine ();
Console.WriteLine ("Advanced Options");
@@ -1168,6 +1160,7 @@ static void About ()
static Pipeline GetStandardPipeline ()
{
Pipeline p = new Pipeline ();
+ p.AppendStep (new ProcessReferencesStep ());
p.AppendStep (new MarkStep ());
p.AppendStep (new RemoveResourcesStep ());
p.AppendStep (new ValidateVirtualMethodAnnotationsStep ());
diff --git a/src/linker/Linker/LinkContext.cs b/src/linker/Linker/LinkContext.cs
index 52931311b88b..9647aa7ea2a8 100644
--- a/src/linker/Linker/LinkContext.cs
+++ b/src/linker/Linker/LinkContext.cs
@@ -30,6 +30,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
+using System.Reflection;
using Mono.Cecil;
using Mono.Cecil.Cil;
@@ -54,8 +55,6 @@ public class LinkContext : IDisposable
{
readonly Pipeline _pipeline;
- AssemblyAction _coreAction;
- AssemblyAction _userAction;
readonly Dictionary _actions;
string _outputDirectory;
readonly Dictionary _parameters;
@@ -97,15 +96,9 @@ public string OutputDirectory {
set { _outputDirectory = value; }
}
- public AssemblyAction CoreAction {
- get { return _coreAction; }
- set { _coreAction = value; }
- }
+ public AssemblyAction TrimAction { get; set; }
- public AssemblyAction UserAction {
- get { return _userAction; }
- set { _userAction = value; }
- }
+ public AssemblyAction DefaultAction { get; set; }
public bool LinkSymbols {
get { return _linkSymbols; }
@@ -313,7 +306,7 @@ public void RegisterAssembly (AssemblyDefinition assembly)
{
if (SeenFirstTime (assembly)) {
SafeReadSymbols (assembly);
- Annotations.SetAction (assembly, CalculateAssemblyAction (assembly.Name));
+ Annotations.SetAction (assembly, CalculateAssemblyAction (assembly));
}
}
@@ -394,37 +387,45 @@ public void SetAction (AssemblyDefinition assembly, AssemblyAction defaultAction
Annotations.SetAction (assembly, action);
}
#endif
- public AssemblyAction CalculateAssemblyAction (AssemblyNameDefinition name)
+ public AssemblyAction CalculateAssemblyAction (AssemblyDefinition assembly)
{
- if (_actions.TryGetValue (name.Name, out AssemblyAction action))
+ if (_actions.TryGetValue (assembly.Name.Name, out AssemblyAction action))
return action;
- if (IsCore (name))
- return CoreAction;
+ if (IsTrimmable (assembly))
+ return TrimAction;
- return UserAction;
+ return DefaultAction;
}
- public static bool IsCore (AssemblyNameReference name)
+ bool IsTrimmable (AssemblyDefinition assembly)
{
- switch (name.Name) {
- case "mscorlib":
- case "Accessibility":
- case "Mono.Security":
- // WPF
- case "PresentationFramework":
- case "PresentationCore":
- case "WindowsBase":
- case "UIAutomationProvider":
- case "UIAutomationTypes":
- case "PresentationUI":
- case "ReachFramework":
- case "netstandard":
- return true;
- default:
- return name.Name.StartsWith ("System")
- || name.Name.StartsWith ("Microsoft");
+ if (!assembly.HasCustomAttributes)
+ return false;
+
+ bool isTrimmable = false;
+
+ foreach (var ca in assembly.CustomAttributes) {
+ if (!ca.AttributeType.IsTypeOf ())
+ continue;
+
+ var args = ca.ConstructorArguments;
+ if (args.Count != 2)
+ continue;
+
+ if (args[0].Value is not string key || !key.Equals ("IsTrimmable", StringComparison.OrdinalIgnoreCase))
+ continue;
+
+ if (args[1].Value is not string value || !value.Equals ("True", StringComparison.OrdinalIgnoreCase)) {
+ var assemblyFileName = Resolver.GetAssemblyFileName (assembly);
+ LogWarning ($"Invalid AssemblyMetadata(\"IsTrimmable\", \"{args[1].Value}\") attribute in assembly '{assembly.Name.Name}'. Value must be \"True\"", 2102, assemblyFileName);
+ continue;
+ }
+
+ isTrimmable = true;
}
+
+ return isTrimmable;
}
public virtual AssemblyDefinition[] GetAssemblies ()
diff --git a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs
index 46f29b177b64..27c99560d3b9 100644
--- a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs
+++ b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs
@@ -76,9 +76,7 @@ public void TestAssemblyPaths (ITaskItem[] assemblyPaths)
continue;
AssemblyAction expectedAction = (AssemblyAction) Enum.Parse (typeof (AssemblyAction), trimMode, ignoreCase: true);
-
- var ad = new Mono.Cecil.AssemblyNameDefinition (Path.GetFileNameWithoutExtension (assemblyPath), new Version ());
- AssemblyAction actualAction = context.CalculateAssemblyAction (ad);
+ AssemblyAction actualAction = (AssemblyAction) context.Actions[Path.GetFileNameWithoutExtension (assemblyPath)];
Assert.Equal (expectedAction, actualAction);
}
@@ -113,8 +111,8 @@ public void TestReferenceAssemblyPaths (string[] referenceAssemblyPaths)
var actualReferences = driver.GetReferenceAssemblies ();
Assert.Equal (expectedReferences.OrderBy (a => a), actualReferences.OrderBy (a => a));
foreach (var reference in expectedReferences) {
- var ad = new Mono.Cecil.AssemblyNameDefinition (Path.GetFileNameWithoutExtension (reference), new Version ());
- AssemblyAction actualAction = driver.Context.CalculateAssemblyAction (ad);
+ var referenceName = Path.GetFileNameWithoutExtension (reference);
+ var actualAction = driver.Context.Actions[referenceName];
Assert.Equal (AssemblyAction.Skip, actualAction);
}
}
@@ -441,12 +439,12 @@ public void TestExtraArgs ()
{
var task = new MockTask () {
TrimMode = "copy",
- ExtraArgs = "-c link"
+ ExtraArgs = "--trim-mode copyused"
};
using (var driver = task.CreateDriver ()) {
- Assert.Equal (AssemblyAction.Copy, driver.Context.UserAction);
+ Assert.Equal (AssemblyAction.Link, driver.Context.DefaultAction);
// Check that ExtraArgs can override TrimMode
- Assert.Equal (AssemblyAction.Link, driver.Context.CoreAction);
+ Assert.Equal (AssemblyAction.CopyUsed, driver.Context.TrimAction);
}
}
@@ -496,8 +494,24 @@ public void TestGlobalTrimMode (string trimMode)
};
using (var driver = task.CreateDriver ()) {
var expectedAction = (AssemblyAction) Enum.Parse (typeof (AssemblyAction), trimMode, ignoreCase: true);
- Assert.Equal (expectedAction, driver.Context.CoreAction);
- Assert.Equal (expectedAction, driver.Context.UserAction);
+ Assert.Equal (expectedAction, driver.Context.TrimAction);
+ Assert.Equal (AssemblyAction.Link, driver.Context.DefaultAction);
+ }
+ }
+
+ [Theory]
+ [InlineData ("copy")]
+ [InlineData ("link")]
+ [InlineData ("copyused")]
+ public void TestDefaultAction (string defaultAction)
+ {
+ var task = new MockTask () {
+ DefaultAction = defaultAction
+ };
+ using (var driver = task.CreateDriver ()) {
+ var expectedAction = (AssemblyAction) Enum.Parse (typeof (AssemblyAction), defaultAction, ignoreCase: true);
+ Assert.Equal (expectedAction, driver.Context.DefaultAction);
+ Assert.Equal (AssemblyAction.Link, driver.Context.TrimAction);
}
}
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerUserActionAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerDefaultActionAttribute.cs
similarity index 65%
rename from test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerUserActionAttribute.cs
rename to test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerDefaultActionAttribute.cs
index b20fd9583ca6..15fb6437acf1 100644
--- a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerUserActionAttribute.cs
+++ b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerDefaultActionAttribute.cs
@@ -3,9 +3,9 @@
namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
[AttributeUsage (AttributeTargets.Class, AllowMultiple = false)]
- public class SetupLinkerUserActionAttribute : BaseMetadataAttribute
+ public class SetupLinkerDefaultActionAttribute : BaseMetadataAttribute
{
- public SetupLinkerUserActionAttribute (string action)
+ public SetupLinkerDefaultActionAttribute (string action)
{
if (string.IsNullOrEmpty (action))
throw new ArgumentNullException (nameof (action));
diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimModeAttribute.cs
similarity index 66%
rename from test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs
rename to test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimModeAttribute.cs
index 077dad672374..0d808ac0d27b 100644
--- a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs
+++ b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimModeAttribute.cs
@@ -3,9 +3,9 @@
namespace Mono.Linker.Tests.Cases.Expectations.Metadata
{
[AttributeUsage (AttributeTargets.Class, AllowMultiple = false)]
- public class SetupLinkerCoreActionAttribute : BaseMetadataAttribute
+ public class SetupLinkerTrimModeAttribute : BaseMetadataAttribute
{
- public SetupLinkerCoreActionAttribute (string action)
+ public SetupLinkerTrimModeAttribute (string action)
{
if (string.IsNullOrEmpty (action))
throw new ArgumentNullException (nameof (action));
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs
index 107d1af708dc..6514e8042ef5 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs
@@ -14,7 +14,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.Debugger
#if NETCOREAPP
[SetupLinkAttributesFile ("DebuggerAttributesRemoved.xml")]
#else
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs
index 4de8b8e47317..59b8fb6e90b2 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs
@@ -10,7 +10,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.Debugger
#if NETCOREAPP
[SetupLinkAttributesFile ("DebuggerAttributesRemoved.xml")]
#else
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs
index 5b45a2da2e4d..7c81962e4ce5 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs
@@ -16,7 +16,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.Debugger
#if NETCOREAPP
[SetupLinkAttributesFile ("DebuggerAttributesRemoved.xml")]
#else
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnType.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnType.cs
index 702a6809373e..a78ee540f86a 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnType.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnType.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.Debugger
#if NETCOREAPP
[SetupLinkAttributesFile ("DebuggerAttributesRemoved.xml")]
#else
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeThatIsNotUsed.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeThatIsNotUsed.cs
index ea626e624001..8df304176c40 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeThatIsNotUsed.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeThatIsNotUsed.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.Debugger
#if NETCOREAPP
[SetupLinkAttributesFile ("DebuggerAttributesRemoved.xml")]
#else
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeWithNonExistentMethod.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeWithNonExistentMethod.cs
index d50a5af09bdd..39d6d77b0fa2 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeWithNonExistentMethod.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerDisplayAttributeOnTypeWithNonExistentMethod.cs
@@ -7,7 +7,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger
{
#if !NETCOREAPP
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs
index 80f7ecd1548a..1a0c432b39fb 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs
@@ -14,7 +14,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.Debugger
#if NETCOREAPP
[SetupLinkAttributesFile ("DebuggerAttributesRemoved.xml")]
#else
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnType.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnType.cs
index 8c213b41b6b6..b22708128326 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnType.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/DebuggerTypeProxyAttributeOnType.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.Debugger
#if NETCOREAPP
[SetupLinkAttributesFile ("DebuggerAttributesRemoved.xml")]
#else
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerKeepDebugMembers ("false")]
// Can be removed once this bug is fixed https://bugzilla.xamarin.com/show_bug.cgi?id=58168
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs
index 2b80e361e7c5..f97a2fd91393 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTarget.cs
@@ -8,7 +8,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs
index 637464b673cb..562baf2b075f 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetOnUnusedType.cs
@@ -7,7 +7,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs
index d6bde5810e92..b816282b40a9 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInOtherAssembly.cs
@@ -9,7 +9,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInSameAssembly.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInSameAssembly.cs
index 580d8f806dd3..33d2dcadfe7c 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInSameAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameInSameAssembly.cs
@@ -7,7 +7,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfGenericTypeInOtherAssembly.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfGenericTypeInOtherAssembly.cs
index 3414a76701fd..671133011236 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfGenericTypeInOtherAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfGenericTypeInOtherAssembly.cs
@@ -8,7 +8,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfNestedTypeInOtherAssembly.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfNestedTypeInOtherAssembly.cs
index 6b29cc01e33d..3090ad3ed2d9 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfNestedTypeInOtherAssembly.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnAssemblyUsingTargetTypeNameOfNestedTypeInOtherAssembly.cs
@@ -8,7 +8,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnType.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnType.cs
index 86edd446f54f..69122f4b740c 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnType.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerDisplayAttributeOnType.cs
@@ -4,7 +4,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs
index 77de6dfe34f5..e2754835dce7 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnAssemblyUsingTarget.cs
@@ -8,7 +8,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnType.cs b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnType.cs
index 1f7778d24963..fa9deabfef95 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnType.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes.Debugger/KeepDebugMembers/DebuggerTypeProxyAttributeOnType.cs
@@ -4,7 +4,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.Debugger.KeepDebugMembers
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
#if !NETCOREAPP
[SetupLinkerKeepDebugMembers ("true")]
#endif
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/CoreLibraryAssemblyAttributesAreKept.cs b/test/Mono.Linker.Tests.Cases/Attributes/CoreLibraryAssemblyAttributesAreKept.cs
index 5b69f5457a0a..43ba8accd26e 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes/CoreLibraryAssemblyAttributesAreKept.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes/CoreLibraryAssemblyAttributesAreKept.cs
@@ -6,7 +6,7 @@
namespace Mono.Linker.Tests.Cases.Attributes
{
[Reference ("System.dll")]
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
// System.dll referenced by a dynamically (for example in TypeConverterAttribute on IComponent)
// has unresolved references.
[SetupLinkerArgument ("--skip-unresolved", "true")]
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs b/test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs
index ee278e46bfc8..702f650af978 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes/MarshalAsCustomMarshalerInterface.cs
@@ -6,7 +6,7 @@
namespace Mono.Linker.Tests.Cases.Attributes
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SkipPeVerify]
[KeptInterface (typeof (IUserData))]
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/NoSecurity/CoreLibrarySecurityAttributeTypesAreRemoved.cs b/test/Mono.Linker.Tests.Cases/Attributes/NoSecurity/CoreLibrarySecurityAttributeTypesAreRemoved.cs
index 83f9f2d4229b..cfd9394f812b 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes/NoSecurity/CoreLibrarySecurityAttributeTypesAreRemoved.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes/NoSecurity/CoreLibrarySecurityAttributeTypesAreRemoved.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.NoSecurity
#if NETCOREAPP
[IgnoreTestCase ("Not important for .NET Core build")]
#endif
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerArgument ("--strip-security", "true")]
[Reference ("System.dll")]
// Attributes from System.Security.Permissions
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CanLinkCoreLibrariesWithOnlyKeepUsedAttributes.cs b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CanLinkCoreLibrariesWithOnlyKeepUsedAttributes.cs
index ea9e29f63efb..97565b5d10dc 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CanLinkCoreLibrariesWithOnlyKeepUsedAttributes.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CanLinkCoreLibrariesWithOnlyKeepUsedAttributes.cs
@@ -5,7 +5,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerArgument ("--used-attrs-only", "true")]
[Reference ("System.dll")]
// System.Core.dll is referenced by System.dll in the .NET FW class libraries. Our GetType reflection marking code
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUnusedAssemblyAttributesAreRemoved.cs b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUnusedAssemblyAttributesAreRemoved.cs
index cba8cdb7a13e..b559261c7f99 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUnusedAssemblyAttributesAreRemoved.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUnusedAssemblyAttributesAreRemoved.cs
@@ -6,7 +6,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed
{
[Reference ("System.dll")]
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerArgument ("--used-attrs-only", "true")]
[RemovedAttributeInAssembly (PlatformAssemblies.CoreLib, typeof (AssemblyDescriptionAttribute))]
#if !NETCOREAPP
diff --git a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUsedAssemblyAttributesAreKept.cs b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUsedAssemblyAttributesAreKept.cs
index 496450768181..6c5bea8621c5 100644
--- a/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUsedAssemblyAttributesAreKept.cs
+++ b/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/CoreLibraryUsedAssemblyAttributesAreKept.cs
@@ -6,7 +6,7 @@
namespace Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed
{
[Reference ("System.dll")]
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerArgument ("--used-attrs-only", "true")]
[KeptAttributeInAssembly (PlatformAssemblies.CoreLib, typeof (AssemblyDescriptionAttribute))]
#if !NETCOREAPP
diff --git a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs
index 0502d7d1362c..8bb85bda818b 100644
--- a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs
+++ b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs
@@ -10,7 +10,7 @@ namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW
#endif
[SetupLinkerArgument ("--exclude-feature", "etw")]
// Keep framework code that calls EventSource methods like OnEventCommand
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
public class BaseRemovedEventSource
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs
index 2a24b2f5ebef..cb6e83ed45c5 100644
--- a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs
+++ b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW
#endif
[SetupLinkerArgument ("--exclude-feature", "etw")]
// Keep framework code that calls EventSource methods like OnEventCommand
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
public class BaseRemovedEventSourceEmptyBody
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs
index 3356b067599f..6adb3e217882 100644
--- a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs
+++ b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW
#endif
[SetupLinkerArgument ("--exclude-feature", "etw")]
// Keep framework code that calls EventSource methods like OnEventCommand
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
public class BaseRemovedEventSourceNonVoidReturn
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs
index fd7d470c6e31..7256d806612b 100644
--- a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs
+++ b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs
@@ -10,7 +10,7 @@ namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW
#endif
[SetupLinkerArgument ("--exclude-feature", "etw")]
// Keep framework code that calls EventSource methods like OnEventCommand
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
// Used to avoid different compilers generating different IL which can mess up the instruction asserts
[SetupCompileArgument ("/optimize+")]
public class Excluded
diff --git a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs
index 7ba06e22a1e0..ed61c571eeb5 100644
--- a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs
+++ b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW
#endif
[SetupLinkerArgument ("--exclude-feature", "etw")]
// Keep framework code that calls EventSource methods like OnEventCommand
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
// Used to avoid different compilers generating different IL which can mess up the instruction asserts
[SetupCompileArgument ("/optimize+")]
public class LocalsOfModifiedMethodAreRemoved
diff --git a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs
index 7ec871e98805..0a988d98631c 100644
--- a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs
+++ b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs
@@ -10,7 +10,7 @@ namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW
#endif
[SetupLinkerArgument ("--exclude-feature", "etw")]
// Keep framework code that calls EventSource methods like OnEventCommand
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
// Used to avoid different compilers generating different IL which can mess up the instruction asserts
[SetupCompileArgument ("/optimize+")]
public class StubbedMethodWithExceptionHandlers
diff --git a/test/Mono.Linker.Tests.Cases/ComponentModel/TypeConverterOnMembers.cs b/test/Mono.Linker.Tests.Cases/ComponentModel/TypeConverterOnMembers.cs
index 81f50788b9b5..850a2f7f95dc 100644
--- a/test/Mono.Linker.Tests.Cases/ComponentModel/TypeConverterOnMembers.cs
+++ b/test/Mono.Linker.Tests.Cases/ComponentModel/TypeConverterOnMembers.cs
@@ -7,7 +7,7 @@
namespace Mono.Linker.Tests.Cases.ComponentModel
{
// Keep framework code that calls TypeConverter methods like ConvertFrom
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
[Reference ("System.dll")]
public class TypeConverterOnMembers
{
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/CanIncludeI18nAssemblies.cs b/test/Mono.Linker.Tests.Cases/CoreLink/CanIncludeI18nAssemblies.cs
index dc616779b94c..1bacd88495cd 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/CanIncludeI18nAssemblies.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/CanIncludeI18nAssemblies.cs
@@ -6,7 +6,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink
#if NETCOREAPP
[IgnoreTestCase ("Not important for .NET Core build")]
#endif
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[Il8n ("all")]
// i18n assemblies should only be included when processing mono class libs. By forcing this test to use mcs,
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/CanOverrideIsTrimmableAttribute.cs b/test/Mono.Linker.Tests.Cases/CoreLink/CanOverrideIsTrimmableAttribute.cs
new file mode 100644
index 000000000000..bdd23ed82486
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/CanOverrideIsTrimmableAttribute.cs
@@ -0,0 +1,36 @@
+using Mono.Linker.Tests.Cases.CoreLink.Dependencies;
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Metadata;
+
+namespace Mono.Linker.Tests.Cases.CoreLink
+{
+ [SetupLinkerDefaultActionAttribute ("copy")]
+ [SetupLinkerAction ("link", "test")]
+ [SetupLinkerAction ("copy", "trimmable")]
+ [SetupLinkerAction ("link", "nontrimmable")]
+
+ [SetupCompileBefore ("trimmable.dll", new[] { "Dependencies/TrimmableAssembly.cs" })]
+ [SetupCompileBefore ("nontrimmable.dll", new[] { "Dependencies/NonTrimmableAssembly.cs" })]
+
+ [KeptAllTypesAndMembersInAssembly ("trimmable.dll")]
+ [KeptMemberInAssembly ("nontrimmable.dll", typeof (NonTrimmableAssembly), "Used()")]
+ [RemovedMemberInAssembly ("nontrimmable.dll", typeof (NonTrimmableAssembly), "Unused()")]
+ public class CanOverrideIsTrimmableAttribute
+ {
+ public static void Main ()
+ {
+ Used ();
+ TrimmableAssembly.Used ();
+ NonTrimmableAssembly.Used ();
+ }
+
+ [Kept]
+ public static void Used ()
+ {
+ }
+
+ public static void Unused ()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs b/test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs
new file mode 100644
index 000000000000..eb1f8e16c800
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs
@@ -0,0 +1,34 @@
+using Mono.Linker.Tests.Cases.CoreLink.Dependencies;
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Metadata;
+
+namespace Mono.Linker.Tests.Cases.CoreLink
+{
+ [SetupLinkerDefaultActionAttribute ("copy")]
+ [SetupCompileBefore ("trimmable.dll", new[] { "Dependencies/TrimmableAssembly.cs" })]
+ [SetupCompileBefore ("nontrimmable.dll", new[] { "Dependencies/NonTrimmableAssembly.cs" })]
+
+ [KeptMemberInAssembly ("trimmable.dll", typeof (TrimmableAssembly), "Used()")]
+ [RemovedMemberInAssembly ("trimmable.dll", typeof (TrimmableAssembly), "Unused()")]
+ [KeptAllTypesAndMembersInAssembly ("nontrimmable.dll")]
+ [KeptMember (".ctor()")]
+ public class CanUseIsTrimmableAttribute
+ {
+ public static void Main ()
+ {
+ Used ();
+ TrimmableAssembly.Used ();
+ NonTrimmableAssembly.Used ();
+ }
+
+ [Kept]
+ public static void Used ()
+ {
+ }
+
+ [Kept]
+ public static void Unused ()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs b/test/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs
index ba3ad068bfa5..e4a51dca617e 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs
@@ -4,7 +4,7 @@
namespace Mono.Linker.Tests.Cases.CoreLink
{
- [SetupLinkerCoreAction ("copy")]
+ [SetupLinkerTrimMode ("copy")]
// System.dll referenced by a dynamically (for example in TypeConverterAttribute on IComponent)
// has unresolved references.
[SetupLinkerArgument ("--skip-unresolved")]
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/DelegateAndMulticastDelegateKeepInstantiatedReqs.cs b/test/Mono.Linker.Tests.Cases/CoreLink/DelegateAndMulticastDelegateKeepInstantiatedReqs.cs
index 5104f544fff8..abe71f11bcc7 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/DelegateAndMulticastDelegateKeepInstantiatedReqs.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/DelegateAndMulticastDelegateKeepInstantiatedReqs.cs
@@ -12,7 +12,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink
///
/// Delegate and is created from
///
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[KeptBaseOnTypeInAssembly (PlatformAssemblies.CoreLib, typeof (MulticastDelegate), PlatformAssemblies.CoreLib, typeof (Delegate))]
// Check a couple override methods to verify they were not removed
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs
new file mode 100644
index 000000000000..125bb712c972
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs
@@ -0,0 +1,18 @@
+using System.Reflection;
+
+[assembly: AssemblyMetadata ("IsTrimmable", "true")]
+[assembly: AssemblyMetadata ("IsTrimmable", "False")]
+
+namespace Mono.Linker.Tests.Cases.CoreLink.Dependencies
+{
+ public static class InvalidIsTrimmableAssembly
+ {
+ public static void Used ()
+ {
+ }
+
+ public static void Unused ()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/NonTrimmableAssembly.cs b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/NonTrimmableAssembly.cs
new file mode 100644
index 000000000000..50bcc9ab5c77
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/NonTrimmableAssembly.cs
@@ -0,0 +1,14 @@
+
+namespace Mono.Linker.Tests.Cases.CoreLink.Dependencies
+{
+ public static class NonTrimmableAssembly
+ {
+ public static void Used ()
+ {
+ }
+
+ public static void Unused ()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/TrimmableAssembly.cs b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/TrimmableAssembly.cs
new file mode 100644
index 000000000000..fdf1cc77e2c8
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/TrimmableAssembly.cs
@@ -0,0 +1,17 @@
+using System.Reflection;
+
+[assembly: AssemblyMetadata ("IsTrimmable", "True")]
+
+namespace Mono.Linker.Tests.Cases.CoreLink.Dependencies
+{
+ public static class TrimmableAssembly
+ {
+ public static void Used ()
+ {
+ }
+
+ public static void Unused ()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedStructWithOverridesFromObject.cs b/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedStructWithOverridesFromObject.cs
index d8255fe44477..43834594527d 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedStructWithOverridesFromObject.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedStructWithOverridesFromObject.cs
@@ -3,7 +3,7 @@
namespace Mono.Linker.Tests.Cases.CoreLink
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
// Need to skip due to `Runtime critical type System.Reflection.CustomAttributeData not found` failure
[SkipPeVerify (SkipPeVerifyForToolchian.Pedump)]
public class InstantiatedStructWithOverridesFromObject
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedTypeWithOverridesFromObject.cs b/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedTypeWithOverridesFromObject.cs
index bb20020a0d34..a810ab9a6db9 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedTypeWithOverridesFromObject.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedTypeWithOverridesFromObject.cs
@@ -3,7 +3,7 @@
namespace Mono.Linker.Tests.Cases.CoreLink
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
// Need to skip due to `Runtime critical type System.Reflection.CustomAttributeData not found` failure
[SkipPeVerify (SkipPeVerifyForToolchian.Pedump)]
public class InstantiatedTypeWithOverridesFromObject
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs b/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs
new file mode 100644
index 000000000000..35463fd52d44
--- /dev/null
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs
@@ -0,0 +1,32 @@
+using Mono.Linker.Tests.Cases.CoreLink.Dependencies;
+using Mono.Linker.Tests.Cases.Expectations.Assertions;
+using Mono.Linker.Tests.Cases.Expectations.Metadata;
+
+namespace Mono.Linker.Tests.Cases.CoreLink
+{
+ [SetupLinkerDefaultActionAttribute ("copy")]
+ [SetupCompileBefore ("trimmable.dll", new[] { "Dependencies/InvalidIsTrimmableAssembly.cs" })]
+
+ [KeptMemberInAssembly ("trimmable.dll", typeof (InvalidIsTrimmableAssembly), "Used()")]
+ [RemovedMemberInAssembly ("trimmable.dll", typeof (InvalidIsTrimmableAssembly), "Unused()")]
+ [ExpectedWarning ("IL2102", "Invalid AssemblyMetadata(\"IsTrimmable\", \"False\") attribute in assembly 'trimmable'. Value must be \"True\"", FileName = "trimmable.dll")]
+ [KeptMember (".ctor()")]
+ public class InvalidIsTrimmableAttribute
+ {
+ public static void Main ()
+ {
+ Used ();
+ InvalidIsTrimmableAssembly.Used ();
+ }
+
+ [Kept]
+ public static void Used ()
+ {
+ }
+
+ [Kept]
+ public static void Unused ()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs b/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs
index a4d715aac4e7..a401b7ca2c47 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink
#if NETCOREAPP
[IgnoreTestCase("Not important for .NET Core build")]
#endif
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[KeptAssembly (PlatformAssemblies.CoreLib)]
[KeptMemberInAssembly (PlatformAssemblies.CoreLib, typeof (Stack), ".ctor(System.Int32)", "Pop()", "Push(System.Object)")]
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs b/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs
index 936f0f3a4bbb..55249656de9a 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedTypes.cs
@@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink
#if NETCOREAPP
[IgnoreTestCase("Not important for .NET Core build")]
#endif
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[Reference ("System.dll")]
[KeptAssembly (PlatformAssemblies.CoreLib)]
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/NeverInstantiatedTypeWithOverridesFromObject.cs b/test/Mono.Linker.Tests.Cases/CoreLink/NeverInstantiatedTypeWithOverridesFromObject.cs
index 8d1b596e497f..3fbe05cd47ad 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/NeverInstantiatedTypeWithOverridesFromObject.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/NeverInstantiatedTypeWithOverridesFromObject.cs
@@ -3,7 +3,7 @@
namespace Mono.Linker.Tests.Cases.CoreLink
{
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
// Need to skip due to `Runtime critical type System.Reflection.CustomAttributeData not found` failure
[SkipPeVerify (SkipPeVerifyForToolchian.Pedump)]
public class NeverInstantiatedTypeWithOverridesFromObject
diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/NoSecurityPlusOnlyKeepUsedRemovesAllSecurityAttributesFromCoreLibraries.cs b/test/Mono.Linker.Tests.Cases/CoreLink/NoSecurityPlusOnlyKeepUsedRemovesAllSecurityAttributesFromCoreLibraries.cs
index b7ccf073f7d4..9d036cd5170d 100644
--- a/test/Mono.Linker.Tests.Cases/CoreLink/NoSecurityPlusOnlyKeepUsedRemovesAllSecurityAttributesFromCoreLibraries.cs
+++ b/test/Mono.Linker.Tests.Cases/CoreLink/NoSecurityPlusOnlyKeepUsedRemovesAllSecurityAttributesFromCoreLibraries.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink
#if NETCOREAPP
[IgnoreTestCase("Not important for .NET Core build")]
#endif
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("link")]
[SetupLinkerArgument ("--strip-security", "true")]
[SetupLinkerArgument ("--used-attrs-only", "true")]
[Reference ("System.dll")]
diff --git a/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs b/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs
index 728356294059..32271e6c47dc 100644
--- a/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs
+++ b/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs
@@ -5,7 +5,7 @@
namespace Mono.Linker.Tests.Cases.DynamicDependencies
{
- [SetupLinkerUserAction ("copyused")]
+ [SetupLinkerDefaultAction ("copyused")]
[SetupCompileBefore ("library.dll", new[] { "Dependencies/DynamicDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction_Lib.cs" }, addAsReference: false)]
[RemovedAssembly ("library.dll")]
public class DynamicDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction
diff --git a/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Individual/CanOutputPInvokes.cs b/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Individual/CanOutputPInvokes.cs
index e42acbb9b489..2baf18a9a510 100644
--- a/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Individual/CanOutputPInvokes.cs
+++ b/test/Mono.Linker.Tests.Cases/Interop/PInvoke/Individual/CanOutputPInvokes.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Interop.PInvoke.Individual
[SetupLinkerAction ("copy", "copyassembly")]
[SetupLinkerAction ("link", "linkassembly")]
// Prevent dumping of pinvokes from core assemblies
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
[SetupCompileBefore ("copyassembly.dll", new[] { typeof (CanOutputPInvokes_CopyAssembly) })]
[SetupCompileBefore ("linkassembly.dll", new[] { typeof (CanOutputPInvokes_LinkAssembly) })]
[SetupLinkerArgument ("--output-pinvokes", new[] { "pinvokes.json" })]
diff --git a/test/Mono.Linker.Tests.Cases/Libraries/UserAssemblyActionWorks.cs b/test/Mono.Linker.Tests.Cases/Libraries/UserAssemblyActionWorks.cs
index 34fad721e3b3..ee367654a719 100644
--- a/test/Mono.Linker.Tests.Cases/Libraries/UserAssemblyActionWorks.cs
+++ b/test/Mono.Linker.Tests.Cases/Libraries/UserAssemblyActionWorks.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Libraries
///
/// We have to check another assembly because the test exe is included with -a and that will cause it to be linked
///
- [SetupLinkerUserAction ("copy")]
+ [SetupLinkerDefaultAction ("copy")]
[SetupCompileBefore ("lib.dll", new[] { "Dependencies/UserAssemblyActionWorks_Lib.cs" })]
[KeptAllTypesAndMembersInAssembly ("lib.dll")]
[SetupLinkerAction ("link", "test")]
diff --git a/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs b/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs
index 6f96d50c09d7..4984c7c46060 100644
--- a/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs
+++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs
@@ -15,19 +15,14 @@ public class MockCorelibAttributeToRemove : Attribute
namespace Mono.Linker.Tests.Cases.LinkAttributes
{
[IgnoreLinkAttributes (false)]
- [SetupLinkerCoreAction ("link")] // Ensure that corelib gets linked so that its attribtues are processed
+ [SetupLinkerTrimMode ("link")] // Ensure that corelib gets linked so that its attribtues are processed
[SetupLinkerArgument ("--skip-unresolved", "true")] // Allow unresolved references to types missing from mock corelib
[SetupCompileBefore (PlatformAssemblies.CoreLib, new string[] { "Dependencies/MockCorelib.cs" },
resources: new object[] { new string[] { "Dependencies/MockCorelib.xml", "ILLink.LinkAttributes.xml" } },
defines: new[] { "INCLUDE_MOCK_CORELIB" })]
[SkipPeVerify]
-#if NETCOREAPP
[RemovedAttributeInAssembly ("System.Private.CoreLib", "System.MockCorelibAttributeToRemove")]
[RemovedTypeInAssembly ("System.Private.CoreLib", "System.MockCorelibAttributeToRemove")]
-#else
- [RemovedAttributeInAssembly ("mscorlib", "System.MockCorelibAttributeToRemove")]
- [RemovedTypeInAssembly ("mscorlib", "System.MockCorelibAttributeToRemove")]
-#endif
class EmbeddedLinkAttributesInCorelib
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests.Cases/PreserveDependencies/PreserveDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs b/test/Mono.Linker.Tests.Cases/PreserveDependencies/PreserveDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs
index 062697d9d4b2..968d94e8ba15 100644
--- a/test/Mono.Linker.Tests.Cases/PreserveDependencies/PreserveDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs
+++ b/test/Mono.Linker.Tests.Cases/PreserveDependencies/PreserveDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction.cs
@@ -4,7 +4,7 @@
namespace Mono.Linker.Tests.Cases.PreserveDependencies
{
- [SetupLinkerUserAction ("copyused")]
+ [SetupLinkerDefaultAction ("copyused")]
[SetupCompileBefore ("FakeSystemAssembly.dll", new[] { "Dependencies/PreserveDependencyAttribute.cs" })]
[SetupCompileBefore ("library.dll", new[] { "Dependencies/PreserveDependencyOnUnusedMethodInNonReferencedAssemblyWithCopyUsedAction_Lib.cs" }, addAsReference: false)]
[RemovedAssembly ("library.dll")]
diff --git a/test/Mono.Linker.Tests.Cases/References/CopyAreKeptFully.cs b/test/Mono.Linker.Tests.Cases/References/CopyAreKeptFully.cs
index 65a91b10b771..bf2d2333b55e 100644
--- a/test/Mono.Linker.Tests.Cases/References/CopyAreKeptFully.cs
+++ b/test/Mono.Linker.Tests.Cases/References/CopyAreKeptFully.cs
@@ -6,7 +6,7 @@
namespace Mono.Linker.Tests.Cases.References
{
[SetupLinkerAction ("link", "test")]
- [SetupLinkerUserAction ("copy")]
+ [SetupLinkerDefaultAction ("copy")]
// Used assembly references are kept
[SetupCompileBefore ("usedlibrary.dll", new[] { "Dependencies/UsedReferencedAssembly.cs" })]
@@ -35,14 +35,14 @@ namespace Mono.Linker.Tests.Cases.References
[KeptAllTypesAndMembersInAssembly ("unuseddynamiclibraryfromdynamiccopy.dll")]
- // Unused dynamic references are not kept (from link assembly)
+ // Unused dynamic references from link assembly are kept (due to copy default action)
[SetupCompileBefore ("unuseddynamiclibrary.dll", new[] { "Dependencies/UnusedDynamicallyReferencedAssembly.cs" })]
- [RemovedAssembly ("unuseddynamiclibrary.dll")]
+ [KeptAllTypesAndMembersInAssembly ("unuseddynamiclibrary.dll")]
- // Unreferenced libraries are not kept
+ // Unreferenced libraries are kept (due to copy default action)
[SetupCompileBefore ("unreferencedlibrary.dll", new[] { "Dependencies/UnreferencedAssembly.cs" })]
- [RemovedAssembly ("unreferencedlibrary.dll")]
+ [KeptAllTypesAndMembersInAssembly ("unreferencedlibrary.dll")]
class CopyAreKeptFully
{
public static void Main ()
diff --git a/test/Mono.Linker.Tests.Cases/References/CopyUsedAreKeptFully.cs b/test/Mono.Linker.Tests.Cases/References/CopyUsedAreKeptFully.cs
index 911cd6cb18ac..ec0ef067bf93 100644
--- a/test/Mono.Linker.Tests.Cases/References/CopyUsedAreKeptFully.cs
+++ b/test/Mono.Linker.Tests.Cases/References/CopyUsedAreKeptFully.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.References
// Actions:
// link - This assembly
// copyused - library1.dll
- [SetupLinkerUserAction ("copyused")]
+ [SetupLinkerDefaultAction ("copyused")]
[SetupLinkerAction ("link", "test")]
[SetupCompileBefore ("library1.dll", new[] { "Dependencies/UserAssembliesAreLinkedByDefault_Library1.cs" })]
diff --git a/test/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs b/test/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs
index 44bd88275c56..c2a8c22ed7a9 100644
--- a/test/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs
+++ b/test/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.References
#if NETCOREAPP
[IgnoreTestCase("Asserts are specific to .NET Framework")]
#endif
- [SetupLinkerCoreAction ("link")]
+ [SetupLinkerTrimMode ("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/test/Mono.Linker.Tests.Cases/TestFramework/VerifyExpectModifiedAttributesWork.cs b/test/Mono.Linker.Tests.Cases/TestFramework/VerifyExpectModifiedAttributesWork.cs
index 8ac41d04065b..99d3a8832175 100644
--- a/test/Mono.Linker.Tests.Cases/TestFramework/VerifyExpectModifiedAttributesWork.cs
+++ b/test/Mono.Linker.Tests.Cases/TestFramework/VerifyExpectModifiedAttributesWork.cs
@@ -14,7 +14,7 @@ namespace Mono.Linker.Tests.Cases.TestFramework
#endif
[SetupLinkerArgument ("--exclude-feature", "etw")]
// Keep framework code that calls EventSource methods like OnEventCommand
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
// Used to avoid different compilers generating different IL which can mess up the instruction asserts
[SetupCompileArgument ("/optimize+")]
public class VerifyExpectModifiedAttributesWork
diff --git a/test/Mono.Linker.Tests.Cases/Tracing/Individual/CanEnableReducedTracing.cs b/test/Mono.Linker.Tests.Cases/Tracing/Individual/CanEnableReducedTracing.cs
index dd0160976314..d774b3f73a2a 100644
--- a/test/Mono.Linker.Tests.Cases/Tracing/Individual/CanEnableReducedTracing.cs
+++ b/test/Mono.Linker.Tests.Cases/Tracing/Individual/CanEnableReducedTracing.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.Tracing.Individual
[SetupLinkerArgument ("--dump-dependencies")]
[SetupLinkerArgument ("--reduced-tracing", "true")]
// Avoid excessive output from core assemblies
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
// Need to define a custom name so that the linker outputs in uncompressed format, which is more useful for making assertions
[SetupLinkerArgument ("--dependencies-file", "linker-dependencies.xml")]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwarded.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwarded.cs
index 171aad0b8b2f..4c119d473aaa 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwarded.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwarded.cs
@@ -11,7 +11,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// Actions:
// link - This assembly, Forwarder.dll and Implementation.dll
- [SetupLinkerUserAction ("link")]
+ [SetupLinkerDefaultAction ("link")]
[KeepTypeForwarderOnlyAssemblies ("false")]
[SetupCompileBefore ("Forwarder.dll", new[] { "Dependencies/ReferenceImplementationLibrary.cs" }, defines: new[] { "INCLUDE_REFERENCE_IMPL" })]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwardedWithCopyAction.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwardedWithCopyAction.cs
index 9855ae444833..d67b53fab310 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwardedWithCopyAction.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributeArgumentForwardedWithCopyAction.cs
@@ -13,7 +13,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// link - Forwarder.dll and Implementation.dll
// copy - this (test.dll) assembly
- [SetupLinkerUserAction ("link")]
+ [SetupLinkerDefaultAction ("link")]
[SetupLinkerAction ("copy", "test")]
[KeepTypeForwarderOnlyAssemblies ("false")]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributesScopeUpdated.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributesScopeUpdated.cs
index 3b6cb38f7ec0..56e06ac6f848 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributesScopeUpdated.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/AttributesScopeUpdated.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// link - Forwarder.dll and Implementation.dll
// copy - this (test.dll) assembly
- [SetupLinkerUserAction ("link")]
+ [SetupLinkerDefaultAction ("link")]
[SetupLinkerAction ("copy", "test")]
[KeepTypeForwarderOnlyAssemblies ("false")]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwardersModifiers.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwardersModifiers.cs
index 90d35a59a605..c3d0dc212467 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwardersModifiers.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/TypeForwardersModifiers.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
[SetupLinkerArgument ("--skip-unresolved", "true")]
// Actions:
// link - This assembly, TypeForwarderModifiersLibDef.dll and TypeForwardersModifiersLib.dll
- [SetupLinkerUserAction ("link")]
+ [SetupLinkerDefaultAction ("link")]
[KeepTypeForwarderOnlyAssemblies ("false")]
[Define ("IL_ASSEMBLY_AVAILABLE")]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyCopyUsed.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyCopyUsed.cs
index aa92d30ca690..f8538f0c55fb 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyCopyUsed.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyCopyUsed.cs
@@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// link - This assembly
// copyused - Forwarder.dll and Implementation.dll
[SetupLinkerAction ("link", "test")]
- [SetupLinkerUserAction ("copyused")]
+ [SetupLinkerDefaultAction ("copyused")]
[KeepTypeForwarderOnlyAssemblies ("false")]
[SetupCompileBefore ("Forwarder.dll", new[] { "Dependencies/ReferenceImplementationLibrary.cs" }, defines: new[] { "INCLUDE_REFERENCE_IMPL" })]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadeCopy.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadeCopy.cs
index 74ce50a8a9f4..c4105f7d3b27 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadeCopy.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadeCopy.cs
@@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// link - This assembly, Implementation.dll
// copy - Forwarder.dll
// --keep-facades
- [SetupLinkerUserAction ("link")]
+ [SetupLinkerDefaultAction ("link")]
[SetupLinkerAction ("copy", "Forwarder")]
[KeepTypeForwarderOnlyAssemblies ("true")]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadesKept.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadesKept.cs
index 72e013a4798a..439e73d758a4 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadesKept.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/UnusedForwarderWithAssemblyLinkedAndFacadesKept.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// Actions:
// link - This assembly, Forwarder.dll and Implementation.dll
// --keep-facades
- [SetupLinkerUserAction ("link")]
+ [SetupLinkerDefaultAction ("link")]
[KeepTypeForwarderOnlyAssemblies ("true")]
[SetupCompileBefore ("Forwarder.dll", new[] { "Dependencies/ReferenceImplementationLibrary.cs" }, defines: new[] { "INCLUDE_REFERENCE_IMPL" })]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedAndUnusedForwarderWithAssemblyCopy.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedAndUnusedForwarderWithAssemblyCopy.cs
index c4c7e9b48ce5..63f9e70c5121 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedAndUnusedForwarderWithAssemblyCopy.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedAndUnusedForwarderWithAssemblyCopy.cs
@@ -7,7 +7,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// Actions:
// link - This assembly, Unused.dll
// copy - Forwarder.dll, Implementation.dll
- [SetupLinkerUserAction ("copy")]
+ [SetupLinkerDefaultAction ("copy")]
[SetupLinkerAction ("link", "Unused")]
[SetupLinkerAction ("link", "test")]
[KeepTypeForwarderOnlyAssemblies ("false")]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopy.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopy.cs
index afd27beb199d..9258160236c2 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopy.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopy.cs
@@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// link - This assembly
// copy - Forwarder.dll and Implementation.dll
[SetupLinkerAction ("link", "test")]
- [SetupLinkerUserAction ("copy")]
+ [SetupLinkerDefaultAction ("copy")]
[KeepTypeForwarderOnlyAssemblies ("false")]
[SetupCompileBefore ("Forwarder.dll", new[] { "Dependencies/ReferenceImplementationLibrary.cs" }, defines: new[] { "INCLUDE_REFERENCE_IMPL" })]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsed.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsed.cs
index ab2f35a7b3e7..fb09a5b7c829 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsed.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsed.cs
@@ -8,7 +8,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// link - This assembly
// copyused - Forwarder.dll and Implementation.dll
[SetupLinkerAction ("link", "test")]
- [SetupLinkerUserAction ("copyused")]
+ [SetupLinkerDefaultAction ("copyused")]
[KeepTypeForwarderOnlyAssemblies ("false")]
[SetupCompileBefore ("Forwarder.dll", new[] { "Dependencies/ReferenceImplementationLibrary.cs" }, defines: new[] { "INCLUDE_REFERENCE_IMPL" })]
diff --git a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsedAndFacadesKept.cs b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsedAndFacadesKept.cs
index f9505278c1c8..9c7b0c76962b 100644
--- a/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsedAndFacadesKept.cs
+++ b/test/Mono.Linker.Tests.Cases/TypeForwarding/UsedForwarderWithAssemblyCopyUsedAndFacadesKept.cs
@@ -9,7 +9,7 @@ namespace Mono.Linker.Tests.Cases.TypeForwarding
// copyused - Forwarder.dll and Implementation.dll
// --keep-facades
[SetupLinkerAction ("link", "test")]
- [SetupLinkerUserAction ("copyused")]
+ [SetupLinkerDefaultAction ("copyused")]
[KeepTypeForwarderOnlyAssemblies ("true")]
[SetupCompileBefore ("Forwarder.dll", new[] { "Dependencies/ReferenceImplementationLibrary.cs" }, defines: new[] { "INCLUDE_REFERENCE_IMPL" })]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs
index 39ba5b3aa01f..f575cdfcacdd 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs
@@ -8,7 +8,7 @@
namespace Mono.Linker.Tests.Cases.Warnings.Individual
{
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
#if !NETCOREAPP
[Reference ("System.Core.dll")]
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) }, new[] { "System.Core.dll" })]
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs
index e021fae449c6..47d1c929435d 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileXml.cs
@@ -4,7 +4,7 @@
namespace Mono.Linker.Tests.Cases.Warnings.Individual
{
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
#if !NETCOREAPP
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) }, new[] { "System.Core.dll" })]
#else
diff --git a/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs b/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs
index 0604926efd4c..c30fffdaabeb 100644
--- a/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs
+++ b/test/Mono.Linker.Tests.Cases/Warnings/Individual/WarningsAreSorted.cs
@@ -12,7 +12,7 @@
namespace Mono.Linker.Tests.Cases.Warnings.Individual
{
[SkipRemainingErrorsValidation]
- [SetupLinkerCoreAction ("skip")]
+ [SetupLinkerTrimMode ("skip")]
#if !NETCOREAPP
[SetupCompileBefore ("library.dll", new[] { typeof (TriggerWarnings_Lib) }, new[] { "System.Core.dll" })]
#else
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs b/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs
index de6587e659d8..b95fb0a14796 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs
@@ -19,6 +19,12 @@ public virtual void AddSearchDirectory (NPath directory)
Append (directory.ToString ());
}
+ public virtual void AddReference (NPath path)
+ {
+ Append ("-reference");
+ Append (path.ToString ());
+ }
+
public virtual void AddOutputDirectory (NPath directory)
{
Append ("-o");
@@ -36,15 +42,15 @@ public virtual void AddResponseFile (NPath path)
Append ($"@{path}");
}
- public virtual void AddCoreLink (string value)
+ public virtual void AddTrimMode (string value)
{
- Append ("-c");
+ Append ("--trim-mode");
Append (value);
}
- public virtual void AddUserLink (string value)
+ public virtual void AddDefaultAction (string value)
{
- Append ("-u");
+ Append ("--action");
Append (value);
}
@@ -110,7 +116,7 @@ public virtual void AddKeepDebugMembers (string value)
public virtual void AddAssemblyAction (string action, string assembly)
{
- Append ("-p");
+ Append ("--action");
Append (action);
Append (assembly);
}
@@ -188,13 +194,11 @@ public virtual void ProcessTestInputAssembly (NPath inputAssemblyPath)
public virtual void ProcessOptions (TestCaseLinkerOptions options)
{
- if (options.CoreAssembliesAction != null)
- AddCoreLink (options.CoreAssembliesAction);
- else
- AddCoreLink ("skip");
+ if (options.TrimMode != null)
+ AddTrimMode (options.TrimMode);
- if (options.UserAssembliesAction != null)
- AddUserLink (options.UserAssembliesAction);
+ if (options.DefaultAssembliesAction != null)
+ AddDefaultAction (options.DefaultAssembliesAction);
if (options.AssembliesAction != null) {
foreach (var entry in options.AssembliesAction)
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs
index 47758c4a39e0..b51639d9da30 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs
@@ -1,12 +1,11 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace Mono.Linker.Tests.TestCasesRunner
{
public class TestCaseLinkerOptions
{
- public string CoreAssembliesAction;
- public string UserAssembliesAction;
+ public string TrimMode;
+ public string DefaultAssembliesAction;
public List> AssembliesAction = new List> ();
public string Il8n;
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs
index 56097c4a2640..e528328dffd4 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs
@@ -37,8 +37,8 @@ public virtual TestCaseLinkerOptions GetLinkerOptions (NPath inputPath)
KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue (nameof (KeepTypeForwarderOnlyAssembliesAttribute), string.Empty),
KeepDebugMembers = GetOptionAttributeValue (nameof (SetupLinkerKeepDebugMembersAttribute), string.Empty),
LinkSymbols = GetOptionAttributeValue (nameof (SetupLinkerLinkSymbolsAttribute), string.Empty),
- CoreAssembliesAction = GetOptionAttributeValue (nameof (SetupLinkerCoreActionAttribute), null),
- UserAssembliesAction = GetOptionAttributeValue (nameof (SetupLinkerUserActionAttribute), null),
+ TrimMode = GetOptionAttributeValue (nameof (SetupLinkerTrimModeAttribute), null),
+ DefaultAssembliesAction = GetOptionAttributeValue (nameof (SetupLinkerDefaultActionAttribute), null),
SkipUnresolved = GetOptionAttributeValue (nameof (SkipUnresolvedAttribute), false),
StripDescriptors = GetOptionAttributeValue (nameof (StripDescriptorsAttribute), true),
StripSubstitutions = GetOptionAttributeValue (nameof (StripSubstitutionsAttribute), true),
@@ -227,13 +227,20 @@ public virtual IEnumerable GetLinkAttributesFiles ()
.Select (GetSourceAndRelativeDestinationValue);
}
- public virtual IEnumerable GetExtraLinkerSearchDirectories ()
+ public virtual IEnumerable GetExtraLinkerReferences ()
{
-#if NETCOREAPP
- yield return Path.GetDirectoryName (typeof (object).Assembly.Location).ToNPath ();
-#else
- yield break;
-#endif
+ var netcoreappDir = Path.GetDirectoryName (typeof (object).Assembly.Location);
+ foreach (var assembly in Directory.EnumerateFiles (netcoreappDir)) {
+ if (Path.GetExtension (assembly) != ".dll")
+ continue;
+ var assemblyName = Path.GetFileNameWithoutExtension (assembly);
+ if (assemblyName.Contains ("Native"))
+ continue;
+ if (assemblyName.StartsWith ("Microsoft") ||
+ assemblyName.StartsWith ("System") ||
+ assemblyName == "mscorlib" || assemblyName == "netstandard")
+ yield return assembly.ToNPath ();
+ }
}
public virtual bool IsIgnored (out string reason)
diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs
index 677de6124373..44325138cc58 100644
--- a/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs
+++ b/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs
@@ -114,9 +114,16 @@ protected virtual void AddLinkOptions (TestCaseSandbox sandbox, ManagedCompilati
foreach (var rspFile in sandbox.ResponseFiles)
builder.AddResponseFile (rspFile);
- builder.AddSearchDirectory (sandbox.InputDirectory);
- foreach (var extraSearchDir in metadataProvider.GetExtraLinkerSearchDirectories ())
- builder.AddSearchDirectory (extraSearchDir);
+ foreach (var inputReference in sandbox.InputDirectory.Files ()) {
+ var ext = inputReference.ExtensionWithDot;
+ if (ext == ".dll" || ext == ".exe")
+ builder.AddReference (inputReference);
+ }
+ var coreAction = caseDefinedOptions.TrimMode ?? "skip";
+ foreach (var extraReference in metadataProvider.GetExtraLinkerReferences ()) {
+ builder.AddReference (extraReference);
+ builder.AddAssemblyAction (coreAction, extraReference.FileNameWithoutExtension);
+ }
builder.ProcessOptions (caseDefinedOptions);