예제 #1
0
        public static void GenerateDependencies(string strippedAssemblyDir, string icallsListFile, RuntimeClassRegistry rcr, out HashSet <string> nativeClasses, out HashSet <string> nativeModules)
        {
            string[] userAssemblies = CodeStrippingUtils.GetUserAssemblies(strippedAssemblyDir);
            nativeClasses = ((!PlayerSettings.stripEngineCode) ? null : CodeStrippingUtils.GenerateNativeClassList(rcr, strippedAssemblyDir, userAssemblies));
            if (nativeClasses != null)
            {
                CodeStrippingUtils.ExcludeModuleManagers(ref nativeClasses);
            }
            nativeModules = CodeStrippingUtils.GetNativeModulesToRegister(nativeClasses);
            if (nativeClasses != null && icallsListFile != null)
            {
                HashSet <string> modulesFromICalls = CodeStrippingUtils.GetModulesFromICalls(icallsListFile);
                int derivedFromClassID             = BaseObjectTools.StringToClassID("GlobalGameManager");
                foreach (string current in modulesFromICalls)
                {
                    int[] moduleClasses = ModuleMetadata.GetModuleClasses(current);
                    int[] array         = moduleClasses;
                    for (int i = 0; i < array.Length; i++)
                    {
                        int num = array[i];
                        if (BaseObjectTools.IsDerivedFromClassID(num, derivedFromClassID))
                        {
                            nativeClasses.Add(BaseObjectTools.ClassIDToString(num));
                        }
                    }
                }
                nativeModules.UnionWith(modulesFromICalls);
            }
            AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker();

            assemblyReferenceChecker.CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0f, true);
        }
예제 #2
0
 public static void GenerateDependencies(string strippedAssemblyDir, string icallsListFile, RuntimeClassRegistry rcr, out HashSet <string> nativeClasses, out HashSet <string> nativeModules)
 {
     string[] userAssemblies = CodeStrippingUtils.GetUserAssemblies(strippedAssemblyDir);
     nativeClasses = !PlayerSettings.stripEngineCode ? (HashSet <string>)null : CodeStrippingUtils.GenerateNativeClassList(rcr, strippedAssemblyDir, userAssemblies);
     if (nativeClasses != null)
     {
         CodeStrippingUtils.ExcludeModuleManagers(ref nativeClasses);
     }
     nativeModules = CodeStrippingUtils.GetNativeModulesToRegister(nativeClasses);
     if (nativeClasses != null && icallsListFile != null)
     {
         HashSet <string> modulesFromIcalls = CodeStrippingUtils.GetModulesFromICalls(icallsListFile);
         int classId = BaseObjectTools.StringToClassID("GlobalGameManager");
         using (HashSet <string> .Enumerator enumerator = modulesFromIcalls.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 foreach (int moduleClass in ModuleMetadata.GetModuleClasses(enumerator.Current))
                 {
                     if (BaseObjectTools.IsDerivedFromClassID(moduleClass, classId))
                     {
                         nativeClasses.Add(BaseObjectTools.ClassIDToString(moduleClass));
                     }
                 }
             }
         }
         nativeModules.UnionWith((IEnumerable <string>)modulesFromIcalls);
     }
     new AssemblyReferenceChecker().CollectReferencesFromRoots(strippedAssemblyDir, (IEnumerable <string>)userAssemblies, true, 0.0f, true);
 }
        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("}");
        }
예제 #4
0
        public static void WriteModuleAndClassRegistrationFile(string strippedAssemblyDir, string icallsListFile, string outputDir, RuntimeClassRegistry rcr, IEnumerable <string> classesToSkip)
        {
            HashSet <string> nativeClasses;
            HashSet <string> nativeModules;

            CodeStrippingUtils.GenerateDependencies(strippedAssemblyDir, icallsListFile, rcr, out nativeClasses, out nativeModules);
            CodeStrippingUtils.WriteModuleAndClassRegistrationFile(Path.Combine(outputDir, "UnityClassRegistration.cpp"), nativeModules, nativeClasses, new HashSet <string>(classesToSkip));
        }
예제 #5
0
 public static HashSet <string> GetNativeModulesToRegister(HashSet <string> nativeClasses)
 {
     if (nativeClasses == null)
     {
         return(CodeStrippingUtils.GetAllStrippableModules());
     }
     return(CodeStrippingUtils.GetRequiredStrippableModules(nativeClasses));
 }
예제 #6
0
        private static HashSet <string> GenerateNativeClassList(RuntimeClassRegistry rcr, string directory, string[] rootAssemblies, StrippingInfo strippingInfo)
        {
            HashSet <string> hashSet = CodeStrippingUtils.CollectNativeClassListFromRoots(directory, rootAssemblies, strippingInfo);

            string[] nativeClassBlackList = CodeStrippingUtils.NativeClassBlackList;
            for (int i = 0; i < nativeClassBlackList.Length; i++)
            {
                string text = nativeClassBlackList[i];
                hashSet.Add(text);
                if (strippingInfo != null)
                {
                    strippingInfo.RegisterDependency(text, "Blacklisted");
                }
            }
            foreach (string current in CodeStrippingUtils.NativeClassDependencyBlackList.Keys)
            {
                if (hashSet.Contains(current))
                {
                    string text2 = CodeStrippingUtils.NativeClassDependencyBlackList[current];
                    hashSet.Add(text2);
                    if (strippingInfo != null)
                    {
                        strippingInfo.RegisterDependency(text2, string.Format("Blacklisted due to dependent class '{0}'", current));
                    }
                }
            }
            foreach (string current2 in rcr.GetAllNativeClassesIncludingManagersAsString())
            {
                int num = BaseObjectTools.StringToClassID(current2);
                if (num != -1 && !BaseObjectTools.IsBaseObject(num))
                {
                    hashSet.Add(current2);
                    if (strippingInfo != null && !BaseObjectTools.IsDerivedFromClassID(num, CodeStrippingUtils.gameManagerClassId))
                    {
                        strippingInfo.RegisterDependency(current2, "Used in Scenes");
                    }
                }
            }
            HashSet <string> hashSet2 = new HashSet <string>();

            foreach (string current3 in hashSet)
            {
                int iD = BaseObjectTools.StringToClassID(current3);
                while (!BaseObjectTools.IsBaseObject(iD))
                {
                    hashSet2.Add(BaseObjectTools.ClassIDToString(iD));
                    int superClassID = BaseObjectTools.GetSuperClassID(iD);
                    if (strippingInfo != null)
                    {
                        strippingInfo.RegisterDependency(BaseObjectTools.ClassIDToString(superClassID), BaseObjectTools.ClassIDToString(iD));
                    }
                    iD = BaseObjectTools.GetSuperClassID(iD);
                }
            }
            return(hashSet2);
        }
