private bool Build(ref TypeReference typeRef, BuildType type) { bool changed = false; // Name string name; if (type.NameChanged) { name = type.NewName; changed = true; } else { name = type.Name; } // Namespace string ns; if (type.NamespaceChanged) { ns = type.NewNamespace; changed = true; } else { ns = type.Namespace; } // Owner var owner = typeRef.Owner; if (type.IsNested) { var enclosingTypeRef = (TypeReference)owner; var enclosingType = (BuildType)type.GetEnclosingType(); if (Build(ref enclosingTypeRef, enclosingType)) { owner = enclosingTypeRef; changed = true; } } else if (owner != null) { changed |= Build(ref owner); } if (!changed) return false; bool isValueType = typeRef.IsValueType.HasValue ? typeRef.IsValueType.Value : type.IsValueType(); typeRef = new TypeReference(name, ns, owner, isValueType); return true; }
private void Process(BuildType type) { if (type.IsNested) { UnstripAndEnqueue((BuildType)type.GetEnclosingType()); } // Enqueue members dependent on this type. // .ctor, .cctor, virtual methods, enum fields, ... foreach (BuildMethod method in type.Methods) { if (method.Strip && !CanStrip(method)) { UnstripAndEnqueue(method); } } if (type.IsValueType()) { foreach (BuildField field in type.Fields) { UnstripAndEnqueue(field); } } // Process references var module = type.Module; if (type.BaseType != null) { Process(type.BaseType, module); } Process(type.Interfaces, module); Process(type.GenericParameters, module); Process(type.CustomAttributes, module); Process(type.SecurityAttributes, module); }