[linker] keep types in the module when sweeping them
authorJb Evain <jbevain@gmail.com>
Mon, 2 May 2011 11:56:39 +0000 (13:56 +0200)
committerJb Evain <jbevain@gmail.com>
Mon, 2 May 2011 11:56:39 +0000 (13:56 +0200)
mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs

index 371f0496fa79253b16a7b3921365191fa666d34c..d0dd00910be1d52c676c115c95da865d79f9dc68 100644 (file)
@@ -30,6 +30,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using Mono.Cecil;
+using Mono.Collections.Generic;
 
 namespace Mono.Linker.Steps {
 
@@ -54,12 +55,9 @@ namespace Mono.Linker.Steps {
                                return;
                        }
 
-                       var types = assembly.MainModule.Types;
-                       var cloned_types = new List<TypeDefinition> (types);
+                       var types = new List<TypeDefinition> ();
 
-                       types.Clear ();
-
-                       foreach (TypeDefinition type in cloned_types) {
+                       foreach (TypeDefinition type in assembly.MainModule.Types) {
                                if (Annotations.IsMarked (type)) {
                                        SweepType (type);
                                        types.Add (type);
@@ -69,6 +67,10 @@ namespace Mono.Linker.Steps {
                                if (type.Name == "<Module>")
                                        types.Add (type);
                        }
+
+                       assembly.MainModule.Types.Clear ();
+                       foreach (TypeDefinition type in types)
+                               assembly.MainModule.Types.Add (type);
                }
 
                bool IsMarkedAssembly (AssemblyDefinition assembly)
@@ -102,11 +104,6 @@ namespace Mono.Linker.Steps {
                        }
                }
 
-               static ICollection Clone (ICollection collection)
-               {
-                       return new ArrayList (collection);
-               }
-
                void SweepType (TypeDefinition type)
                {
                        if (type.HasFields)