예제 #7
0
        private static HashSet <UnityType> CollectNativeClassListFromRoots(string directory, string[] rootAssemblies, StrippingInfo strippingInfo)
        {
            HashSet <string>        source     = CodeStrippingUtils.CollectManagedTypeReferencesFromRoots(directory, rootAssemblies, strippingInfo);
            IEnumerable <UnityType> collection = from name in source
                                                 select UnityType.FindTypeByName(name) into klass
                                                     where klass != null && klass.baseClass != null
                                                 select klass;

            return(new HashSet <UnityType>(collection));
        }
예제 #8
0
        private static string[] GetUserAssemblies(string strippedAssemblyDir)
        {
            List <string> stringList = new List <string>();

            foreach (string userAssembly in CodeStrippingUtils.s_UserAssemblies)
            {
                stringList.AddRange(CodeStrippingUtils.GetAssembliesInDirectory(strippedAssemblyDir, userAssembly));
            }
            return(stringList.ToArray());
        }
예제 #9
0
        public static void WriteModuleAndClassRegistrationFile(string strippedAssemblyDir, string icallsListFile, string outputDir, RuntimeClassRegistry rcr, IEnumerable <UnityType> classesToSkip, IIl2CppPlatformProvider platformProvider)
        {
            bool stripEngineCode = PlayerSettings.stripEngineCode;
            HashSet <UnityType> nativeClasses;
            HashSet <string>    nativeModules;

            CodeStrippingUtils.GenerateDependencies(strippedAssemblyDir, icallsListFile, rcr, stripEngineCode, out nativeClasses, out nativeModules, platformProvider);
            string file = Path.Combine(outputDir, "UnityClassRegistration.cpp");

            CodeStrippingUtils.WriteModuleAndClassRegistrationFile(file, nativeModules, nativeClasses, new HashSet <UnityType>(classesToSkip));
        }
예제 #10
0
        private static string[] GetUserAssemblies(string strippedAssemblyDir)
        {
            List <string> list = new List <string>();

            string[] userAssemblies = CodeStrippingUtils.UserAssemblies;
            for (int i = 0; i < userAssemblies.Length; i++)
            {
                string assemblyName = userAssemblies[i];
                list.AddRange(CodeStrippingUtils.GetAssembliesInDirectory(strippedAssemblyDir, assemblyName));
            }
            return(list.ToArray());
        }
예제 #11
0
        public static void WriteModuleAndClassRegistrationFile(string strippedAssemblyDir, string outputDir, RuntimeClassRegistry rcr)
        {
            HashSet <string> hashSet = (PlayerSettings.strippingLevel != StrippingLevel.Disabled) ? CodeStrippingUtils.GenerateNativeClassList(rcr, strippedAssemblyDir, CodeStrippingUtils.GetUserAssemblies(strippedAssemblyDir)) : null;

            if (hashSet != null)
            {
                CodeStrippingUtils.ExcludeModuleManagers(ref hashSet);
            }
            HashSet <string> nativeModules = (hashSet != null) ? CodeStrippingUtils.GetRequiredStrippableModules(hashSet) : CodeStrippingUtils.GetAllStrippableModules();
            string           file          = Path.Combine(outputDir, "UnityClassRegistration.cpp");

            CodeStrippingUtils.WriteModuleAndClassRegistrationFile(file, nativeModules, hashSet);
        }
예제 #12
0
        public static void GenerateDependencies(string strippedAssemblyDir, string icallsListFile, RuntimeClassRegistry rcr, out HashSet <string> nativeClasses, out HashSet <string> nativeModules, BuildReport buildReport)
        {
            StrippingInfo buildReportData = StrippingInfo.GetBuildReportData(buildReport);

            string[] userAssemblies = CodeStrippingUtils.GetUserAssemblies(strippedAssemblyDir);
            nativeClasses = ((!PlayerSettings.stripEngineCode) ? null : CodeStrippingUtils.GenerateNativeClassList(rcr, strippedAssemblyDir, userAssemblies, buildReportData));
            if (nativeClasses != null)
            {
                CodeStrippingUtils.ExcludeModuleManagers(ref nativeClasses);
            }
            nativeModules = CodeStrippingUtils.GetNativeModulesToRegister(nativeClasses, buildReportData);
            if (nativeClasses != null && icallsListFile != null)
            {
                HashSet <string> modulesFromICalls = CodeStrippingUtils.GetModulesFromICalls(icallsListFile);
                foreach (string current in modulesFromICalls)
                {
                    if (!nativeModules.Contains(current) && buildReportData != null)
                    {
                        buildReportData.RegisterDependency(current, "Required by Scripts");
                    }
                    int[] moduleClasses = ModuleMetadata.GetModuleClasses(current);
                    int[] array         = moduleClasses;
                    for (int i = 0; i < array.Length; i++)
                    {
                        int num = array[i];
                        if (BaseObjectTools.IsDerivedFromClassID(num, CodeStrippingUtils.gameManagerClassId))
                        {
                            string text = BaseObjectTools.ClassIDToString(num);
                            nativeClasses.Add(text);
                            if (buildReportData != null)
                            {
                                buildReportData.RegisterDependency(text, "Required by Module");
                            }
                        }
                    }
                }
                nativeModules.UnionWith(modulesFromICalls);
            }
            AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker();

            assemblyReferenceChecker.CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0f, true);
            if (buildReportData != null)
            {
                foreach (string current2 in nativeModules)
                {
                    buildReportData.AddModule(current2);
                }
                buildReportData.AddModule("Core");
            }
        }
