From d1a6b3d2501af19b3adacca834fcfe38b06a9c62 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 16 Feb 2021 18:44:12 -0800 Subject: [PATCH 01/10] Support attribute opt-in --- docs/error-codes.md | 23 ++++ src/linker/Linker.Steps/MarkStep.cs | 14 +-- .../RootNonTrimmableAssemblies.cs | 55 +++++++++ src/linker/Linker/AssemblyResolver.cs | 28 +++-- src/linker/Linker/Driver.cs | 108 +++++++++--------- src/linker/Linker/LinkContext.cs | 74 ++++++------ test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs | 18 ++- .../CanOverrideIsTrimmableAttribute.cs | 36 ++++++ .../CoreLink/CanUseIsTrimmableAttribute.cs | 34 ++++++ .../InvalidIsTrimmableAssembly.cs | 20 ++++ .../Dependencies/NonTrimmableAssembly.cs | 14 +++ .../Dependencies/TrimmableAssembly.cs | 17 +++ .../CoreLink/InvalidIsTrimmableAttribute.cs | 33 ++++++ .../EmbeddedLinkAttributesInCorelib.cs | 5 - .../References/CopyAreKeptFully.cs | 8 +- .../TestCasesRunner/LinkerArgumentBuilder.cs | 16 ++- .../TestCasesRunner/TestCaseMetadaProvider.cs | 13 ++- .../TestCasesRunner/TestRunner.cs | 13 ++- 18 files changed, 387 insertions(+), 142 deletions(-) create mode 100644 src/linker/Linker.Steps/RootNonTrimmableAssemblies.cs create mode 100644 test/Mono.Linker.Tests.Cases/CoreLink/CanOverrideIsTrimmableAttribute.cs create mode 100644 test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs create mode 100644 test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs create mode 100644 test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/NonTrimmableAssembly.cs create mode 100644 test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/TrimmableAssembly.cs create mode 100644 test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs diff --git a/docs/error-codes.md b/docs/error-codes.md index 3a66bde74bfa..cc33e4cb1c8d 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,25 @@ 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 assembl 'fullname'. Value must be "True" + [assembly: AssemblyMetadata("IsTrimmable", "False")] + ``` + +#### `IL2103`: Duplicate AssemblyMetadata("IsTrimmable", "True") attributes in assembly 'assembly' + +- AssemblyMetadata("IsTrimmable", "True") should only be used once at the assembly level. + + ``` C# + // IL2103: Duplicate AssemblyMetadata("IsTrimmable", "True") attribute in assembly 'assembly'. + [assembly: AssemblyMetadata("IsTrimmable", "True")] + [assembly: AssemblyMetadata("IsTrimmable", "True")] + ``` + ## 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/src/linker/Linker.Steps/MarkStep.cs b/src/linker/Linker.Steps/MarkStep.cs index cc32af906022..005ac0ac4a47 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 (RootNonTrimmableAssemblies.IsFullyPreservedAction (_context.Annotations.GetAction (assembly))) { MarkEntireAssembly (assembly); return; } diff --git a/src/linker/Linker.Steps/RootNonTrimmableAssemblies.cs b/src/linker/Linker.Steps/RootNonTrimmableAssemblies.cs new file mode 100644 index 000000000000..ecbc6a42b635 --- /dev/null +++ b/src/linker/Linker.Steps/RootNonTrimmableAssemblies.cs @@ -0,0 +1,55 @@ +// 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 RootNonTrimmableAssemblies : BaseStep + { + protected override void Process () + { + // Walk over all -reference inputs and resolve any that may need to be rooted + foreach (var assemblyPath in GetInputAssemblyPaths ()) { + var assemblyName = Path.GetFileNameWithoutExtension (assemblyPath); + + if (!MaybeIsFullyPreservedAssembly (assemblyName)) + continue; + + var assembly = Context.TryResolve (assemblyName); + if (assembly == null) { + Context.LogError ($"Reference assembly '{assemblyPath}' could not be loaded", 1039); + continue; + } + + if (IsFullyPreservedAction (Annotations.GetAction (assembly))) + Annotations.Mark (assembly.MainModule, new DependencyInfo (DependencyKind.AssemblyAction, assembly)); + } + } + + public 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..0f6766c7cf11 100644 --- a/src/linker/Linker/AssemblyResolver.cs +++ b/src/linker/Linker/AssemblyResolver.cs @@ -42,7 +42,7 @@ public class AssemblyResolver : DirectoryAssemblyResolver HashSet _unresolvedAssemblies; bool _ignoreUnresolved; LinkContext _context; - readonly Collection _references; + readonly HashSet _references; public IDictionary AssemblyCache { @@ -57,7 +57,7 @@ public AssemblyResolver () public AssemblyResolver (Dictionary assembly_cache) { _assemblies = assembly_cache; - _references = new Collection () { }; + _references = new HashSet () { }; } public bool IgnoreUnresolved { @@ -80,16 +80,19 @@ public string GetAssemblyFileName (AssemblyDefinition assembly) return assembly.MainModule.FileName; } - AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, Collection references, ReaderParameters parameters) + AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, HashSet references, ReaderParameters parameters) { - var fileName = name.Name + ".dll"; + var extensions = new[] { ".dll", ".exe" }; foreach (var reference in references) { - if (Path.GetFileName (reference) != fileName) - continue; - try { - return GetAssembly (reference, parameters); - } catch (BadImageFormatException) { - continue; + foreach (var extension in extensions) { + var fileName = name.Name + extension; + if (Path.GetFileName (reference) != fileName) + continue; + try { + return GetAssembly (reference, parameters); + } catch (BadImageFormatException) { + continue; + } } } @@ -139,6 +142,11 @@ public void AddReferenceAssembly (string referencePath) _references.Add (referencePath); } + public HashSet GetReferencePaths () + { + return _references; + } + protected override void Dispose (bool disposing) { foreach (var asm in _assemblies.Values) { diff --git a/src/linker/Linker/Driver.cs b/src/linker/Linker/Driver.cs index afeedc5e6431..9460058035d6 100644 --- a/src/linker/Linker/Driver.cs +++ b/src/linker/Linker/Driver.cs @@ -261,6 +261,47 @@ protected int SetupContext (ILogger customLogger = null) continue; + case "--action": { + 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 "--trim-action": { + AssemblyAction? action = null; + if (!GetStringParam (token, l => action = ParseAssemblyAction (l))) + return -1; + + if (action == null) + return -1; + + context.TrimAction = action.Value; + continue; + } + case "--default-action": { + AssemblyAction? action = null; + if (!GetStringParam (token, l => action = ParseAssemblyAction (l))) + return -1; + + if (action == null) + return -1; + + context.DefaultAction = action.Value; + continue; + } case "--custom-step": if (!GetStringParam (token, l => custom_steps.Push (l))) return -1; @@ -493,47 +534,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 +1045,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 +1086,18 @@ 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-action ACTION Sets action for assemblies annotated as trimmable. 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"); + // https://github.com/mono/linker/blob/main/docs/design/trimmed-assemblies.md#assemblymetadataistrimmable-false + // If we add support for opting out by setting "IsTrimmable" to "False", we should add an option to control behavior for such assemblies. + // Console.WriteLine (" --no-trim-action ACTION Sets action for assemblies annotated as non-trimmable. Defaults to 'copy'"); + Console.WriteLine (" --default-action ACTION Sets action for assemblies that have no trimmability annotation. Defaults to 'link'"); + Console.WriteLine (" --action ACTION ASM Overrides the default action for specific assembly name"); Console.WriteLine (); Console.WriteLine ("Advanced Options"); @@ -1168,6 +1171,7 @@ static void About () static Pipeline GetStandardPipeline () { Pipeline p = new Pipeline (); + p.AppendStep (new RootNonTrimmableAssemblies ()); 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..5717521128d4 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,50 @@ 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 (CheckIsTrimmable (assembly)) + return TrimAction; - return UserAction; + return DefaultAction; } - public static bool IsCore (AssemblyNameReference name) + bool CheckIsTrimmable (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; + var assemblyFileName = Resolver.GetAssemblyFileName (assembly); + + 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)) { + LogWarning ($"Invalid AssemblyMetadata(\"IsTrimmable\", \"{args[1].Value}\") attribute in assembly '{assembly.Name.Name}'. Value must be \"True\"", 2102, assemblyFileName); + continue; + } + + if (isTrimmable) { + LogWarning ($"Duplicate AssemblyMetadata(\"IsTrimmable\", \"True\") attributes in assembly '{assembly.Name.Name}'", 2103, assemblyFileName); + break; + } + + 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..b64e9f9665da 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.GetFileName (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-action link" }; using (var driver = task.CreateDriver ()) { - Assert.Equal (AssemblyAction.Copy, driver.Context.UserAction); + Assert.Equal (AssemblyAction.Copy, driver.Context.DefaultAction); // Check that ExtraArgs can override TrimMode - Assert.Equal (AssemblyAction.Link, driver.Context.CoreAction); + Assert.Equal (AssemblyAction.Link, driver.Context.TrimAction); } } @@ -496,8 +494,8 @@ 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.Copy, driver.Context.DefaultAction); } } 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..89942f5e335b --- /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 +{ + [SetupLinkerUserActionAttribute ("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..f6ba2787f924 --- /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 +{ + [SetupLinkerUserActionAttribute ("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/Dependencies/InvalidIsTrimmableAssembly.cs b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs new file mode 100644 index 000000000000..298bb0c0b5c5 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs @@ -0,0 +1,20 @@ +using System.Reflection; + +[assembly: AssemblyMetadata ("IsTrimmable", "True")] +[assembly: AssemblyMetadata ("IsTrimmable", "False")] +[assembly: AssemblyMetadata ("IsTrimmable", "True")] +[assembly: AssemblyMetadata ("IsTrimmable", "true")] + +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/InvalidIsTrimmableAttribute.cs b/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs new file mode 100644 index 000000000000..ca912db08e6b --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs @@ -0,0 +1,33 @@ +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 +{ + [SetupLinkerUserActionAttribute ("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")] + [ExpectedWarning ("IL2103", "Duplicate AssemblyMetadata(\"IsTrimmable\", \"True\") attributes in assembly 'trimmable'", 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/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs b/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs index 6f96d50c09d7..86ac6fac788f 100644 --- a/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs +++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs @@ -21,13 +21,8 @@ namespace Mono.Linker.Tests.Cases.LinkAttributes 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/References/CopyAreKeptFully.cs b/test/Mono.Linker.Tests.Cases/References/CopyAreKeptFully.cs index 65a91b10b771..e7032669a975 100644 --- a/test/Mono.Linker.Tests.Cases/References/CopyAreKeptFully.cs +++ b/test/Mono.Linker.Tests.Cases/References/CopyAreKeptFully.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/TestCasesRunner/LinkerArgumentBuilder.cs b/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs index de6587e659d8..ff94958cb912 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Mono.Linker.Tests.Extensions; namespace Mono.Linker.Tests.TestCasesRunner @@ -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"); @@ -38,13 +44,13 @@ public virtual void AddResponseFile (NPath path) public virtual void AddCoreLink (string value) { - Append ("-c"); + Append ("--trim-action"); Append (value); } public virtual void AddUserLink (string value) { - Append ("-u"); + Append ("--default-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); } @@ -190,8 +196,6 @@ public virtual void ProcessOptions (TestCaseLinkerOptions options) { if (options.CoreAssembliesAction != null) AddCoreLink (options.CoreAssembliesAction); - else - AddCoreLink ("skip"); if (options.UserAssembliesAction != null) AddUserLink (options.UserAssembliesAction); diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs index 56097c4a2640..8ef90a1982c2 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs @@ -227,13 +227,14 @@ 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; + 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..2482313b928e 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.CoreAssembliesAction ?? "skip"; + foreach (var extraReference in metadataProvider.GetExtraLinkerReferences ()) { + builder.AddReference (extraReference); + builder.AddAssemblyAction (coreAction, extraReference.FileNameWithoutExtension); + } builder.ProcessOptions (caseDefinedOptions); From 6011ad3419c0b1375109561ac9c271ba0852a7b9 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 16 Feb 2021 18:44:28 -0800 Subject: [PATCH 02/10] Update docs --- docs/illink-options.md | 19 +++++++++++-------- docs/illink-tasks.md | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/illink-options.md b/docs/illink-options.md index 52d1ea2f95e8..26ea19de68d3 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`. +Trimmed assemblies are the assemblies that have `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-action skip|copy|copyused|link` + +You can specify what action to do on assemblies without such an attribute with the option: + +`--default-action copy|link` ### The output directory diff --git a/docs/illink-tasks.md b/docs/illink-tasks.md index 50b8883ba5be..1ff92c1ee3d1 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-action link" /> ``` ## Default Linking Behavior From 73b2c4a04e91c43293e3d4863955cd072b3f201e Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Tue, 16 Feb 2021 18:49:17 -0800 Subject: [PATCH 03/10] Rename test attributes to match --- ...ute.cs => SetupLinkerDefaultActionAttribute.cs} | 4 ++-- ...ribute.cs => SetupLinkerTrimActionAttribute.cs} | 4 ++-- ...ebuggerDisplayAttributeOnAssemblyUsingTarget.cs | 2 +- ...ayAttributeOnAssemblyUsingTargetOnUnusedType.cs | 2 +- ...OnAssemblyUsingTargetTypeNameInOtherAssembly.cs | 2 +- .../DebuggerDisplayAttributeOnType.cs | 2 +- .../DebuggerDisplayAttributeOnTypeThatIsNotUsed.cs | 2 +- ...rDisplayAttributeOnTypeWithNonExistentMethod.cs | 2 +- ...uggerTypeProxyAttributeOnAssemblyUsingTarget.cs | 2 +- .../DebuggerTypeProxyAttributeOnType.cs | 2 +- ...ebuggerDisplayAttributeOnAssemblyUsingTarget.cs | 2 +- ...ayAttributeOnAssemblyUsingTargetOnUnusedType.cs | 2 +- ...OnAssemblyUsingTargetTypeNameInOtherAssembly.cs | 2 +- ...eOnAssemblyUsingTargetTypeNameInSameAssembly.cs | 2 +- ...ngTargetTypeNameOfGenericTypeInOtherAssembly.cs | 2 +- ...ingTargetTypeNameOfNestedTypeInOtherAssembly.cs | 2 +- .../DebuggerDisplayAttributeOnType.cs | 2 +- ...uggerTypeProxyAttributeOnAssemblyUsingTarget.cs | 2 +- .../DebuggerTypeProxyAttributeOnType.cs | 2 +- .../CoreLibraryAssemblyAttributesAreKept.cs | 2 +- .../MarshalAsCustomMarshalerInterface.cs | 2 +- .../CoreLibrarySecurityAttributeTypesAreRemoved.cs | 2 +- ...nLinkCoreLibrariesWithOnlyKeepUsedAttributes.cs | 2 +- ...oreLibraryUnusedAssemblyAttributesAreRemoved.cs | 2 +- .../CoreLibraryUsedAssemblyAttributesAreKept.cs | 2 +- .../BCLFeatures/ETW/BaseRemovedEventSource.cs | 2 +- .../ETW/BaseRemovedEventSourceEmptyBody.cs | 2 +- .../ETW/BaseRemovedEventSourceNonVoidReturn.cs | 2 +- .../BCLFeatures/ETW/Excluded.cs | 2 +- .../ETW/LocalsOfModifiedMethodAreRemoved.cs | 2 +- .../ETW/StubbedMethodWithExceptionHandlers.cs | 2 +- .../ComponentModel/TypeConverterOnMembers.cs | 2 +- .../CoreLink/CanIncludeI18nAssemblies.cs | 2 +- .../CoreLink/CanOverrideIsTrimmableAttribute.cs | 2 +- .../CoreLink/CanUseIsTrimmableAttribute.cs | 2 +- .../CopyOfCoreLibrariesKeepsUnusedTypes.cs | 2 +- ...gateAndMulticastDelegateKeepInstantiatedReqs.cs | 2 +- .../InstantiatedStructWithOverridesFromObject.cs | 2 +- .../InstantiatedTypeWithOverridesFromObject.cs | 2 +- .../CoreLink/InvalidIsTrimmableAttribute.cs | 2 +- .../LinkingOfCoreLibrariesRemovesUnusedMethods.cs | 2 +- .../LinkingOfCoreLibrariesRemovesUnusedTypes.cs | 2 +- ...NeverInstantiatedTypeWithOverridesFromObject.cs | 2 +- ...emovesAllSecurityAttributesFromCoreLibraries.cs | 2 +- ...hodInNonReferencedAssemblyWithCopyUsedAction.cs | 2 +- .../PInvoke/Individual/CanOutputPInvokes.cs | 2 +- .../Libraries/UserAssemblyActionWorks.cs | 2 +- .../EmbeddedLinkAttributesInCorelib.cs | 2 +- ...hodInNonReferencedAssemblyWithCopyUsedAction.cs | 2 +- .../References/CopyAreKeptFully.cs | 2 +- .../References/CopyUsedAreKeptFully.cs | 2 +- .../ReferencesAreRemovedWhenAllUsagesAreRemoved.cs | 2 +- .../VerifyExpectModifiedAttributesWork.cs | 2 +- .../Tracing/Individual/CanEnableReducedTracing.cs | 2 +- .../TypeForwarding/AttributeArgumentForwarded.cs | 2 +- .../AttributeArgumentForwardedWithCopyAction.cs | 2 +- .../TypeForwarding/AttributesScopeUpdated.cs | 2 +- .../TypeForwarding/TypeForwardersModifiers.cs | 2 +- .../UnusedForwarderWithAssemblyCopyUsed.cs | 2 +- ...usedForwarderWithAssemblyLinkedAndFacadeCopy.cs | 2 +- ...sedForwarderWithAssemblyLinkedAndFacadesKept.cs | 2 +- .../UsedAndUnusedForwarderWithAssemblyCopy.cs | 2 +- .../UsedForwarderWithAssemblyCopy.cs | 2 +- .../UsedForwarderWithAssemblyCopyUsed.cs | 2 +- ...dForwarderWithAssemblyCopyUsedAndFacadesKept.cs | 2 +- .../CanGenerateWarningSuppressionFileCSharp.cs | 2 +- .../CanGenerateWarningSuppressionFileXml.cs | 2 +- .../Warnings/Individual/WarningsAreSorted.cs | 2 +- .../TestCasesRunner/LinkerArgumentBuilder.cs | 14 +++++++------- .../TestCasesRunner/TestCaseLinkerOptions.cs | 7 +++---- .../TestCasesRunner/TestCaseMetadaProvider.cs | 4 ++-- .../TestCasesRunner/TestRunner.cs | 2 +- 72 files changed, 83 insertions(+), 84 deletions(-) rename test/Mono.Linker.Tests.Cases.Expectations/Metadata/{SetupLinkerUserActionAttribute.cs => SetupLinkerDefaultActionAttribute.cs} (65%) rename test/Mono.Linker.Tests.Cases.Expectations/Metadata/{SetupLinkerCoreActionAttribute.cs => SetupLinkerTrimActionAttribute.cs} (68%) 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/SetupLinkerTrimActionAttribute.cs similarity index 68% rename from test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs rename to test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimActionAttribute.cs index 077dad672374..46c8bca43fbc 100644 --- a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerCoreActionAttribute.cs +++ b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimActionAttribute.cs @@ -3,9 +3,9 @@ namespace Mono.Linker.Tests.Cases.Expectations.Metadata { [AttributeUsage (AttributeTargets.Class, AllowMultiple = false)] - public class SetupLinkerCoreActionAttribute : BaseMetadataAttribute + public class SetupLinkerTrimActionAttribute : BaseMetadataAttribute { - public SetupLinkerCoreActionAttribute (string action) + public SetupLinkerTrimActionAttribute (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..eeea46c5307e 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")] + [SetupLinkerTrimAction ("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..b431308839da 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")] + [SetupLinkerTrimAction ("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..001da8417a9c 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")] + [SetupLinkerTrimAction ("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..2e017cbae8b9 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")] + [SetupLinkerTrimAction ("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..c712e6943375 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")] + [SetupLinkerTrimAction ("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..e8002cd22611 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")] + [SetupLinkerTrimAction ("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..be60c5a0fb9a 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")] + [SetupLinkerTrimAction ("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..8bd7ae1d314c 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")] + [SetupLinkerTrimAction ("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..2cb82afb2f42 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")] + [SetupLinkerTrimAction ("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..8de8987e3382 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")] + [SetupLinkerTrimAction ("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..61c7cdc4392a 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")] + [SetupLinkerTrimAction ("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..1f939907cb12 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")] + [SetupLinkerTrimAction ("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..45bca7ad7b38 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")] + [SetupLinkerTrimAction ("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..0c3182332d66 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")] + [SetupLinkerTrimAction ("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..ff44158dccba 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")] + [SetupLinkerTrimAction ("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..11a11d3e4911 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")] + [SetupLinkerTrimAction ("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..478858fdf77c 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")] + [SetupLinkerTrimAction ("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..7a46a7bdf614 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")] + [SetupLinkerTrimAction ("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..e3ec04187cee 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")] + [SetupLinkerTrimAction ("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..8f386b71a548 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")] + [SetupLinkerTrimAction ("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..0f611ddfea9f 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")] + [SetupLinkerTrimAction ("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..9a9468afec78 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")] + [SetupLinkerTrimAction ("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..a83f5dbb75a0 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")] + [SetupLinkerTrimAction ("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..894cc6453621 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")] + [SetupLinkerTrimAction ("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..ad4e016ac023 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")] + [SetupLinkerTrimAction ("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..8d5a84d87a64 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")] + [SetupLinkerTrimAction ("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..e70aac22a993 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")] + [SetupLinkerTrimAction ("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..f1416d2353a1 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")] + [SetupLinkerTrimAction ("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..3b9d65d04222 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")] + [SetupLinkerTrimAction ("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..9d06c2f7d89d 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")] + [SetupLinkerTrimAction ("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..4527c1f855c8 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")] + [SetupLinkerTrimAction ("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 index 89942f5e335b..bdd23ed82486 100644 --- a/test/Mono.Linker.Tests.Cases/CoreLink/CanOverrideIsTrimmableAttribute.cs +++ b/test/Mono.Linker.Tests.Cases/CoreLink/CanOverrideIsTrimmableAttribute.cs @@ -4,7 +4,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink { - [SetupLinkerUserActionAttribute ("copy")] + [SetupLinkerDefaultActionAttribute ("copy")] [SetupLinkerAction ("link", "test")] [SetupLinkerAction ("copy", "trimmable")] [SetupLinkerAction ("link", "nontrimmable")] diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs b/test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs index f6ba2787f924..eb1f8e16c800 100644 --- a/test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs +++ b/test/Mono.Linker.Tests.Cases/CoreLink/CanUseIsTrimmableAttribute.cs @@ -4,7 +4,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink { - [SetupLinkerUserActionAttribute ("copy")] + [SetupLinkerDefaultActionAttribute ("copy")] [SetupCompileBefore ("trimmable.dll", new[] { "Dependencies/TrimmableAssembly.cs" })] [SetupCompileBefore ("nontrimmable.dll", new[] { "Dependencies/NonTrimmableAssembly.cs" })] diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs b/test/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs index ba3ad068bfa5..3bbc90c30c9f 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")] + [SetupLinkerTrimAction ("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..75b8827570cb 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")] + [SetupLinkerTrimAction ("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/InstantiatedStructWithOverridesFromObject.cs b/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedStructWithOverridesFromObject.cs index d8255fe44477..e112b461c309 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")] + [SetupLinkerTrimAction ("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..a931fe96e0c6 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")] + [SetupLinkerTrimAction ("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 index ca912db08e6b..84668cf176a2 100644 --- a/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs +++ b/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs @@ -4,7 +4,7 @@ namespace Mono.Linker.Tests.Cases.CoreLink { - [SetupLinkerUserActionAttribute ("copy")] + [SetupLinkerDefaultActionAttribute ("copy")] [SetupCompileBefore ("trimmable.dll", new[] { "Dependencies/InvalidIsTrimmableAssembly.cs" })] [KeptMemberInAssembly ("trimmable.dll", typeof (InvalidIsTrimmableAssembly), "Used()")] diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs b/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs index a4d715aac4e7..adf43955b05d 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")] + [SetupLinkerTrimAction ("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..b67a51e43f5d 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")] + [SetupLinkerTrimAction ("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..00eada13dc5f 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")] + [SetupLinkerTrimAction ("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..3d93330d4b93 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")] + [SetupLinkerTrimAction ("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..83e2c1d8c09f 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")] + [SetupLinkerTrimAction ("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 86ac6fac788f..aa7a225c421e 100644 --- a/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs +++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs @@ -15,7 +15,7 @@ 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 + [SetupLinkerTrimAction ("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" } }, 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 e7032669a975..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" })] 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..ac7ba844a106 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")] + [SetupLinkerTrimAction ("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..f7a7978e7a27 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")] + [SetupLinkerTrimAction ("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..6d502a14a63d 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")] + [SetupLinkerTrimAction ("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..d5eda4100466 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")] + [SetupLinkerTrimAction ("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..224b57e82c8e 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")] + [SetupLinkerTrimAction ("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..b5c62e73a02f 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")] + [SetupLinkerTrimAction ("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 ff94958cb912..ed5609be15f5 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Mono.Linker.Tests.Extensions; namespace Mono.Linker.Tests.TestCasesRunner @@ -42,13 +42,13 @@ public virtual void AddResponseFile (NPath path) Append ($"@{path}"); } - public virtual void AddCoreLink (string value) + public virtual void AddTrimAction (string value) { Append ("--trim-action"); Append (value); } - public virtual void AddUserLink (string value) + public virtual void AddDefaultAction (string value) { Append ("--default-action"); Append (value); @@ -194,11 +194,11 @@ public virtual void ProcessTestInputAssembly (NPath inputAssemblyPath) public virtual void ProcessOptions (TestCaseLinkerOptions options) { - if (options.CoreAssembliesAction != null) - AddCoreLink (options.CoreAssembliesAction); + if (options.TrimAssembliesAction != null) + AddTrimAction (options.TrimAssembliesAction); - 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..a87ef2388d78 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 TrimAssembliesAction; + 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 8ef90a1982c2..3935c283cd82 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), + TrimAssembliesAction = GetOptionAttributeValue (nameof (SetupLinkerTrimActionAttribute), null), + DefaultAssembliesAction = GetOptionAttributeValue (nameof (SetupLinkerDefaultActionAttribute), null), SkipUnresolved = GetOptionAttributeValue (nameof (SkipUnresolvedAttribute), false), StripDescriptors = GetOptionAttributeValue (nameof (StripDescriptorsAttribute), true), StripSubstitutions = GetOptionAttributeValue (nameof (StripSubstitutionsAttribute), true), diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs index 2482313b928e..581db16654f3 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs @@ -119,7 +119,7 @@ protected virtual void AddLinkOptions (TestCaseSandbox sandbox, ManagedCompilati if (ext == ".dll" || ext == ".exe") builder.AddReference (inputReference); } - var coreAction = caseDefinedOptions.CoreAssembliesAction ?? "skip"; + var coreAction = caseDefinedOptions.TrimAssembliesAction ?? "skip"; foreach (var extraReference in metadataProvider.GetExtraLinkerReferences ()) { builder.AddReference (extraReference); builder.AddAssemblyAction (coreAction, extraReference.FileNameWithoutExtension); From 6a72f8dda2f29a50fb509b71ff7b1e5f3b2e826f Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 17 Feb 2021 11:23:17 -0800 Subject: [PATCH 04/10] Don't pass native SDK assemblies to tests on Windows --- .../TestCasesRunner/TestCaseMetadaProvider.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs index 3935c283cd82..80606220b4bc 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs @@ -233,7 +233,13 @@ public virtual IEnumerable GetExtraLinkerReferences () foreach (var assembly in Directory.EnumerateFiles (netcoreappDir)) { if (Path.GetExtension (assembly) != ".dll") continue; - yield return assembly.ToNPath (); + 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 (); } } From 712632236cadf8d8dc5de5c146c946f750c70357 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 17 Feb 2021 12:01:51 -0800 Subject: [PATCH 05/10] Update LinkTask --- src/ILLink.Tasks/LinkTask.cs | 22 +++++++++++++------ test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs | 18 ++++++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/ILLink.Tasks/LinkTask.cs b/src/ILLink.Tasks/LinkTask.cs index a1bdf38b6281..8d82b33f342a 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-action' /// public string TrimMode { get; set; } + /// + /// Sets the default action for assemblies which have not opted into trimming. + /// Maps to '--default-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-action ").AppendLine (TrimMode); + + if (DefaultAction != null) + args.Append ("--default-action ").AppendLine (DefaultAction); if (CustomSteps != null) { foreach (var customStep in CustomSteps) { diff --git a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs index b64e9f9665da..5e4df169ce9f 100644 --- a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs +++ b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs @@ -495,7 +495,23 @@ 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.TrimAction); - Assert.Equal (AssemblyAction.Copy, driver.Context.DefaultAction); + 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); } } From 308fe09100d5dd16eb366ad5cb7940da542c3a3a Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 17 Feb 2021 12:10:45 -0800 Subject: [PATCH 06/10] PR feedback - Don't warn on duplicate attributes - Remove comment - Fix typos and wording - Use static array - Rename CheckIsTrimmable -> IsTrimmable --- docs/error-codes.md | 12 +----------- docs/illink-options.md | 2 +- src/linker/Linker/AssemblyResolver.cs | 3 +-- src/linker/Linker/DirectoryAssemblyResolver.cs | 5 +++-- src/linker/Linker/Driver.cs | 3 --- src/linker/Linker/LinkContext.cs | 11 +++-------- .../Dependencies/InvalidIsTrimmableAssembly.cs | 4 +--- .../CoreLink/InvalidIsTrimmableAttribute.cs | 1 - 8 files changed, 10 insertions(+), 31 deletions(-) diff --git a/docs/error-codes.md b/docs/error-codes.md index cc33e4cb1c8d..c674f363c00b 100644 --- a/docs/error-codes.md +++ b/docs/error-codes.md @@ -1519,20 +1519,10 @@ This is technically possible if a custom assembly defines `DynamicDependencyAttr - 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 assembl 'fullname'. Value must be "True" + // IL2102: Invalid AssemblyMetadata("IsTrimmable", "False") attribute in assembly 'assembly'. Value must be "True" [assembly: AssemblyMetadata("IsTrimmable", "False")] ``` -#### `IL2103`: Duplicate AssemblyMetadata("IsTrimmable", "True") attributes in assembly 'assembly' - -- AssemblyMetadata("IsTrimmable", "True") should only be used once at the assembly level. - - ``` C# - // IL2103: Duplicate AssemblyMetadata("IsTrimmable", "True") attribute in assembly 'assembly'. - [assembly: AssemblyMetadata("IsTrimmable", "True")] - [assembly: AssemblyMetadata("IsTrimmable", "True")] - ``` - ## 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 26ea19de68d3..7e84d660b515 100644 --- a/docs/illink-options.md +++ b/docs/illink-options.md @@ -68,7 +68,7 @@ or Or you can specify what to do for the trimmed assemblies. -Trimmed assemblies are the assemblies that have `AssemblyMetadata("IsTrimmable", "True")`. +A trimmable assembly is any assembly that includes the attribute `System.Reflection.AssemblyMetadata("IsTrimmable", "True")`. You can specify what action to do on the trimmed assemblies with the option: diff --git a/src/linker/Linker/AssemblyResolver.cs b/src/linker/Linker/AssemblyResolver.cs index 0f6766c7cf11..08d062c11751 100644 --- a/src/linker/Linker/AssemblyResolver.cs +++ b/src/linker/Linker/AssemblyResolver.cs @@ -82,9 +82,8 @@ public string GetAssemblyFileName (AssemblyDefinition assembly) AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, HashSet references, ReaderParameters parameters) { - var extensions = new[] { ".dll", ".exe" }; foreach (var reference in references) { - foreach (var extension in extensions) { + foreach (var extension in DirectoryAssemblyResolver.Extensions) { var fileName = name.Name + extension; if (Path.GetFileName (reference) != fileName) continue; 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 9460058035d6..ecfe18ba952b 100644 --- a/src/linker/Linker/Driver.cs +++ b/src/linker/Linker/Driver.cs @@ -1093,9 +1093,6 @@ static void Usage () 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"); - // https://github.com/mono/linker/blob/main/docs/design/trimmed-assemblies.md#assemblymetadataistrimmable-false - // If we add support for opting out by setting "IsTrimmable" to "False", we should add an option to control behavior for such assemblies. - // Console.WriteLine (" --no-trim-action ACTION Sets action for assemblies annotated as non-trimmable. Defaults to 'copy'"); Console.WriteLine (" --default-action ACTION Sets action for assemblies that have no trimmability annotation. Defaults to 'link'"); Console.WriteLine (" --action ACTION ASM Overrides the default action for specific assembly name"); diff --git a/src/linker/Linker/LinkContext.cs b/src/linker/Linker/LinkContext.cs index 5717521128d4..9647aa7ea2a8 100644 --- a/src/linker/Linker/LinkContext.cs +++ b/src/linker/Linker/LinkContext.cs @@ -392,19 +392,18 @@ public AssemblyAction CalculateAssemblyAction (AssemblyDefinition assembly) if (_actions.TryGetValue (assembly.Name.Name, out AssemblyAction action)) return action; - if (CheckIsTrimmable (assembly)) + if (IsTrimmable (assembly)) return TrimAction; return DefaultAction; } - bool CheckIsTrimmable (AssemblyDefinition assembly) + bool IsTrimmable (AssemblyDefinition assembly) { if (!assembly.HasCustomAttributes) return false; bool isTrimmable = false; - var assemblyFileName = Resolver.GetAssemblyFileName (assembly); foreach (var ca in assembly.CustomAttributes) { if (!ca.AttributeType.IsTypeOf ()) @@ -418,15 +417,11 @@ bool CheckIsTrimmable (AssemblyDefinition assembly) 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; } - if (isTrimmable) { - LogWarning ($"Duplicate AssemblyMetadata(\"IsTrimmable\", \"True\") attributes in assembly '{assembly.Name.Name}'", 2103, assemblyFileName); - break; - } - isTrimmable = true; } diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs index 298bb0c0b5c5..125bb712c972 100644 --- a/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs +++ b/test/Mono.Linker.Tests.Cases/CoreLink/Dependencies/InvalidIsTrimmableAssembly.cs @@ -1,9 +1,7 @@ using System.Reflection; -[assembly: AssemblyMetadata ("IsTrimmable", "True")] -[assembly: AssemblyMetadata ("IsTrimmable", "False")] -[assembly: AssemblyMetadata ("IsTrimmable", "True")] [assembly: AssemblyMetadata ("IsTrimmable", "true")] +[assembly: AssemblyMetadata ("IsTrimmable", "False")] namespace Mono.Linker.Tests.Cases.CoreLink.Dependencies { diff --git a/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs b/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs index 84668cf176a2..35463fd52d44 100644 --- a/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs +++ b/test/Mono.Linker.Tests.Cases/CoreLink/InvalidIsTrimmableAttribute.cs @@ -10,7 +10,6 @@ namespace Mono.Linker.Tests.Cases.CoreLink [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")] - [ExpectedWarning ("IL2103", "Duplicate AssemblyMetadata(\"IsTrimmable\", \"True\") attributes in assembly 'trimmable'", FileName = "trimmable.dll")] [KeptMember (".ctor()")] public class InvalidIsTrimmableAttribute { From 0348c04d05e19eb93f657a780a66e9161c2bc409 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 17 Feb 2021 12:55:18 -0800 Subject: [PATCH 07/10] PR feedback: rename options - --trim-action -> --trim-mode -- --default-action -> --action --- docs/illink-options.md | 4 +- docs/illink-tasks.md | 2 +- src/ILLink.Tasks/LinkTask.cs | 8 ++-- src/linker/Linker/Driver.cs | 44 ++++++++----------- test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs | 2 +- ...ute.cs => SetupLinkerTrimModeAttribute.cs} | 4 +- ...erDisplayAttributeOnAssemblyUsingTarget.cs | 2 +- ...ributeOnAssemblyUsingTargetOnUnusedType.cs | 2 +- ...emblyUsingTargetTypeNameInOtherAssembly.cs | 2 +- .../DebuggerDisplayAttributeOnType.cs | 2 +- ...ggerDisplayAttributeOnTypeThatIsNotUsed.cs | 2 +- ...layAttributeOnTypeWithNonExistentMethod.cs | 2 +- ...TypeProxyAttributeOnAssemblyUsingTarget.cs | 2 +- .../DebuggerTypeProxyAttributeOnType.cs | 2 +- ...erDisplayAttributeOnAssemblyUsingTarget.cs | 2 +- ...ributeOnAssemblyUsingTargetOnUnusedType.cs | 2 +- ...emblyUsingTargetTypeNameInOtherAssembly.cs | 2 +- ...semblyUsingTargetTypeNameInSameAssembly.cs | 2 +- ...getTypeNameOfGenericTypeInOtherAssembly.cs | 2 +- ...rgetTypeNameOfNestedTypeInOtherAssembly.cs | 2 +- .../DebuggerDisplayAttributeOnType.cs | 2 +- ...TypeProxyAttributeOnAssemblyUsingTarget.cs | 2 +- .../DebuggerTypeProxyAttributeOnType.cs | 2 +- .../CoreLibraryAssemblyAttributesAreKept.cs | 2 +- .../MarshalAsCustomMarshalerInterface.cs | 2 +- ...LibrarySecurityAttributeTypesAreRemoved.cs | 2 +- ...CoreLibrariesWithOnlyKeepUsedAttributes.cs | 2 +- ...braryUnusedAssemblyAttributesAreRemoved.cs | 2 +- ...oreLibraryUsedAssemblyAttributesAreKept.cs | 2 +- .../BCLFeatures/ETW/BaseRemovedEventSource.cs | 2 +- .../ETW/BaseRemovedEventSourceEmptyBody.cs | 2 +- .../BaseRemovedEventSourceNonVoidReturn.cs | 2 +- .../BCLFeatures/ETW/Excluded.cs | 2 +- .../ETW/LocalsOfModifiedMethodAreRemoved.cs | 2 +- .../ETW/StubbedMethodWithExceptionHandlers.cs | 2 +- .../ComponentModel/TypeConverterOnMembers.cs | 2 +- .../CoreLink/CanIncludeI18nAssemblies.cs | 2 +- .../CopyOfCoreLibrariesKeepsUnusedTypes.cs | 2 +- ...ndMulticastDelegateKeepInstantiatedReqs.cs | 2 +- ...stantiatedStructWithOverridesFromObject.cs | 2 +- ...InstantiatedTypeWithOverridesFromObject.cs | 2 +- ...kingOfCoreLibrariesRemovesUnusedMethods.cs | 2 +- ...inkingOfCoreLibrariesRemovesUnusedTypes.cs | 2 +- ...InstantiatedTypeWithOverridesFromObject.cs | 2 +- ...sAllSecurityAttributesFromCoreLibraries.cs | 2 +- .../PInvoke/Individual/CanOutputPInvokes.cs | 2 +- .../EmbeddedLinkAttributesInCorelib.cs | 2 +- ...rencesAreRemovedWhenAllUsagesAreRemoved.cs | 2 +- .../VerifyExpectModifiedAttributesWork.cs | 2 +- .../Individual/CanEnableReducedTracing.cs | 2 +- ...CanGenerateWarningSuppressionFileCSharp.cs | 2 +- .../CanGenerateWarningSuppressionFileXml.cs | 2 +- .../Warnings/Individual/WarningsAreSorted.cs | 2 +- .../TestCasesRunner/LinkerArgumentBuilder.cs | 10 ++--- .../TestCasesRunner/TestCaseLinkerOptions.cs | 2 +- .../TestCasesRunner/TestCaseMetadaProvider.cs | 2 +- .../TestCasesRunner/TestRunner.cs | 2 +- 57 files changed, 83 insertions(+), 91 deletions(-) rename test/Mono.Linker.Tests.Cases.Expectations/Metadata/{SetupLinkerTrimActionAttribute.cs => SetupLinkerTrimModeAttribute.cs} (66%) diff --git a/docs/illink-options.md b/docs/illink-options.md index 7e84d660b515..edd02d7cc7e1 100644 --- a/docs/illink-options.md +++ b/docs/illink-options.md @@ -72,11 +72,11 @@ A trimmable assembly is any assembly that includes the attribute `System.Reflect You can specify what action to do on the trimmed assemblies with the option: -`--trim-action skip|copy|copyused|link` +`--trim-mode skip|copy|copyused|link` You can specify what action to do on assemblies without such an attribute with the option: -`--default-action copy|link` +`--action copy|link` ### The output directory diff --git a/docs/illink-tasks.md b/docs/illink-tasks.md index 1ff92c1ee3d1..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 --trim-action link" /> + ExtraArgs="-t --trim-mode link" /> ``` ## Default Linking Behavior diff --git a/src/ILLink.Tasks/LinkTask.cs b/src/ILLink.Tasks/LinkTask.cs index 8d82b33f342a..164972dcd035 100644 --- a/src/ILLink.Tasks/LinkTask.cs +++ b/src/ILLink.Tasks/LinkTask.cs @@ -181,13 +181,13 @@ public class ILLink : ToolTask /// /// Sets the default action for trimmable assemblies. - /// Maps to '--trim-action' + /// Maps to '--trim-mode' /// public string TrimMode { get; set; } /// /// Sets the default action for assemblies which have not opted into trimming. - /// Maps to '--default-action' + /// Maps to '--action' public string DefaultAction { get; set; } /// @@ -401,10 +401,10 @@ protected override string GenerateResponseFileCommands () args.AppendLine ("-b"); if (TrimMode != null) - args.Append ("--trim-action ").AppendLine (TrimMode); + args.Append ("--trim-mode ").AppendLine (TrimMode); if (DefaultAction != null) - args.Append ("--default-action ").AppendLine (DefaultAction); + args.Append ("--action ").AppendLine (DefaultAction); if (CustomSteps != null) { foreach (var customStep in CustomSteps) { diff --git a/src/linker/Linker/Driver.cs b/src/linker/Linker/Driver.cs index ecfe18ba952b..671a72113f95 100644 --- a/src/linker/Linker/Driver.cs +++ b/src/linker/Linker/Driver.cs @@ -262,16 +262,19 @@ protected int SetupContext (ILogger customLogger = null) continue; case "--action": { - if (arguments.Count < 2) { - ErrorMissingArgument (token); + AssemblyAction? action = null; + if (!GetStringParam (token, l => action = ParseAssemblyAction (l))) return -1; - } - var action = ParseAssemblyAction (arguments.Dequeue ()); if (action == null) return -1; - string assemblyName = arguments.Dequeue (); + string assemblyName = GetNextStringValue (); + if (assemblyName == null) { + context.DefaultAction = action.Value; + continue; + } + if (!IsValidAssemblyName (assemblyName)) { context.LogError ($"Invalid assembly name '{assemblyName}'", 1036); return -1; @@ -280,7 +283,7 @@ protected int SetupContext (ILogger customLogger = null) context.RegisterAssemblyAction (assemblyName, action.Value); continue; } - case "--trim-action": { + case "--trim-mode": { AssemblyAction? action = null; if (!GetStringParam (token, l => action = ParseAssemblyAction (l))) return -1; @@ -291,17 +294,6 @@ protected int SetupContext (ILogger customLogger = null) context.TrimAction = action.Value; continue; } - case "--default-action": { - AssemblyAction? action = null; - if (!GetStringParam (token, l => action = ParseAssemblyAction (l))) - return -1; - - if (action == null) - return -1; - - context.DefaultAction = action.Value; - continue; - } case "--custom-step": if (!GetStringParam (token, l => custom_steps.Push (l))) return -1; @@ -1086,15 +1078,15 @@ static void Usage () Console.WriteLine (); Console.WriteLine ("Actions"); - Console.WriteLine (" --trim-action ACTION Sets action for assemblies annotated as trimmable. 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 (" --default-action ACTION Sets action for assemblies that have no trimmability annotation. Defaults to 'link'"); - Console.WriteLine (" --action 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"); diff --git a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs index 5e4df169ce9f..363f7ba0d940 100644 --- a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs +++ b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs @@ -439,7 +439,7 @@ public void TestExtraArgs () { var task = new MockTask () { TrimMode = "copy", - ExtraArgs = "--trim-action link" + ExtraArgs = "--trim-mode link" }; using (var driver = task.CreateDriver ()) { Assert.Equal (AssemblyAction.Copy, driver.Context.DefaultAction); diff --git a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimActionAttribute.cs b/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimModeAttribute.cs similarity index 66% rename from test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimActionAttribute.cs rename to test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimModeAttribute.cs index 46c8bca43fbc..0d808ac0d27b 100644 --- a/test/Mono.Linker.Tests.Cases.Expectations/Metadata/SetupLinkerTrimActionAttribute.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 SetupLinkerTrimActionAttribute : BaseMetadataAttribute + public class SetupLinkerTrimModeAttribute : BaseMetadataAttribute { - public SetupLinkerTrimActionAttribute (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 eeea46c5307e..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 - [SetupLinkerTrimAction ("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 b431308839da..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 - [SetupLinkerTrimAction ("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 001da8417a9c..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 - [SetupLinkerTrimAction ("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 2e017cbae8b9..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 - [SetupLinkerTrimAction ("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 c712e6943375..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 - [SetupLinkerTrimAction ("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 e8002cd22611..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 - [SetupLinkerTrimAction ("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 be60c5a0fb9a..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 - [SetupLinkerTrimAction ("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 8bd7ae1d314c..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 - [SetupLinkerTrimAction ("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 2cb82afb2f42..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 { - [SetupLinkerTrimAction ("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 8de8987e3382..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 { - [SetupLinkerTrimAction ("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 61c7cdc4392a..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 { - [SetupLinkerTrimAction ("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 1f939907cb12..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 { - [SetupLinkerTrimAction ("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 45bca7ad7b38..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 { - [SetupLinkerTrimAction ("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 0c3182332d66..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 { - [SetupLinkerTrimAction ("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 ff44158dccba..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 { - [SetupLinkerTrimAction ("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 11a11d3e4911..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 { - [SetupLinkerTrimAction ("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 478858fdf77c..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 { - [SetupLinkerTrimAction ("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 7a46a7bdf614..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")] - [SetupLinkerTrimAction ("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 e3ec04187cee..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 { - [SetupLinkerTrimAction ("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 8f386b71a548..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 - [SetupLinkerTrimAction ("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 0f611ddfea9f..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 { - [SetupLinkerTrimAction ("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 9a9468afec78..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")] - [SetupLinkerTrimAction ("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 a83f5dbb75a0..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")] - [SetupLinkerTrimAction ("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 894cc6453621..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 - [SetupLinkerTrimAction ("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 ad4e016ac023..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 - [SetupLinkerTrimAction ("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 8d5a84d87a64..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 - [SetupLinkerTrimAction ("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 e70aac22a993..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 - [SetupLinkerTrimAction ("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 f1416d2353a1..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 - [SetupLinkerTrimAction ("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 3b9d65d04222..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 - [SetupLinkerTrimAction ("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 9d06c2f7d89d..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 - [SetupLinkerTrimAction ("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 4527c1f855c8..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 - [SetupLinkerTrimAction ("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/CopyOfCoreLibrariesKeepsUnusedTypes.cs b/test/Mono.Linker.Tests.Cases/CoreLink/CopyOfCoreLibrariesKeepsUnusedTypes.cs index 3bbc90c30c9f..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 { - [SetupLinkerTrimAction ("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 75b8827570cb..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 /// - [SetupLinkerTrimAction ("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/InstantiatedStructWithOverridesFromObject.cs b/test/Mono.Linker.Tests.Cases/CoreLink/InstantiatedStructWithOverridesFromObject.cs index e112b461c309..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 { - [SetupLinkerTrimAction ("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 a931fe96e0c6..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 { - [SetupLinkerTrimAction ("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/LinkingOfCoreLibrariesRemovesUnusedMethods.cs b/test/Mono.Linker.Tests.Cases/CoreLink/LinkingOfCoreLibrariesRemovesUnusedMethods.cs index adf43955b05d..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 - [SetupLinkerTrimAction ("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 b67a51e43f5d..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 - [SetupLinkerTrimAction ("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 00eada13dc5f..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 { - [SetupLinkerTrimAction ("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 3d93330d4b93..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 - [SetupLinkerTrimAction ("link")] + [SetupLinkerTrimMode ("link")] [SetupLinkerArgument ("--strip-security", "true")] [SetupLinkerArgument ("--used-attrs-only", "true")] [Reference ("System.dll")] 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 83e2c1d8c09f..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 - [SetupLinkerTrimAction ("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/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs b/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs index aa7a225c421e..4984c7c46060 100644 --- a/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs +++ b/test/Mono.Linker.Tests.Cases/LinkAttributes/EmbeddedLinkAttributesInCorelib.cs @@ -15,7 +15,7 @@ public class MockCorelibAttributeToRemove : Attribute namespace Mono.Linker.Tests.Cases.LinkAttributes { [IgnoreLinkAttributes (false)] - [SetupLinkerTrimAction ("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" } }, diff --git a/test/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs b/test/Mono.Linker.Tests.Cases/References/ReferencesAreRemovedWhenAllUsagesAreRemoved.cs index ac7ba844a106..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 - [SetupLinkerTrimAction ("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 f7a7978e7a27..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 - [SetupLinkerTrimAction ("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 6d502a14a63d..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 - [SetupLinkerTrimAction ("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/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs b/test/Mono.Linker.Tests.Cases/Warnings/Individual/CanGenerateWarningSuppressionFileCSharp.cs index d5eda4100466..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 { - [SetupLinkerTrimAction ("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 224b57e82c8e..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 { - [SetupLinkerTrimAction ("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 b5c62e73a02f..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] - [SetupLinkerTrimAction ("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 ed5609be15f5..b95fb0a14796 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/LinkerArgumentBuilder.cs @@ -42,15 +42,15 @@ public virtual void AddResponseFile (NPath path) Append ($"@{path}"); } - public virtual void AddTrimAction (string value) + public virtual void AddTrimMode (string value) { - Append ("--trim-action"); + Append ("--trim-mode"); Append (value); } public virtual void AddDefaultAction (string value) { - Append ("--default-action"); + Append ("--action"); Append (value); } @@ -194,8 +194,8 @@ public virtual void ProcessTestInputAssembly (NPath inputAssemblyPath) public virtual void ProcessOptions (TestCaseLinkerOptions options) { - if (options.TrimAssembliesAction != null) - AddTrimAction (options.TrimAssembliesAction); + if (options.TrimMode != null) + AddTrimMode (options.TrimMode); if (options.DefaultAssembliesAction != null) AddDefaultAction (options.DefaultAssembliesAction); diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs index a87ef2388d78..b51639d9da30 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseLinkerOptions.cs @@ -4,7 +4,7 @@ namespace Mono.Linker.Tests.TestCasesRunner { public class TestCaseLinkerOptions { - public string TrimAssembliesAction; + public string TrimMode; public string DefaultAssembliesAction; public List> AssembliesAction = new List> (); diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs index 80606220b4bc..e528328dffd4 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/TestCaseMetadaProvider.cs @@ -37,7 +37,7 @@ public virtual TestCaseLinkerOptions GetLinkerOptions (NPath inputPath) KeepTypeForwarderOnlyAssemblies = GetOptionAttributeValue (nameof (KeepTypeForwarderOnlyAssembliesAttribute), string.Empty), KeepDebugMembers = GetOptionAttributeValue (nameof (SetupLinkerKeepDebugMembersAttribute), string.Empty), LinkSymbols = GetOptionAttributeValue (nameof (SetupLinkerLinkSymbolsAttribute), string.Empty), - TrimAssembliesAction = GetOptionAttributeValue (nameof (SetupLinkerTrimActionAttribute), null), + TrimMode = GetOptionAttributeValue (nameof (SetupLinkerTrimModeAttribute), null), DefaultAssembliesAction = GetOptionAttributeValue (nameof (SetupLinkerDefaultActionAttribute), null), SkipUnresolved = GetOptionAttributeValue (nameof (SkipUnresolvedAttribute), false), StripDescriptors = GetOptionAttributeValue (nameof (StripDescriptorsAttribute), true), diff --git a/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs b/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs index 581db16654f3..44325138cc58 100644 --- a/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs +++ b/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs @@ -119,7 +119,7 @@ protected virtual void AddLinkOptions (TestCaseSandbox sandbox, ManagedCompilati if (ext == ".dll" || ext == ".exe") builder.AddReference (inputReference); } - var coreAction = caseDefinedOptions.TrimAssembliesAction ?? "skip"; + var coreAction = caseDefinedOptions.TrimMode ?? "skip"; foreach (var extraReference in metadataProvider.GetExtraLinkerReferences ()) { builder.AddReference (extraReference); builder.AddAssemblyAction (coreAction, extraReference.FileNameWithoutExtension); From 7e793f4d5f94d9ca08331b3725501fa0e40efe9e Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Wed, 17 Feb 2021 15:02:15 -0800 Subject: [PATCH 08/10] Fix ILLink.Tasks test --- test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs index 363f7ba0d940..27c99560d3b9 100644 --- a/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs +++ b/test/ILLink.Tasks.Tests/ILLink.Tasks.Tests.cs @@ -111,7 +111,7 @@ 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 referenceName = Path.GetFileName (reference); + var referenceName = Path.GetFileNameWithoutExtension (reference); var actualAction = driver.Context.Actions[referenceName]; Assert.Equal (AssemblyAction.Skip, actualAction); } @@ -439,12 +439,12 @@ public void TestExtraArgs () { var task = new MockTask () { TrimMode = "copy", - ExtraArgs = "--trim-mode link" + ExtraArgs = "--trim-mode copyused" }; using (var driver = task.CreateDriver ()) { - Assert.Equal (AssemblyAction.Copy, driver.Context.DefaultAction); + Assert.Equal (AssemblyAction.Link, driver.Context.DefaultAction); // Check that ExtraArgs can override TrimMode - Assert.Equal (AssemblyAction.Link, driver.Context.TrimAction); + Assert.Equal (AssemblyAction.CopyUsed, driver.Context.TrimAction); } } From f4fab057b2b75a00c5e0a29da9e600043a99b880 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Thu, 18 Feb 2021 11:35:57 -0800 Subject: [PATCH 09/10] PR feedback - Add plenty of comments - RootNonTrimmableAssemblies -> ProcessReferencesStep - Make -reference order stable using List instead of HashSet --- src/linker/Linker.Steps/MarkStep.cs | 2 +- ...Assemblies.cs => ProcessReferencesStep.cs} | 24 +++++++++++++++++-- src/linker/Linker/AssemblyResolver.cs | 13 +++++----- src/linker/Linker/Driver.cs | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) rename src/linker/Linker.Steps/{RootNonTrimmableAssemblies.cs => ProcessReferencesStep.cs} (56%) diff --git a/src/linker/Linker.Steps/MarkStep.cs b/src/linker/Linker.Steps/MarkStep.cs index 005ac0ac4a47..d2bd25430b29 100644 --- a/src/linker/Linker.Steps/MarkStep.cs +++ b/src/linker/Linker.Steps/MarkStep.cs @@ -1302,7 +1302,7 @@ protected void MarkAssembly (AssemblyDefinition assembly, DependencyInfo reason) MarkExportedTypesTarget.ProcessAssembly (assembly, _context); - if (RootNonTrimmableAssemblies.IsFullyPreservedAction (_context.Annotations.GetAction (assembly))) { + if (ProcessReferencesStep.IsFullyPreservedAction (_context.Annotations.GetAction (assembly))) { MarkEntireAssembly (assembly); return; } diff --git a/src/linker/Linker.Steps/RootNonTrimmableAssemblies.cs b/src/linker/Linker.Steps/ProcessReferencesStep.cs similarity index 56% rename from src/linker/Linker.Steps/RootNonTrimmableAssemblies.cs rename to src/linker/Linker.Steps/ProcessReferencesStep.cs index ecbc6a42b635..5baf93084c57 100644 --- a/src/linker/Linker.Steps/RootNonTrimmableAssemblies.cs +++ b/src/linker/Linker.Steps/ProcessReferencesStep.cs @@ -7,23 +7,43 @@ namespace Mono.Linker.Steps { - public class RootNonTrimmableAssemblies : BaseStep + public class ProcessReferencesStep : BaseStep { protected override void Process () { - // Walk over all -reference inputs and resolve any that may need to be rooted + // 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)); } diff --git a/src/linker/Linker/AssemblyResolver.cs b/src/linker/Linker/AssemblyResolver.cs index 08d062c11751..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 HashSet _references; + readonly List _references; public IDictionary AssemblyCache { @@ -57,7 +56,7 @@ public AssemblyResolver () public AssemblyResolver (Dictionary assembly_cache) { _assemblies = assembly_cache; - _references = new HashSet () { }; + _references = new List () { }; } public bool IgnoreUnresolved { @@ -80,9 +79,9 @@ public string GetAssemblyFileName (AssemblyDefinition assembly) return assembly.MainModule.FileName; } - AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, HashSet references, ReaderParameters parameters) + AssemblyDefinition ResolveFromReferences (AssemblyNameReference name, ReaderParameters parameters) { - foreach (var reference in references) { + foreach (var reference in _references) { foreach (var extension in DirectoryAssemblyResolver.Extensions) { var fileName = name.Name + extension; if (Path.GetFileName (reference) != fileName) @@ -109,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) @@ -141,7 +140,7 @@ public void AddReferenceAssembly (string referencePath) _references.Add (referencePath); } - public HashSet GetReferencePaths () + public List GetReferencePaths () { return _references; } diff --git a/src/linker/Linker/Driver.cs b/src/linker/Linker/Driver.cs index 671a72113f95..59c73b8a6321 100644 --- a/src/linker/Linker/Driver.cs +++ b/src/linker/Linker/Driver.cs @@ -1160,7 +1160,7 @@ static void About () static Pipeline GetStandardPipeline () { Pipeline p = new Pipeline (); - p.AppendStep (new RootNonTrimmableAssemblies ()); + p.AppendStep (new ProcessReferencesStep ()); p.AppendStep (new MarkStep ()); p.AppendStep (new RemoveResourcesStep ()); p.AppendStep (new ValidateVirtualMethodAnnotationsStep ()); From bbb7b6859c3cb41778c0420a56896101ad412798 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Fri, 19 Feb 2021 09:21:35 -0800 Subject: [PATCH 10/10] PR feedback Make GetInputAssemblyPaths private --- src/linker/Linker.Steps/ProcessReferencesStep.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linker/Linker.Steps/ProcessReferencesStep.cs b/src/linker/Linker.Steps/ProcessReferencesStep.cs index 5baf93084c57..4c329b37ca2d 100644 --- a/src/linker/Linker.Steps/ProcessReferencesStep.cs +++ b/src/linker/Linker.Steps/ProcessReferencesStep.cs @@ -49,7 +49,7 @@ protected override void Process () } } - public IEnumerable GetInputAssemblyPaths () + IEnumerable GetInputAssemblyPaths () { var assemblies = new HashSet (); foreach (var referencePath in Context.Resolver.GetReferencePaths ()) {