2 using System.Collections;
3 using System.Collections.Generic;
8 using Mono.Linker.Steps;
13 namespace Mono.Tuner {
15 public class CustomizeActions : BaseStep {
17 readonly bool link_sdk_only;
18 readonly HashSet<string> skipped_assemblies;
20 public CustomizeActions (bool link_sdk_only, IEnumerable<string> skipped_assemblies)
22 this.link_sdk_only = link_sdk_only;
23 this.skipped_assemblies = new HashSet<string> (skipped_assemblies);
26 protected override void ProcessAssembly (AssemblyDefinition assembly)
28 if (!IsSkipped (assembly) && IsLinked (assembly)) {
29 if (!Annotations.HasAction (assembly)) // stray assembly not picked up when resolving references
30 Annotations.SetAction (assembly, AssemblyAction.Link);
33 ProcessUserAssembly (assembly);
36 protected virtual bool IsPreservedAttribute (CustomAttribute attribute)
38 return (attribute.AttributeType.Name == "PreserveAttribute");
41 protected virtual bool IsLinkerSafeAttribute (CustomAttribute attribute)
43 return (attribute.AttributeType.Name == "LinkerSafeAttribute");
46 protected virtual bool IsSkipped (AssemblyDefinition assembly)
48 if (assembly.HasCustomAttributes) {
49 foreach (var ca in assembly.CustomAttributes) {
50 if (IsPreservedAttribute (ca))
54 return skipped_assemblies.Contains (assembly.Name.Name);
57 protected virtual bool IsLinked (AssemblyDefinition assembly)
62 // Link SDK : applies to BCL/SDK and product assembly (e.g. monotouch.dll)
63 if (Profile.IsSdkAssembly (assembly))
65 if (Profile.IsProductAssembly (assembly))
67 // the assembly can be marked with [LinkAssembly]
68 if (assembly.HasCustomAttributes) {
69 foreach (var ca in assembly.CustomAttributes) {
70 if (IsLinkerSafeAttribute (ca))
77 protected void ProcessUserAssembly (AssemblyDefinition assembly)
79 ResolveFromAssemblyStep.ProcessLibrary (Context, assembly);