예제 #13
0
        private static HashSet <string> CollectNativeClassListFromRoots(string directory, string[] rootAssemblies)
        {
            HashSet <string> hashSet  = new HashSet <string>();
            HashSet <string> hashSet2 = CodeStrippingUtils.CollectManagedTypeReferencesFromRoots(directory, rootAssemblies);

            foreach (string current in hashSet2)
            {
                int num = BaseObjectTools.StringToClassID(current);
                if (num != -1 && !BaseObjectTools.IsBaseObject(num))
                {
                    hashSet.Add(current);
                }
            }
            return(hashSet);
        }
예제 #14
0
        private static HashSet <string> GetRequiredStrippableModules(HashSet <string> nativeClasses)
        {
            HashSet <string> stringSet = new HashSet <string>();

            foreach (string moduleName in ModuleMetadata.GetModuleNames())
            {
                if (ModuleMetadata.GetModuleStrippable(moduleName))
                {
                    HashSet <string> classNames = CodeStrippingUtils.GetClassNames((IEnumerable <int>)ModuleMetadata.GetModuleClasses(moduleName));
                    if (nativeClasses.Overlaps((IEnumerable <string>)classNames))
                    {
                        stringSet.Add(moduleName);
                    }
                }
            }
            return(stringSet);
        }
예제 #15
0
        private static HashSet <string> GenerateNativeClassList(RuntimeClassRegistry rcr, string directory, string[] rootAssemblies)
        {
            HashSet <string> stringSet1 = CodeStrippingUtils.CollectNativeClassListFromRoots(directory, rootAssemblies);

            foreach (string nativeClassBlack in CodeStrippingUtils.NativeClassBlackList)
            {
                stringSet1.Add(nativeClassBlack);
            }
            using (Dictionary <string, string> .KeyCollection.Enumerator enumerator = CodeStrippingUtils.NativeClassDependencyBlackList.Keys.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    if (stringSet1.Contains(current))
                    {
                        string classDependencyBlack = CodeStrippingUtils.NativeClassDependencyBlackList[current];
                        stringSet1.Add(classDependencyBlack);
                    }
                }
            }
            using (List <string> .Enumerator enumerator = rcr.GetAllNativeClassesIncludingManagersAsString().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    int    classId = BaseObjectTools.StringToClassID(current);
                    if (classId != -1 && !BaseObjectTools.IsBaseObject(classId))
                    {
                        stringSet1.Add(current);
                    }
                }
            }
            HashSet <string> stringSet2 = new HashSet <string>();

            using (HashSet <string> .Enumerator enumerator = stringSet1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    for (int ID = BaseObjectTools.StringToClassID(enumerator.Current); !BaseObjectTools.IsBaseObject(ID); ID = BaseObjectTools.GetSuperClassID(ID))
                    {
                        stringSet2.Add(BaseObjectTools.ClassIDToString(ID));
                    }
                }
            }
            return(stringSet2);
        }
예제 #16
0
        private static HashSet <string> GetRequiredStrippableModules(HashSet <string> nativeClasses, StrippingInfo strippingInfo)
        {
            HashSet <string> hashSet  = new HashSet <string>();
            HashSet <string> hashSet2 = new HashSet <string>();

            string[] moduleNames = ModuleMetadata.GetModuleNames();
            for (int i = 0; i < moduleNames.Length; i++)
            {
                string text = moduleNames[i];
                if (ModuleMetadata.GetModuleStrippable(text))
                {
                    HashSet <string> classNames = CodeStrippingUtils.GetClassNames(ModuleMetadata.GetModuleClasses(text));
                    if (nativeClasses.Overlaps(classNames))
                    {
                        hashSet2.Add(text);
                        if (strippingInfo != null)
                        {
                            foreach (string current in classNames)
                            {
                                if (nativeClasses.Contains(current))
                                {
                                    strippingInfo.RegisterDependency(text, current);
                                    if (BaseObjectTools.IsDerivedFromClassID(BaseObjectTools.StringToClassID(current), CodeStrippingUtils.gameManagerClassId))
                                    {
                                        strippingInfo.RegisterDependency(current, "Required by Module");
                                    }
                                    hashSet.Add(current);
                                }
                            }
                        }
                    }
                }
            }
            if (strippingInfo != null)
            {
                foreach (string current2 in nativeClasses)
                {
                    if (!hashSet.Contains(current2))
                    {
                        strippingInfo.RegisterDependency("Core", current2);
                    }
                }
            }
            return(hashSet2);
        }
예제 #17
0
        private static HashSet <string> CollectNativeClassListFromRoots(string directory, string[] rootAssemblies)
        {
            HashSet <string> stringSet = new HashSet <string>();

            using (HashSet <string> .Enumerator enumerator = CodeStrippingUtils.CollectManagedTypeReferencesFromRoots(directory, rootAssemblies).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    int    classId = BaseObjectTools.StringToClassID(current);
                    if (classId != -1 && !BaseObjectTools.IsBaseObject(classId))
                    {
                        stringSet.Add(current);
                    }
                }
            }
            return(stringSet);
        }
