public static string GenerateLinkXmlToPreserveDerivedTypes(string stagingArea, string librariesFolder, RuntimeClassRegistry usedClasses) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type MonoAssemblyStripping.\u003CGenerateLinkXmlToPreserveDerivedTypes\u003Ec__AnonStorey6C typesCAnonStorey6C = new MonoAssemblyStripping.\u003CGenerateLinkXmlToPreserveDerivedTypes\u003Ec__AnonStorey6C(); // ISSUE: reference to a compiler-generated field typesCAnonStorey6C.usedClasses = usedClasses; string fullPath = Path.GetFullPath(Path.Combine(stagingArea, "preserved_derived_types.xml")); // ISSUE: reference to a compiler-generated field typesCAnonStorey6C.resolver = new DefaultAssemblyResolver(); // ISSUE: reference to a compiler-generated field ((BaseAssemblyResolver)typesCAnonStorey6C.resolver).AddSearchDirectory(librariesFolder); using (TextWriter textWriter = (TextWriter) new StreamWriter(fullPath)) { textWriter.WriteLine("<linker>"); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated method // ISSUE: reference to a compiler-generated method using (HashSet <AssemblyDefinition> .Enumerator enumerator1 = MonoAssemblyStripping.CollectAssembliesRecursive(((IEnumerable <string>)typesCAnonStorey6C.usedClasses.GetUserAssemblies()).Where <string>(new Func <string, bool>(typesCAnonStorey6C.\u003C\u003Em__EC)).Select <string, AssemblyDefinition>(new Func <string, AssemblyDefinition>(typesCAnonStorey6C.\u003C\u003Em__ED))).GetEnumerator()) { while (enumerator1.MoveNext()) { AssemblyDefinition current1 = enumerator1.Current; if (!(((AssemblyNameReference)current1.get_Name()).get_Name() == "UnityEngine")) { HashSet <TypeDefinition> typesToPreserve = new HashSet <TypeDefinition>(); // ISSUE: reference to a compiler-generated field MonoAssemblyStripping.CollectBlackListTypes(typesToPreserve, (IList <TypeDefinition>)current1.get_MainModule().get_Types(), typesCAnonStorey6C.usedClasses.GetAllManagedBaseClassesAsString()); if (typesToPreserve.Count != 0) { textWriter.WriteLine("<assembly fullname=\"{0}\">", (object)((AssemblyNameReference)current1.get_Name()).get_Name()); using (HashSet <TypeDefinition> .Enumerator enumerator2 = typesToPreserve.GetEnumerator()) { while (enumerator2.MoveNext()) { TypeDefinition current2 = enumerator2.Current; textWriter.WriteLine("<type fullname=\"{0}\" preserve=\"all\"/>", (object)((TypeReference)current2).get_FullName()); } } textWriter.WriteLine("</assembly>"); } } } } textWriter.WriteLine("</linker>"); } return(fullPath); }
public static IEnumerable <AssemblyDefinition> CollectAllAssemblies(string librariesFolder, RuntimeClassRegistry usedClasses) { DefaultAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.RemoveSearchDirectory("."); resolver.RemoveSearchDirectory("bin"); resolver.AddSearchDirectory(librariesFolder); IEnumerable <AssemblyNameReference> source = from s in usedClasses.GetUserAssemblies() where usedClasses.IsDLLUsed(s) select s into file select AssemblyNameReference.Parse(Path.GetFileNameWithoutExtension(file)); return(MonoAssemblyStripping.CollectAssembliesRecursive(from dll in source select MonoAssemblyStripping.ResolveAssemblyReference(resolver, dll) into a where a != null select a)); }
public static string GenerateLinkXmlToPreserveDerivedTypes(string stagingArea, string librariesFolder, RuntimeClassRegistry usedClasses) { string fullPath = Path.GetFullPath(Path.Combine(stagingArea, "preserved_derived_types.xml")); DefaultAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(librariesFolder); using (TextWriter textWriter = new StreamWriter(fullPath)) { textWriter.WriteLine("<linker>"); foreach (AssemblyDefinition current in MonoAssemblyStripping.CollectAssembliesRecursive((from s in usedClasses.GetUserAssemblies() where usedClasses.IsDLLUsed(s) select s).Select(delegate(string file) { BaseAssemblyResolver arg_1F_0 = resolver; string arg_1F_1 = Path.GetFileNameWithoutExtension(file); ReaderParameters readerParameters = new ReaderParameters(); readerParameters.set_AssemblyResolver(resolver); return(arg_1F_0.Resolve(arg_1F_1, readerParameters)); }))) { if (!(current.get_Name().get_Name() == "UnityEngine")) { HashSet <TypeDefinition> hashSet = new HashSet <TypeDefinition>(); MonoAssemblyStripping.CollectBlackListTypes(hashSet, current.get_MainModule().get_Types(), usedClasses.GetAllManagedBaseClassesAsString()); if (hashSet.Count != 0) { textWriter.WriteLine("<assembly fullname=\"{0}\">", current.get_Name().get_Name()); foreach (TypeDefinition current2 in hashSet) { textWriter.WriteLine("<type fullname=\"{0}\" preserve=\"all\"/>", current2.get_FullName()); } textWriter.WriteLine("</assembly>"); } } } textWriter.WriteLine("</linker>"); } return(fullPath); }