Example #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 ? (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 GenerateDependencies(string strippedAssemblyDir, string icallsListFile, RuntimeClassRegistry rcr, out HashSet <string> nativeClasses, out HashSet <string> nativeModules)
 {
     string[] userAssemblies = GetUserAssemblies(strippedAssemblyDir);
     nativeClasses = !PlayerSettings.stripEngineCode ? null : GenerateNativeClassList(rcr, strippedAssemblyDir, userAssemblies);
     if (nativeClasses != null)
     {
         ExcludeModuleManagers(ref nativeClasses);
     }
     nativeModules = GetNativeModulesToRegister(nativeClasses);
     if ((nativeClasses != null) && (icallsListFile != null))
     {
         HashSet <string> modulesFromICalls = GetModulesFromICalls(icallsListFile);
         int derivedFromClassID             = BaseObjectTools.StringToClassID("GlobalGameManager");
         foreach (string str in modulesFromICalls)
         {
             foreach (int num2 in ModuleMetadata.GetModuleClasses(str))
             {
                 if (BaseObjectTools.IsDerivedFromClassID(num2, derivedFromClassID))
                 {
                     nativeClasses.Add(BaseObjectTools.ClassIDToString(num2));
                 }
             }
         }
         nativeModules.UnionWith(modulesFromICalls);
     }
     new AssemblyReferenceChecker().CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0f, true);
 }
        private static HashSet <string> GenerateNativeClassList(RuntimeClassRegistry rcr, string directory, string[] rootAssemblies)
        {
            HashSet <string> set = CollectNativeClassListFromRoots(directory, rootAssemblies);

            foreach (string str in NativeClassBlackList)
            {
                set.Add(str);
            }
            foreach (string str2 in rcr.GetAllNativeClassesIncludingManagersAsString())
            {
                int iD = BaseObjectTools.StringToClassID(str2);
                if ((iD != -1) && !BaseObjectTools.IsBaseObject(iD))
                {
                    set.Add(str2);
                }
            }
            HashSet <string> set2 = new HashSet <string>();

            foreach (string str3 in set)
            {
                for (int i = BaseObjectTools.StringToClassID(str3); !BaseObjectTools.IsBaseObject(i); i = BaseObjectTools.GetSuperClassID(i))
                {
                    set2.Add(BaseObjectTools.ClassIDToString(i));
                }
            }
            return(set2);
        }
Example #4
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);
        }
        private static void ExcludeModuleManagers(ref HashSet <string> nativeClasses)
        {
            string[] moduleNames        = ModuleMetadata.GetModuleNames();
            int      derivedFromClassID = BaseObjectTools.StringToClassID("GlobalGameManager");

            foreach (string str in moduleNames)
            {
                if (ModuleMetadata.GetModuleStrippable(str))
                {
                    int[]            moduleClasses = ModuleMetadata.GetModuleClasses(str);
                    HashSet <int>    set           = new HashSet <int>();
                    HashSet <string> other         = new HashSet <string>();
                    foreach (int num3 in moduleClasses)
                    {
                        if (BaseObjectTools.IsDerivedFromClassID(num3, derivedFromClassID))
                        {
                            set.Add(num3);
                        }
                        else
                        {
                            other.Add(BaseObjectTools.ClassIDToString(num3));
                        }
                    }
                    if ((other.Count != 0) && !nativeClasses.Overlaps(other))
                    {
                        foreach (int num5 in set)
                        {
                            nativeClasses.Remove(BaseObjectTools.ClassIDToString(num5));
                        }
                    }
                }
            }
        }
Example #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);
        }