예제 #18
0
 private static void WriteModuleAndClassRegistrationFile(string file, HashSet <string> nativeModules, HashSet <string> nativeClasses)
 {
     using (TextWriter textWriter = new StreamWriter(file))
     {
         CodeStrippingUtils.WriteStaticallyLinkedModuleRegistration(textWriter, nativeModules, nativeClasses);
         textWriter.WriteLine();
         textWriter.WriteLine("void RegisterAllClasses()");
         textWriter.WriteLine("{");
         if (nativeClasses == null)
         {
             textWriter.WriteLine("\tvoid RegisterAllClassesGranular();");
             textWriter.WriteLine("\tRegisterAllClassesGranular();");
         }
         else
         {
             textWriter.WriteLine(string.Format("\t//Total: {0} classes", nativeClasses.Count));
             int num = 0;
             foreach (string current in nativeClasses)
             {
                 textWriter.WriteLine(string.Format("\t//{0}. {1}", num, current));
                 if (current == "MasterServerInterface")
                 {
                     textWriter.WriteLine("\t//Skipping");
                 }
                 else
                 {
                     if (current == "NetworkManager")
                     {
                         textWriter.WriteLine("\t//Skipping");
                     }
                     else
                     {
                         textWriter.WriteLine(string.Format("\tvoid RegisterClass_{0}();", current));
                         textWriter.WriteLine(string.Format("\tRegisterClass_{0}();", current));
                     }
                 }
                 textWriter.WriteLine();
                 num++;
             }
         }
         textWriter.WriteLine("}");
         textWriter.Close();
     }
 }
예제 #19
0
        private static HashSet <string> GetRequiredStrippableModules(HashSet <string> nativeClasses)
        {
            HashSet <string> hashSet = new HashSet <string>();

            string[] moduleNames = ModuleMetadata.GetModuleNames();
            for (int i = 0; i < moduleNames.Length; i++)
            {
                string text = moduleNames[i];
                if (ModuleMetadata.GetModuleStrippable(text))
                {
                    HashSet <string> classNames = CodeStrippingUtils.GetClassNames(ModuleMetadata.GetModuleClasses(text));
                    if (nativeClasses.Overlaps(classNames))
                    {
                        hashSet.Add(text);
                    }
                }
            }
            return(hashSet);
        }
예제 #20
0
        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("}");
        }
예제 #21
0
        private static HashSet <string> GenerateNativeClassList(RuntimeClassRegistry rcr, string directory, string[] rootAssemblies)
        {
            HashSet <string> hashSet = CodeStrippingUtils.CollectNativeClassListFromRoots(directory, rootAssemblies);

            string[] nativeClassBlackList = CodeStrippingUtils.NativeClassBlackList;
            for (int i = 0; i < nativeClassBlackList.Length; i++)
            {
                string item = nativeClassBlackList[i];
                hashSet.Add(item);
            }
            foreach (string current in rcr.GetAllNativeClassesIncludingManagersAsString())
            {
                int num = BaseObjectTools.StringToClassID(current);
                if (num != -1 && !BaseObjectTools.IsBaseObject(num))
                {
                    hashSet.Add(current);
                }
            }
            return(hashSet);
        }
예제 #22
0
 private static void WriteModuleAndClassRegistrationFile(string file, HashSet <string> nativeModules, HashSet <string> nativeClasses, HashSet <string> classesToSkip)
 {
     using (TextWriter w = (TextWriter) new StreamWriter(file))
     {
         CodeStrippingUtils.WriteStaticallyLinkedModuleRegistration(w, nativeModules, nativeClasses);
         w.WriteLine();
         w.WriteLine("void RegisterAllClasses()");
         w.WriteLine("{");
         if (nativeClasses == null)
         {
             w.WriteLine("\tvoid RegisterAllClassesGranular();");
             w.WriteLine("\tRegisterAllClassesGranular();");
         }
         else
         {
             w.WriteLine("\t//Total: {0} classes", (object)nativeClasses.Count);
             int num = 0;
             using (HashSet <string> .Enumerator enumerator = nativeClasses.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     string current = enumerator.Current;
                     w.WriteLine("\t//{0}. {1}", (object)num, (object)current);
                     if (classesToSkip.Contains(current))
                     {
                         w.WriteLine("\t//Skipping {0}", (object)current);
                     }
                     else
                     {
                         w.WriteLine("\tvoid RegisterClass_{0}();", (object)current);
                         w.WriteLine("\tRegisterClass_{0}();", (object)current);
                     }
                     w.WriteLine();
                     ++num;
                 }
             }
         }
         w.WriteLine("}");
         w.Close();
     }
 }
예제 #23
0
        private static HashSet <string> GenerateNativeClassList(RuntimeClassRegistry rcr, string directory, string[] rootAssemblies)
        {
            HashSet <string> hashSet = CodeStrippingUtils.CollectNativeClassListFromRoots(directory, rootAssemblies);

            string[] nativeClassBlackList = CodeStrippingUtils.NativeClassBlackList;
            for (int i = 0; i < nativeClassBlackList.Length; i++)
            {
                string item = nativeClassBlackList[i];
                hashSet.Add(item);
            }
            foreach (string current in CodeStrippingUtils.NativeClassDependencyBlackList.Keys)
            {
                if (hashSet.Contains(current))
                {
                    string item2 = CodeStrippingUtils.NativeClassDependencyBlackList[current];
                    hashSet.Add(item2);
                }
            }
            foreach (string current2 in rcr.GetAllNativeClassesIncludingManagersAsString())
            {
                int num = BaseObjectTools.StringToClassID(current2);
                if (num != -1 && !BaseObjectTools.IsBaseObject(num))
                {
                    hashSet.Add(current2);
                }
            }
            HashSet <string> hashSet2 = new HashSet <string>();

            foreach (string current3 in hashSet)
            {
                int iD = BaseObjectTools.StringToClassID(current3);
                while (!BaseObjectTools.IsBaseObject(iD))
                {
                    hashSet2.Add(BaseObjectTools.ClassIDToString(iD));
                    iD = BaseObjectTools.GetSuperClassID(iD);
                }
            }
            return(hashSet2);
        }
