CleanType (type);
}
- static bool CheckType (ModuleDefinition module, TypeReference reference)
- {
- TypeSpecification spec = reference as TypeSpecification;
- if (spec != null)
- return CheckType (module, spec.ElementType);
-
- TypeDefinition type = reference as TypeDefinition;
- if (type == null)
- return true;
-
- return module.Types.Contains (type);
- }
-
static void CleanType (TypeDefinition type)
{
if (type.HasProperties)
CleanProperties (type);
if (type.HasEvents)
CleanEvents (type);
+
+ if (type.HasNestedTypes)
+ foreach (var nested in type.NestedTypes)
+ CleanType (nested);
}
static MethodDefinition CheckMethod (TypeDefinition type, MethodDefinition method)
InitializeFields (type);
if (type.HasMethods)
InitializeMethods (type.Methods);
+
+ if (type.HasNestedTypes)
+ foreach (var nested in type.NestedTypes)
+ InitializeType (nested);
}
void InitializeFields (TypeDefinition type)
{
context.Annotations.SetAction (assembly, AssemblyAction.Copy);
- foreach (TypeDefinition type in assembly.MainModule.Types) {
- context.Annotations.Mark (type);
+ foreach (TypeDefinition type in assembly.MainModule.Types)
+ MarkType (context, type);
+ }
- if (type.HasFields)
- MarkFields (context, type.Fields);
- if (type.HasMethods)
- MarkMethods (context, type.Methods);
- }
+ static void MarkType (LinkContext context, TypeDefinition type)
+ {
+ context.Annotations.Mark (type);
+
+ if (type.HasFields)
+ MarkFields (context, type.Fields);
+ if (type.HasMethods)
+ MarkMethods (context, type.Methods);
+ if (type.HasNestedTypes)
+ foreach (var nested in type.NestedTypes)
+ MarkType (context, nested);
}
void ProcessExecutable (AssemblyDefinition assembly)
types.Add (type);
continue;
}
+
+ if (type.Name == "<Module>")
+ types.Add (type);
}
}
if (Annotations.IsMarked (nested)) {
SweepType (nested);
} else {
- //type.NestedTypes.RemoveAt (i--);
+ type.NestedTypes.RemoveAt (i--);
}
}
}
{
MapVirtualMethods (type);
MapInterfaceMethodsInTypeHierarchy (type);
+
+ if (!type.HasNestedTypes)
+ return;
+
+ foreach (var nested in type.NestedTypes)
+ MapType (nested);
}
void MapInterfaceMethodsInTypeHierarchy (TypeDefinition type)