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 void GenerateRegisterModules(RuntimeClassRegistry allClasses, TextWriter output, bool strippingEnabled) { allClasses.SynchronizeClasses(); HashSet <string> modulesToRegister = CodeStrippingUtils.GetNativeModulesToRegister(!strippingEnabled ? (HashSet <string>)null : new HashSet <string>((IEnumerable <string>)allClasses.GetAllNativeClassesAsString())); modulesToRegister.Add("IMGUI"); using (HashSet <string> .Enumerator enumerator = modulesToRegister.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; output.WriteLine("\textern \"C\" void RegisterModule_" + current + "();"); } } output.WriteLine("void RegisterStaticallyLinkedModules()"); output.WriteLine("{"); using (HashSet <string> .Enumerator enumerator = modulesToRegister.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; output.WriteLine("\tRegisterModule_" + current + "();"); } } output.WriteLine("}"); }
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 void GenerateRegisterClassesForStripping(RuntimeClassRegistry allClasses, TextWriter output) { output.Write("void RegisterAllClasses() \n{\n"); allClasses.SynchronizeClasses(); foreach (string str in allClasses.GetAllNativeClassesAsString()) { output.WriteLine(string.Format("extern int RegisterClass_{0}();\nRegisterClass_{0}();", str)); } output.Write("\n}\n"); }
public static void GenerateRegisterClassesForStripping(RuntimeClassRegistry allClasses, TextWriter output) { output.Write("void RegisterAllClasses() \n{\n"); allClasses.SynchronizeClasses(); using (List <string> .Enumerator enumerator = allClasses.GetAllNativeClassesAsString().GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; output.WriteLine(string.Format("extern int RegisterClass_{0}();\nRegisterClass_{0}();", (object)current)); } } output.Write("\n}\n"); }
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); }
public static void GenerateRegisterModules(RuntimeClassRegistry allClasses, TextWriter output, bool strippingEnabled) { allClasses.SynchronizeClasses(); HashSet <string> nativeClasses = !strippingEnabled ? null : new HashSet <string>(allClasses.GetAllNativeClassesAsString()); HashSet <string> nativeModulesToRegister = CodeStrippingUtils.GetNativeModulesToRegister(nativeClasses); nativeModulesToRegister.Add("IMGUI"); foreach (string str in nativeModulesToRegister) { output.WriteLine("\textern \"C\" void RegisterModule_" + str + "();"); } output.WriteLine("void RegisterStaticallyLinkedModules()"); output.WriteLine("{"); foreach (string str2 in nativeModulesToRegister) { output.WriteLine("\tRegisterModule_" + str2 + "();"); } output.WriteLine("}"); }
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 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 void GenerateRegisterClassesForStripping(RuntimeClassRegistry allClasses, TextWriter output) { output.Write("void RegisterAllClasses() \n{\n"); allClasses.SynchronizeClasses(); using (List<string>.Enumerator enumerator = allClasses.GetAllNativeClassesAsString().GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; output.WriteLine(string.Format("extern int RegisterClass_{0}();\nRegisterClass_{0}();", (object) current)); } } output.Write("\n}\n"); }
public static void GenerateRegisterModules(RuntimeClassRegistry allClasses, TextWriter output, bool strippingEnabled) { allClasses.SynchronizeClasses(); HashSet<string> modulesToRegister = CodeStrippingUtils.GetNativeModulesToRegister(!strippingEnabled ? (HashSet<string>) null : new HashSet<string>((IEnumerable<string>) allClasses.GetAllNativeClassesAsString())); modulesToRegister.Add("IMGUI"); using (HashSet<string>.Enumerator enumerator = modulesToRegister.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; output.WriteLine("\textern \"C\" void RegisterModule_" + current + "();"); } } output.WriteLine("void RegisterStaticallyLinkedModules()"); output.WriteLine("{"); using (HashSet<string>.Enumerator enumerator = modulesToRegister.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.Current; output.WriteLine("\tRegisterModule_" + current + "();"); } } output.WriteLine("}"); }
public static void GenerateRegisterClassesForStripping(RuntimeClassRegistry allClasses, TextWriter output) { output.Write("void RegisterAllClasses() \n{\n"); allClasses.SynchronizeClasses(); foreach (string current in allClasses.GetAllNativeClassesAsString()) { output.WriteLine(string.Format("extern int RegisterClass_{0}();\nRegisterClass_{0}();", current)); } output.Write("\n}\n"); }