예제 #24
0
        public static void InjectCustomDependencies(BuildTarget target, StrippingInfo strippingInfo, HashSet <UnityType> nativeClasses, HashSet <string> nativeModules)
        {
            UnityType item = UnityType.FindTypeByName("UnityAnalyticsManager");

            if (nativeClasses.Contains(item))
            {
                if (PlayerSettings.submitAnalytics)
                {
                    strippingInfo.RegisterDependency("UnityAnalyticsManager", "Required by HW Statistics (See Player Settings)");
                    strippingInfo.SetIcon("Required by HW Statistics (See Player Settings)", "class/PlayerSettings");
                }
                if (AnalyticsSettings.enabled)
                {
                    strippingInfo.RegisterDependency("UnityAnalyticsManager", "Required by Unity Analytics (See Services Window)");
                    strippingInfo.SetIcon("Required by Unity Analytics (See Services Window)", "class/PlayerSettings");
                }
            }
            if (CodeStrippingUtils.IsVRModuleUsed(target))
            {
                nativeModules.Add("VR");
                strippingInfo.RegisterDependency("VR", "Required by Scripts");
                strippingInfo.SetIcon("Required because VR is enabled in PlayerSettings", "class/PlayerSettings");
            }
        }
예제 #25
0
 public static HashSet <string> GetNativeModulesToRegister(HashSet <UnityType> nativeClasses, StrippingInfo strippingInfo)
 {
     return((nativeClasses != null) ? CodeStrippingUtils.GetRequiredStrippableModules(nativeClasses, strippingInfo) : CodeStrippingUtils.GetAllStrippableModules());
 }