Example #7
0
        private static HashSet <string> GetClassNames(IEnumerable <int> classIds)
        {
            HashSet <string> stringSet = new HashSet <string>();

            foreach (int classId in classIds)
            {
                stringSet.Add(BaseObjectTools.ClassIDToString(classId));
            }
            return(stringSet);
        }
        private void SyncToState()
        {
            Annotation[] annotations = AnnotationUtility.GetAnnotations();
            string       str         = string.Empty;

            if (AnnotationWindow.s_Debug)
            {
                str += "AnnotationWindow: SyncToState\n";
            }
            this.m_BuiltinAnnotations = new List <AInfo>();
            this.m_ScriptAnnotations  = new List <AInfo>();
            for (int index = 0; index < annotations.Length; ++index)
            {
                if (AnnotationWindow.s_Debug)
                {
                    str = str + "   same as below: icon " + (object)annotations[index].iconEnabled + " gizmo " + (object)annotations[index].gizmoEnabled + "\n";
                }
                AInfo ainfo = new AInfo(annotations[index].gizmoEnabled == 1, annotations[index].iconEnabled == 1, annotations[index].flags, annotations[index].classID, annotations[index].scriptClass);
                if (ainfo.m_ScriptClass == string.Empty)
                {
                    this.m_BuiltinAnnotations.Add(ainfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        str = str + "   " + BaseObjectTools.ClassIDToString(ainfo.m_ClassID) + ": icon " + (object)ainfo.m_IconEnabled + " gizmo " + (object)ainfo.m_GizmoEnabled + "\n";
                    }
                }
                else
                {
                    this.m_ScriptAnnotations.Add(ainfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        str = str + "   " + annotations[index].scriptClass + ": icon " + (object)ainfo.m_IconEnabled + " gizmo " + (object)ainfo.m_GizmoEnabled + "\n";
                    }
                }
            }
            this.m_BuiltinAnnotations.Sort();
            this.m_ScriptAnnotations.Sort();
            this.m_RecentAnnotations = new List <AInfo>();
            Annotation[] changedAnnotations = AnnotationUtility.GetRecentlyChangedAnnotations();
            for (int index = 0; index < changedAnnotations.Length && index < 5; ++index)
            {
                AInfo ainfo = this.GetAInfo(changedAnnotations[index].classID, changedAnnotations[index].scriptClass);
                if (ainfo != null)
                {
                    this.m_RecentAnnotations.Add(ainfo);
                }
            }
            this.m_SyncWithState = false;
            if (!AnnotationWindow.s_Debug)
            {
                return;
            }
            Debug.Log((object)str);
        }
Example #9
0
        public void AddNativeClassID(int ID)
        {
            string str = BaseObjectTools.ClassIDToString(ID);

            if (str.Length > 0)
            {
                this.allNativeClasses[ID] = str;
                if (!this.functionalityGroups.ContainsValue(str))
                {
                    this.nativeClasses[ID] = str;
                }
            }
        }
Example #10
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");
            }
        }
Example #11
0
 public AInfo(bool gizmoEnabled, bool iconEnabled, int flags, int classID, string scriptClass)
 {
     this.m_GizmoEnabled = gizmoEnabled;
     this.m_IconEnabled  = iconEnabled;
     this.m_ClassID      = classID;
     this.m_ScriptClass  = scriptClass;
     this.m_Flags        = flags;
     if (this.m_ScriptClass == string.Empty)
     {
         this.m_DisplayText = BaseObjectTools.ClassIDToString(this.m_ClassID);
     }
     else
     {
         this.m_DisplayText = this.m_ScriptClass;
     }
 }
Example #12
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);
        }
Example #13
0
 private static void ExcludeModuleManagers(ref HashSet <string> nativeClasses)
 {
     string[] moduleNames = ModuleMetadata.GetModuleNames();
     string[] array       = moduleNames;
     for (int i = 0; i < array.Length; i++)
     {
         string moduleName = array[i];
         if (ModuleMetadata.GetModuleStrippable(moduleName))
         {
             int[]            moduleClasses = ModuleMetadata.GetModuleClasses(moduleName);
             HashSet <int>    hashSet       = new HashSet <int>();
             HashSet <string> hashSet2      = new HashSet <string>();
             int[]            array2        = moduleClasses;
             for (int j = 0; j < array2.Length; j++)
             {
                 int num = array2[j];
                 if (BaseObjectTools.IsDerivedFromClassID(num, CodeStrippingUtils.gameManagerClassId))
                 {
                     hashSet.Add(num);
                 }
                 else
                 {
                     hashSet2.Add(BaseObjectTools.ClassIDToString(num));
                 }
             }
             if (hashSet2.Count != 0)
             {
                 if (!nativeClasses.Overlaps(hashSet2))
                 {
                     foreach (int current in hashSet)
                     {
                         nativeClasses.Remove(BaseObjectTools.ClassIDToString(current));
                     }
                 }
                 else
                 {
                     foreach (int current2 in hashSet)
                     {
                         nativeClasses.Add(BaseObjectTools.ClassIDToString(current2));
                     }
                 }
             }
         }
     }
 }
