public static string GenerateBlackList(string librariesFolder, RuntimeClassRegistry usedClasses, string[] allAssemblies) { string text = "tmplink.xml"; usedClasses.SynchronizeClasses(); using (TextWriter textWriter = new StreamWriter(Path.Combine(librariesFolder, text))) { textWriter.WriteLine("<linker>"); textWriter.WriteLine("<assembly fullname=\"UnityEngine\">"); foreach (string current in usedClasses.GetAllManagedClassesAsString()) { textWriter.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", current, usedClasses.GetRetentionLevel(current))); } textWriter.WriteLine("</assembly>"); DefaultAssemblyResolver defaultAssemblyResolver = new DefaultAssemblyResolver(); defaultAssemblyResolver.AddSearchDirectory(librariesFolder); for (int i = 0; i < allAssemblies.Length; i++) { string path = allAssemblies[i]; AssemblyDefinition assemblyDefinition = defaultAssemblyResolver.Resolve(Path.GetFileNameWithoutExtension(path), new ReaderParameters { AssemblyResolver = defaultAssemblyResolver }); textWriter.WriteLine("<assembly fullname=\"{0}\">", assemblyDefinition.Name.Name); MonoAssemblyStripping.GenerateBlackListTypeXML(textWriter, assemblyDefinition.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString()); textWriter.WriteLine("</assembly>"); } textWriter.WriteLine("</linker>"); } return text; }
public static string GenerateBlackList(string librariesFolder, RuntimeClassRegistry usedClasses, string[] allAssemblies) { string str = "tmplink.xml"; usedClasses.SynchronizeClasses(); using (TextWriter writer = new StreamWriter(Path.Combine(librariesFolder, str))) { writer.WriteLine("<linker>"); writer.WriteLine("<assembly fullname=\"UnityEngine\">"); foreach (string str2 in usedClasses.GetAllManagedClassesAsString()) { writer.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", str2, usedClasses.GetRetentionLevel(str2))); } writer.WriteLine("</assembly>"); DefaultAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(librariesFolder); foreach (string str3 in allAssemblies) { ReaderParameters parameters = new ReaderParameters { AssemblyResolver = resolver }; AssemblyDefinition definition = resolver.Resolve(Path.GetFileNameWithoutExtension(str3), parameters); writer.WriteLine("<assembly fullname=\"{0}\">", definition.Name.Name); if (definition.Name.Name.StartsWith("UnityEngine.")) { foreach (string str4 in usedClasses.GetAllManagedClassesAsString()) { writer.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", str4, usedClasses.GetRetentionLevel(str4))); } } GenerateBlackListTypeXML(writer, definition.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString()); writer.WriteLine("</assembly>"); } writer.WriteLine("</linker>"); } return str; }
public static string GenerateBlackList(string librariesFolder, RuntimeClassRegistry usedClasses, string[] allAssemblies) { string text = "tmplink.xml"; usedClasses.SynchronizeClasses(); using (TextWriter textWriter = new StreamWriter(Path.Combine(librariesFolder, text))) { textWriter.WriteLine("<linker>"); textWriter.WriteLine("<assembly fullname=\"UnityEngine\">"); foreach (string current in usedClasses.GetAllManagedClassesAsString()) { textWriter.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", current, usedClasses.GetRetentionLevel(current))); } textWriter.WriteLine("</assembly>"); DefaultAssemblyResolver defaultAssemblyResolver = new DefaultAssemblyResolver(); defaultAssemblyResolver.AddSearchDirectory(librariesFolder); for (int i = 0; i < allAssemblies.Length; i++) { string path = allAssemblies[i]; AssemblyDefinition assemblyDefinition = defaultAssemblyResolver.Resolve(Path.GetFileNameWithoutExtension(path), new ReaderParameters { AssemblyResolver = defaultAssemblyResolver }); textWriter.WriteLine("<assembly fullname=\"{0}\">", assemblyDefinition.Name.Name); if (assemblyDefinition.Name.Name.StartsWith("UnityEngine.")) { foreach (string current2 in usedClasses.GetAllManagedClassesAsString()) { textWriter.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", current2, usedClasses.GetRetentionLevel(current2))); } } MonoAssemblyStripping.GenerateBlackListTypeXML(textWriter, assemblyDefinition.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString()); textWriter.WriteLine("</assembly>"); } textWriter.WriteLine("</linker>"); } return(text); }
public static string GenerateBlackList(string librariesFolder, RuntimeClassRegistry usedClasses, string[] allAssemblies) { string str = "tmplink.xml"; usedClasses.SynchronizeClasses(); using (TextWriter writer = new StreamWriter(Path.Combine(librariesFolder, str))) { writer.WriteLine("<linker>"); writer.WriteLine("<assembly fullname=\"UnityEngine\">"); foreach (string str2 in usedClasses.GetAllManagedClassesAsString()) { writer.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", str2, usedClasses.GetRetentionLevel(str2))); } writer.WriteLine("</assembly>"); DefaultAssemblyResolver resolver = new DefaultAssemblyResolver(); resolver.AddSearchDirectory(librariesFolder); foreach (string str3 in allAssemblies) { ReaderParameters parameters = new ReaderParameters { AssemblyResolver = resolver }; AssemblyDefinition definition = resolver.Resolve(Path.GetFileNameWithoutExtension(str3), parameters); writer.WriteLine("<assembly fullname=\"{0}\">", definition.Name.Name); if (definition.Name.Name.StartsWith("UnityEngine.")) { foreach (string str4 in usedClasses.GetAllManagedClassesAsString()) { writer.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", str4, usedClasses.GetRetentionLevel(str4))); } } GenerateBlackListTypeXML(writer, definition.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString()); writer.WriteLine("</assembly>"); } writer.WriteLine("</linker>"); } return(str); }
public static string GenerateBlackList(string librariesFolder, RuntimeClassRegistry usedClasses, string[] allAssemblies) { string path2 = "tmplink.xml"; usedClasses.SynchronizeClasses(); using (TextWriter w = (TextWriter) new StreamWriter(Path.Combine(librariesFolder, path2))) { w.WriteLine("<linker>"); w.WriteLine("<assembly fullname=\"UnityEngine\">"); using (List <string> .Enumerator enumerator = usedClasses.GetAllManagedClassesAsString().GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; w.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", (object)current, (object)usedClasses.GetRetentionLevel(current))); } } w.WriteLine("</assembly>"); DefaultAssemblyResolver assemblyResolver1 = new DefaultAssemblyResolver(); ((BaseAssemblyResolver)assemblyResolver1).AddSearchDirectory(librariesFolder); foreach (string allAssembly in allAssemblies) { DefaultAssemblyResolver assemblyResolver2 = assemblyResolver1; string withoutExtension = Path.GetFileNameWithoutExtension(allAssembly); ReaderParameters readerParameters1 = new ReaderParameters(); readerParameters1.set_AssemblyResolver((IAssemblyResolver)assemblyResolver1); ReaderParameters readerParameters2 = readerParameters1; AssemblyDefinition assemblyDefinition = ((BaseAssemblyResolver)assemblyResolver2).Resolve(withoutExtension, readerParameters2); w.WriteLine("<assembly fullname=\"{0}\">", (object)((AssemblyNameReference)assemblyDefinition.get_Name()).get_Name()); if (((AssemblyNameReference)assemblyDefinition.get_Name()).get_Name().StartsWith("UnityEngine.")) { using (List <string> .Enumerator enumerator = usedClasses.GetAllManagedClassesAsString().GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; w.WriteLine(string.Format("<type fullname=\"UnityEngine.{0}\" preserve=\"{1}\"/>", (object)current, (object)usedClasses.GetRetentionLevel(current))); } } } MonoAssemblyStripping.GenerateBlackListTypeXML(w, (IList <TypeDefinition>)assemblyDefinition.get_MainModule().get_Types(), usedClasses.GetAllManagedBaseClassesAsString()); w.WriteLine("</assembly>"); } w.WriteLine("</linker>"); } return(path2); }