예제 #26
0
        public static void WriteCPlusPlusFileForStaticAOTModuleRegistration(BuildTarget buildTarget, string file, CrossCompileOptions crossCompileOptions, bool advancedLic, string targetDevice, bool stripping, RuntimeClassRegistry usedClassRegistry, AssemblyReferenceChecker checker, string stagingAreaDataManaged)
        {
            HashSet <UnityType> set;
            HashSet <string>    set2;
            string str  = Path.Combine(stagingAreaDataManaged, "ICallSummary.txt");
            string exe  = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe");
            string args = $"-assembly=" { Path.Combine(stagingAreaDataManaged, "UnityEngine.dll") } " -summary=" { str } "";

            Runner.RunManagedProgram(exe, args);
            CodeStrippingUtils.GenerateDependencies(Path.GetFullPath(stagingAreaDataManaged), str, usedClassRegistry, stripping, out set, out set2, null);
            using (TextWriter writer = new StreamWriter(file))
            {
                string[]             assemblyFileNames   = checker.GetAssemblyFileNames();
                AssemblyDefinition[] assemblyDefinitions = checker.GetAssemblyDefinitions();
                bool      flag = (crossCompileOptions & CrossCompileOptions.FastICall) != CrossCompileOptions.Dynamic;
                ArrayList list = BuildNativeMethodList(assemblyDefinitions);
                if (buildTarget == BuildTarget.iOS)
                {
                    writer.WriteLine("#include \"RegisterMonoModules.h\"");
                    writer.WriteLine("#include <stdio.h>");
                }
                writer.WriteLine("");
                writer.WriteLine("#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR");
                writer.WriteLine("    #define DECL_USER_FUNC(f) void f() __attribute__((weak_import))");
                writer.WriteLine(@"    #define REGISTER_USER_FUNC(f)\");
                writer.WriteLine(@"        do {\");
                writer.WriteLine(@"        if(f != NULL)\");
                writer.WriteLine(@"            mono_dl_register_symbol(#f, (void*)f);\");
                writer.WriteLine(@"        else\");
                writer.WriteLine("            ::printf_console(\"Symbol '%s' not found. Maybe missing implementation for Simulator?\\n\", #f);\\");
                writer.WriteLine("        }while(0)");
                writer.WriteLine("#else");
                writer.WriteLine("    #define DECL_USER_FUNC(f) void f() ");
                writer.WriteLine("    #if !defined(__arm64__)");
                writer.WriteLine("    #define REGISTER_USER_FUNC(f) mono_dl_register_symbol(#f, (void*)&f)");
                writer.WriteLine("    #else");
                writer.WriteLine("        #define REGISTER_USER_FUNC(f)");
                writer.WriteLine("    #endif");
                writer.WriteLine("#endif");
                writer.WriteLine("extern \"C\"\n{");
                writer.WriteLine("    typedef void* gpointer;");
                writer.WriteLine("    typedef int gboolean;");
                if (buildTarget == BuildTarget.iOS)
                {
                    writer.WriteLine("    const char*         UnityIPhoneRuntimeVersion = \"{0}\";", Application.unityVersion);
                    writer.WriteLine("    void                mono_dl_register_symbol (const char* name, void *addr);");
                    writer.WriteLine("#if !defined(__arm64__)");
                    writer.WriteLine("    extern int          mono_ficall_flag;");
                    writer.WriteLine("#endif");
                }
                writer.WriteLine("    void                mono_aot_register_module(gpointer *aot_info);");
                writer.WriteLine("#if __ORBIS__ || SN_TARGET_PSP2");
                writer.WriteLine("#define DLL_EXPORT __declspec(dllexport)");
                writer.WriteLine("#else");
                writer.WriteLine("#define DLL_EXPORT");
                writer.WriteLine("#endif");
                writer.WriteLine("#if !(TARGET_IPHONE_SIMULATOR)");
                writer.WriteLine("    extern gboolean     mono_aot_only;");
                for (int i = 0; i < assemblyFileNames.Length; i++)
                {
                    string str4 = assemblyFileNames[i];
                    string str5 = assemblyDefinitions[i].Name.Name.Replace(".", "_").Replace("-", "_").Replace(" ", "_");
                    writer.WriteLine("    extern gpointer*    mono_aot_module_{0}_info; // {1}", str5, str4);
                }
                writer.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR)");
                IEnumerator enumerator = list.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        string current = (string)enumerator.Current;
                        writer.WriteLine("    DECL_USER_FUNC({0});", current);
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                writer.WriteLine("}");
                writer.WriteLine("DLL_EXPORT void RegisterMonoModules()");
                writer.WriteLine("{");
                writer.WriteLine("#if !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)");
                writer.WriteLine("    mono_aot_only = true;");
                if (buildTarget == BuildTarget.iOS)
                {
                    writer.WriteLine("    mono_ficall_flag = {0};", !flag ? "false" : "true");
                }
                foreach (AssemblyDefinition definition in assemblyDefinitions)
                {
                    string str7 = definition.Name.Name.Replace(".", "_").Replace("-", "_").Replace(" ", "_");
                    writer.WriteLine("    mono_aot_register_module(mono_aot_module_{0}_info);", str7);
                }
                writer.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)");
                writer.WriteLine("");
                if (buildTarget == BuildTarget.iOS)
                {
                    IEnumerator enumerator2 = list.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            string str8 = (string)enumerator2.Current;
                            writer.WriteLine("    REGISTER_USER_FUNC({0});", str8);
                        }
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator2 as IDisposable;
                        if (disposable2 != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }
                writer.WriteLine("}");
                writer.WriteLine("");
                AssemblyDefinition unityEngine = null;
                for (int j = 0; j < assemblyFileNames.Length; j++)
                {
                    if (assemblyFileNames[j] == "UnityEngine.dll")
                    {
                        unityEngine = assemblyDefinitions[j];
                    }
                }
                if (buildTarget == BuildTarget.iOS)
                {
                    AssemblyDefinition[] assemblies = new AssemblyDefinition[] { unityEngine };
                    GenerateRegisterInternalCalls(assemblies, writer);
                    ResolveDefinedNativeClassesFromMono(assemblies, usedClassRegistry);
                    ResolveReferencedUnityEngineClassesFromMono(assemblyDefinitions, unityEngine, usedClassRegistry);
                    GenerateRegisterModules(set, set2, writer, stripping);
                    if (stripping && (usedClassRegistry != null))
                    {
                        GenerateRegisterClassesForStripping(set, writer);
                    }
                    else
                    {
                        GenerateRegisterClasses(set, writer);
                    }
                }
                writer.Close();
            }
        }
        static public void WriteCPlusPlusFileForStaticAOTModuleRegistration(BuildTarget buildTarget, string file,
                                                                            CrossCompileOptions crossCompileOptions,
                                                                            bool advancedLic, string targetDevice, bool stripping, RuntimeClassRegistry usedClassRegistry,
                                                                            AssemblyReferenceChecker checker, string stagingAreaDataManaged, IIl2CppPlatformProvider platformProvider)
        {
            // generate the Interal Call Summary file
            var icallSummaryPath = Path.Combine(stagingAreaDataManaged, "ICallSummary.txt");
            var dlls             = Directory.GetFiles(stagingAreaDataManaged, "UnityEngine.*Module.dll").Concat(new[] { Path.Combine(stagingAreaDataManaged, "UnityEngine.dll") });
            var exe  = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe");
            var args = string.Format("-assembly=\"{0}\" -summary=\"{1}\"",
                                     dlls.Aggregate((dllArg, next) => dllArg + ";" + next), icallSummaryPath
                                     );

            Runner.RunManagedProgram(exe, args);

            HashSet <UnityType> nativeClasses;
            HashSet <string>    nativeModules;

            CodeStrippingUtils.GenerateDependencies(Path.GetDirectoryName(stagingAreaDataManaged), icallSummaryPath, usedClassRegistry, stripping, out nativeClasses, out nativeModules, platformProvider);

            using (TextWriter w = new StreamWriter(file))
            {
                string[]             fileNames  = checker.GetAssemblyFileNames();
                AssemblyDefinition[] assemblies = checker.GetAssemblyDefinitions();

                bool fastICall = (crossCompileOptions & CrossCompileOptions.FastICall) != 0;

                ArrayList nativeMethods = BuildNativeMethodList(assemblies);

                if (buildTarget == BuildTarget.iOS)
                {
                    w.WriteLine("#include \"RegisterMonoModules.h\"");
                    w.WriteLine("#include <stdio.h>");
                }

                w.WriteLine("");
                w.WriteLine("#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR");
                w.WriteLine("    #define DECL_USER_FUNC(f) void f() __attribute__((weak_import))");
                w.WriteLine("    #define REGISTER_USER_FUNC(f)\\");
                w.WriteLine("        do {\\");
                w.WriteLine("        if(f != NULL)\\");
                w.WriteLine("            mono_dl_register_symbol(#f, (void*)f);\\");
                w.WriteLine("        else\\");
                w.WriteLine("            ::printf_console(\"Symbol \'%s\' not found. Maybe missing implementation for Simulator?\\n\", #f);\\");
                w.WriteLine("        }while(0)");
                w.WriteLine("#else");
                w.WriteLine("    #define DECL_USER_FUNC(f) void f() ");
                w.WriteLine("    #if !defined(__arm64__)");
                w.WriteLine("    #define REGISTER_USER_FUNC(f) mono_dl_register_symbol(#f, (void*)&f)");
                w.WriteLine("    #else");
                w.WriteLine("        #define REGISTER_USER_FUNC(f)");
                w.WriteLine("    #endif");
                w.WriteLine("#endif");
                w.WriteLine("extern \"C\"\n{");

                w.WriteLine("    typedef void* gpointer;");
                w.WriteLine("    typedef int gboolean;");

                if (buildTarget == BuildTarget.iOS)
                {
                    w.WriteLine("    const char*         UnityIPhoneRuntimeVersion = \"{0}\";", Application.unityVersion);
                    w.WriteLine("    void                mono_dl_register_symbol (const char* name, void *addr);");

                    w.WriteLine("#if !defined(__arm64__)");
                    w.WriteLine("    extern int          mono_ficall_flag;");
                    w.WriteLine("#endif");
                }

                w.WriteLine("    void                mono_aot_register_module(gpointer *aot_info);");

                w.WriteLine("#if __ORBIS__ || SN_TARGET_PSP2");
                w.WriteLine("#define DLL_EXPORT __declspec(dllexport)"); // ps4 and psp2 need dllexport.
                w.WriteLine("#else");
                w.WriteLine("#define DLL_EXPORT");
                w.WriteLine("#endif");

                w.WriteLine("#if !(TARGET_IPHONE_SIMULATOR)");
                w.WriteLine("    extern gboolean     mono_aot_only;");

                for (int q = 0; q < fileNames.Length; ++q)
                {
                    string fileName     = fileNames[q];
                    string assemblyName = assemblies[q].Name.Name;
                    assemblyName = assemblyName.Replace(".", "_");
                    assemblyName = assemblyName.Replace("-", "_");
                    assemblyName = assemblyName.Replace(" ", "_");

                    w.WriteLine("    extern gpointer*    mono_aot_module_{0}_info; // {1}", assemblyName, fileName);
                }
                w.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR)");
                foreach (string nmethod in nativeMethods)
                {
                    w.WriteLine("    DECL_USER_FUNC({0});", nmethod);
                }
                w.WriteLine("}");

                w.WriteLine("DLL_EXPORT void RegisterMonoModules()");
                w.WriteLine("{");

                w.WriteLine("#if !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)");
                w.WriteLine("    mono_aot_only = true;");

                if (buildTarget == BuildTarget.iOS)
                {
                    w.WriteLine("    mono_ficall_flag = {0};", fastICall ? "true" : "false");
                }

                foreach (AssemblyDefinition definition in assemblies)
                {
                    string assemblyName = definition.Name.Name;
                    assemblyName = assemblyName.Replace(".", "_");
                    assemblyName = assemblyName.Replace("-", "_");
                    assemblyName = assemblyName.Replace(" ", "_");
                    w.WriteLine("    mono_aot_register_module(mono_aot_module_{0}_info);", assemblyName);
                }

                w.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)");
                w.WriteLine("");

                if (buildTarget == BuildTarget.iOS)
                {
                    foreach (string nmethod in nativeMethods)
                    {
                        w.WriteLine("    REGISTER_USER_FUNC({0});", nmethod);
                    }
                }
                w.WriteLine("}");
                w.WriteLine("");


                if (buildTarget == BuildTarget.iOS)
                {
                    var inputAssemblies = new List <AssemblyDefinition>();

                    for (int i = 0; i < assemblies.Length; i++)
                    {
                        if (AssemblyHelper.IsUnityEngineModule(assemblies[i]))
                        {
                            inputAssemblies.Add(assemblies[i]);
                        }
                    }

                    GenerateRegisterInternalCalls(inputAssemblies.ToArray(), w);

                    GenerateRegisterModules(nativeClasses, nativeModules, w, stripping);

                    if (stripping && usedClassRegistry != null)
                    {
                        GenerateRegisterClassesForStripping(nativeClasses, w);
                    }
                    else
                    {
                        GenerateRegisterClasses(nativeClasses, w);
                    }
                }

                w.Close();
            }
        }
예제 #28
0
 private static void WriteModuleAndClassRegistrationFile(string file, HashSet <string> nativeModules, HashSet <UnityType> nativeClasses, HashSet <UnityType> classesToSkip)
 {
     using (TextWriter textWriter = new StreamWriter(file))
     {
         textWriter.WriteLine("template <typename T> void RegisterClass();");
         textWriter.WriteLine("template <typename T> void RegisterStrippedTypeInfo(int, const char*, const char*);");
         textWriter.WriteLine();
         CodeStrippingUtils.WriteStaticallyLinkedModuleRegistration(textWriter, nativeModules, nativeClasses);
         textWriter.WriteLine();
         if (nativeClasses != null)
         {
             foreach (UnityType current in UnityType.GetTypes())
             {
                 if (current.baseClass != null && !current.isEditorOnly && !classesToSkip.Contains(current))
                 {
                     if (current.hasNativeNamespace)
                     {
                         textWriter.Write("namespace {0} {{ class {1}; }} ", current.nativeNamespace, current.name);
                     }
                     else
                     {
                         textWriter.Write("class {0}; ", current.name);
                     }
                     if (nativeClasses.Contains(current))
                     {
                         textWriter.WriteLine("template <> void RegisterClass<{0}>();", current.qualifiedName);
                     }
                     else
                     {
                         textWriter.WriteLine();
                     }
                 }
             }
             textWriter.WriteLine();
         }
         textWriter.WriteLine("void RegisterAllClasses()");
         textWriter.WriteLine("{");
         if (nativeClasses == null)
         {
             textWriter.WriteLine("\tvoid RegisterAllClassesGranular();");
             textWriter.WriteLine("\tRegisterAllClassesGranular();");
         }
         else
         {
             textWriter.WriteLine("void RegisterBuiltinTypes();");
             textWriter.WriteLine("RegisterBuiltinTypes();");
             textWriter.WriteLine("\t//Total: {0} non stripped classes", nativeClasses.Count);
             int num = 0;
             foreach (UnityType current2 in nativeClasses)
             {
                 textWriter.WriteLine("\t//{0}. {1}", num, current2.qualifiedName);
                 if (classesToSkip.Contains(current2))
                 {
                     textWriter.WriteLine("\t//Skipping {0}", current2.qualifiedName);
                 }
                 else
                 {
                     textWriter.WriteLine("\tRegisterClass<{0}>();", current2.qualifiedName);
                 }
                 num++;
             }
             textWriter.WriteLine();
         }
         textWriter.WriteLine("}");
         textWriter.Close();
     }
 }
예제 #29
0
        public static void GenerateDependencies(string strippedAssemblyDir, string icallsListFile, RuntimeClassRegistry rcr, bool doStripping, out HashSet <UnityType> nativeClasses, out HashSet <string> nativeModules, IIl2CppPlatformProvider platformProvider)
        {
            StrippingInfo strippingInfo = (platformProvider != null) ? StrippingInfo.GetBuildReportData(platformProvider.buildReport) : null;

            string[] userAssemblies = CodeStrippingUtils.GetUserAssemblies(strippedAssemblyDir);
            nativeClasses = ((!doStripping) ? null : CodeStrippingUtils.GenerateNativeClassList(rcr, strippedAssemblyDir, userAssemblies, strippingInfo));
            if (nativeClasses != null)
            {
                CodeStrippingUtils.ExcludeModuleManagers(ref nativeClasses);
            }
            nativeModules = CodeStrippingUtils.GetNativeModulesToRegister(nativeClasses, strippingInfo);
            if (nativeClasses != null && icallsListFile != null)
            {
                HashSet <string> modulesFromICalls = CodeStrippingUtils.GetModulesFromICalls(icallsListFile);
                foreach (string current in modulesFromICalls)
                {
                    if (!nativeModules.Contains(current))
                    {
                        if (strippingInfo != null)
                        {
                            strippingInfo.RegisterDependency(StrippingInfo.ModuleName(current), "Required by Scripts");
                        }
                    }
                    UnityType[] moduleTypes = ModuleMetadata.GetModuleTypes(current);
                    UnityType[] array       = moduleTypes;
                    for (int i = 0; i < array.Length; i++)
                    {
                        UnityType unityType = array[i];
                        if (unityType.IsDerivedFrom(CodeStrippingUtils.GameManagerTypeInfo))
                        {
                            nativeClasses.Add(unityType);
                        }
                    }
                }
                nativeModules.UnionWith(modulesFromICalls);
            }
            bool flag = true;

            if (platformProvider != null)
            {
                while (flag)
                {
                    flag = false;
                    foreach (string current2 in nativeModules.ToList <string>())
                    {
                        string moduleWhitelist = CodeStrippingUtils.GetModuleWhitelist(current2, platformProvider.moduleStrippingInformationFolder);
                        if (File.Exists(moduleWhitelist))
                        {
                            foreach (string current3 in CodeStrippingUtils.GetDependentModules(moduleWhitelist))
                            {
                                if (!nativeModules.Contains(current3))
                                {
                                    nativeModules.Add(current3);
                                    flag = true;
                                }
                                if (strippingInfo != null)
                                {
                                    string text = StrippingInfo.ModuleName(current2);
                                    strippingInfo.RegisterDependency(StrippingInfo.ModuleName(current3), "Required by " + text);
                                    if (strippingInfo.icons.ContainsKey(text))
                                    {
                                        strippingInfo.SetIcon("Required by " + text, strippingInfo.icons[text]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker();

            assemblyReferenceChecker.CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0f, true);
            if (strippingInfo != null)
            {
                foreach (string current4 in nativeModules)
                {
                    strippingInfo.AddModule(StrippingInfo.ModuleName(current4));
                }
                strippingInfo.AddModule(StrippingInfo.ModuleName("Core"));
            }
            if (nativeClasses != null && strippingInfo != null)
            {
                CodeStrippingUtils.InjectCustomDependencies(platformProvider.target, strippingInfo, nativeClasses, nativeModules);
            }
        }
예제 #30
0
        private static HashSet <UnityType> GenerateNativeClassList(RuntimeClassRegistry rcr, string directory, string[] rootAssemblies, StrippingInfo strippingInfo)
        {
            HashSet <UnityType> hashSet = CodeStrippingUtils.CollectNativeClassListFromRoots(directory, rootAssemblies, strippingInfo);

            UnityType[] blackListNativeClasses = CodeStrippingUtils.BlackListNativeClasses;
            for (int i = 0; i < blackListNativeClasses.Length; i++)
            {
                UnityType item = blackListNativeClasses[i];
                hashSet.Add(item);
            }
            foreach (UnityType current in CodeStrippingUtils.BlackListNativeClassesDependency.Keys)
            {
                if (hashSet.Contains(current))
                {
                    UnityType item2 = CodeStrippingUtils.BlackListNativeClassesDependency[current];
                    hashSet.Add(item2);
                }
            }
            foreach (string current2 in rcr.GetAllNativeClassesIncludingManagersAsString())
            {
                UnityType unityType = UnityType.FindTypeByName(current2);
                if (unityType != null && unityType.baseClass != null)
                {
                    hashSet.Add(unityType);
                    if (strippingInfo != null)
                    {
                        if (!unityType.IsDerivedFrom(CodeStrippingUtils.GameManagerTypeInfo))
                        {
                            List <string> scenesForClass = rcr.GetScenesForClass(unityType.persistentTypeID);
                            if (scenesForClass != null)
                            {
                                foreach (string current3 in scenesForClass)
                                {
                                    strippingInfo.RegisterDependency(current2, current3);
                                    if (current3.EndsWith(".unity"))
                                    {
                                        strippingInfo.SetIcon(current3, "class/SceneAsset");
                                    }
                                    else
                                    {
                                        strippingInfo.SetIcon(current3, "class/AssetBundle");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            HashSet <UnityType> hashSet2 = new HashSet <UnityType>();

            foreach (UnityType current4 in hashSet)
            {
                UnityType unityType2 = current4;
                while (unityType2.baseClass != null)
                {
                    hashSet2.Add(unityType2);
                    unityType2 = unityType2.baseClass;
                }
            }
            return(hashSet2);
        }