GetAllManagedBaseClassesAsString() public method

public GetAllManagedBaseClassesAsString ( ) : List
return List
		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 GenerateLinkXmlToPreserveDerivedTypes(string librariesFolder, RuntimeClassRegistry usedClasses)
        {
            var  sb = new StringBuilder();
            bool wrotePreservations = false;

            sb.AppendLine("<linker>");
            foreach (var assembly in CollectAllAssemblies(librariesFolder, usedClasses))
            {
                if (AssemblyHelper.IsUnityEngineModule(assembly))
                {
                    continue;
                }

                var typesToPreserve = new HashSet <TypeDefinition>();
                CollectBlackListTypes(typesToPreserve, assembly.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString());

                // don't write out xml file for assemblies with no types since link.xml files on disk have special meaning to IL2CPP stripping
                if (typesToPreserve.Count == 0)
                {
                    continue;
                }

                wrotePreservations = true;

                sb.AppendLine(string.Format("<assembly fullname=\"{0}\">", assembly.Name.Name));
                foreach (var typeToPreserve in typesToPreserve)
                {
                    sb.AppendLine(string.Format("<type fullname=\"{0}\" preserve=\"all\"/>", typeToPreserve.FullName));
                }
                sb.AppendLine("</assembly>");
            }
            sb.AppendLine("</linker>");

            // Don't generate and pass xml files that are empty.  While they are harmless, they are noisey and just cause useless clutter
            if (!wrotePreservations)
            {
                return(null);
            }

            string path = Path.GetTempFileName();

            File.WriteAllText(path, sb.ToString());
            return(path);
        }
        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);
        }
示例#4
0
        public static string GenerateLinkXmlToPreserveDerivedTypes(string librariesFolder, RuntimeClassRegistry usedClasses)
        {
            string path = Path.GetTempFileName();

            using (TextWriter w = new StreamWriter(path))
            {
                w.WriteLine("<linker>");
                foreach (var assembly in CollectAllAssemblies(librariesFolder, usedClasses))
                {
                    if (AssemblyHelper.IsUnityEngineModule(assembly))
                    {
                        continue;
                    }

                    var typesToPreserve = new HashSet <TypeDefinition>();
                    CollectBlackListTypes(typesToPreserve, assembly.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString());

                    // don't write out xml file for assemblies with no types since link.xml files on disk have special meaning to IL2CPP stripping
                    if (typesToPreserve.Count == 0)
                    {
                        continue;
                    }

                    w.WriteLine("<assembly fullname=\"{0}\">", assembly.Name.Name);
                    foreach (var typeToPreserve in typesToPreserve)
                    {
                        w.WriteLine("<type fullname=\"{0}\" preserve=\"all\"/>", typeToPreserve.FullName);
                    }
                    w.WriteLine("</assembly>");
                }
                w.WriteLine("</linker>");
            }

            return(path);
        }
        public static string GenerateLinkXmlToPreserveDerivedTypes(string librariesFolder, RuntimeClassRegistry usedClasses)
        {
            string tempFileName = Path.GetTempFileName();

            using (TextWriter textWriter = new StreamWriter(tempFileName))
            {
                textWriter.WriteLine("<linker>");
                foreach (AssemblyDefinition current in MonoAssemblyStripping.CollectAllAssemblies(librariesFolder, usedClasses))
                {
                    if (!AssemblyHelper.IsUnityEngineModule(current))
                    {
                        HashSet <TypeDefinition> hashSet = new HashSet <TypeDefinition>();
                        MonoAssemblyStripping.CollectBlackListTypes(hashSet, current.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString());
                        if (hashSet.Count != 0)
                        {
                            textWriter.WriteLine("<assembly fullname=\"{0}\">", current.Name.Name);
                            foreach (TypeDefinition current2 in hashSet)
                            {
                                textWriter.WriteLine("<type fullname=\"{0}\" preserve=\"all\"/>", current2.FullName);
                            }
                            textWriter.WriteLine("</assembly>");
                        }
                    }
                }
                textWriter.WriteLine("</linker>");
            }
            return(tempFileName);
        }
示例#6
0
        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 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 into file
                                                                                                        select resolver.Resolve(Path.GetFileNameWithoutExtension(file), new ReaderParameters
                {
                    AssemblyResolver = resolver
                })))
                {
                    if (!(current.Name.Name == "UnityEngine"))
                    {
                        HashSet <TypeDefinition> hashSet = new HashSet <TypeDefinition>();
                        MonoAssemblyStripping.CollectBlackListTypes(hashSet, current.MainModule.Types, usedClasses.GetAllManagedBaseClassesAsString());
                        if (hashSet.Count != 0)
                        {
                            textWriter.WriteLine("<assembly fullname=\"{0}\">", current.Name.Name);
                            foreach (TypeDefinition current2 in hashSet)
                            {
                                textWriter.WriteLine("<type fullname=\"{0}\" preserve=\"all\"/>", current2.FullName);
                            }
                            textWriter.WriteLine("</assembly>");
                        }
                    }
                }
                textWriter.WriteLine("</linker>");
            }
            return(fullPath);
        }
 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);
        }