Example #14
0
        private static HashSet <string> GetClassNames(IEnumerable <int> classIds)
        {
            HashSet <string>  set        = new HashSet <string>();
            IEnumerator <int> enumerator = classIds.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    int current = enumerator.Current;
                    set.Add(BaseObjectTools.ClassIDToString(current));
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
            return(set);
        }
Example #15
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);
        }
Example #16
0
        private static void ExcludeModuleManagers(ref HashSet <string> nativeClasses)
        {
            string[] moduleNames = ModuleMetadata.GetModuleNames();
            int      classId     = BaseObjectTools.StringToClassID("GlobalGameManager");

            foreach (string moduleName in moduleNames)
            {
                if (ModuleMetadata.GetModuleStrippable(moduleName))
                {
                    int[]            moduleClasses = ModuleMetadata.GetModuleClasses(moduleName);
                    HashSet <int>    intSet        = new HashSet <int>();
                    HashSet <string> stringSet     = new HashSet <string>();
                    foreach (int num in moduleClasses)
                    {
                        if (BaseObjectTools.IsDerivedFromClassID(num, classId))
                        {
                            intSet.Add(num);
                        }
                        else
                        {
                            stringSet.Add(BaseObjectTools.ClassIDToString(num));
                        }
                    }
                    if (stringSet.Count != 0 && !nativeClasses.Overlaps((IEnumerable <string>)stringSet))
                    {
                        using (HashSet <int> .Enumerator enumerator = intSet.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                int current = enumerator.Current;
                                nativeClasses.Remove(BaseObjectTools.ClassIDToString(current));
                            }
                        }
                    }
                }
            }
        }
        private void SyncToState()
        {
            Annotation[] annotations = AnnotationUtility.GetAnnotations();
            string       text        = "";

            if (AnnotationWindow.s_Debug)
            {
                text += "AnnotationWindow: SyncToState\n";
            }
            this.m_BuiltinAnnotations = new List <AInfo>();
            this.m_ScriptAnnotations  = new List <AInfo>();
            for (int i = 0; i < annotations.Length; i++)
            {
                if (AnnotationWindow.s_Debug)
                {
                    string text2 = text;
                    text = string.Concat(new object[]
                    {
                        text2,
                        "   same as below: icon ",
                        annotations[i].iconEnabled,
                        " gizmo ",
                        annotations[i].gizmoEnabled,
                        "\n"
                    });
                }
                bool  gizmoEnabled = annotations[i].gizmoEnabled == 1;
                bool  iconEnabled  = annotations[i].iconEnabled == 1;
                AInfo aInfo        = new AInfo(gizmoEnabled, iconEnabled, annotations[i].flags, annotations[i].classID, annotations[i].scriptClass);
                if (aInfo.m_ScriptClass == "")
                {
                    this.m_BuiltinAnnotations.Add(aInfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        string text2 = text;
                        text = string.Concat(new object[]
                        {
                            text2,
                            "   ",
                            BaseObjectTools.ClassIDToString(aInfo.m_ClassID),
                            ": icon ",
                            aInfo.m_IconEnabled,
                            " gizmo ",
                            aInfo.m_GizmoEnabled,
                            "\n"
                        });
                    }
                }
                else
                {
                    this.m_ScriptAnnotations.Add(aInfo);
                    if (AnnotationWindow.s_Debug)
                    {
                        string text2 = text;
                        text = string.Concat(new object[]
                        {
                            text2,
                            "   ",
                            annotations[i].scriptClass,
                            ": icon ",
                            aInfo.m_IconEnabled,
                            " gizmo ",
                            aInfo.m_GizmoEnabled,
                            "\n"
                        });
                    }
                }
            }
            this.m_BuiltinAnnotations.Sort();
            this.m_ScriptAnnotations.Sort();
            this.m_RecentAnnotations = new List <AInfo>();
            Annotation[] recentlyChangedAnnotations = AnnotationUtility.GetRecentlyChangedAnnotations();
            int          num = 0;

            while (num < recentlyChangedAnnotations.Length && num < 5)
            {
                AInfo aInfo2 = this.GetAInfo(recentlyChangedAnnotations[num].classID, recentlyChangedAnnotations[num].scriptClass);
                if (aInfo2 != null)
                {
                    this.m_RecentAnnotations.Add(aInfo2);
                }
                num++;
            }
            this.m_SyncWithState = false;
            if (AnnotationWindow.s_Debug)
            {
                Debug.Log(text);
            }
        }