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 HashSet <string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies) { HashSet <string> set = new HashSet <string>(); AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); bool withMethods = false; bool ignoreSystemDlls = false; checker.CollectReferencesFromRoots(directory, rootAssemblies, withMethods, 0f, ignoreSystemDlls); string[] assemblyFileNames = checker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = checker.GetAssemblyDefinitions(); foreach (AssemblyDefinition definition in assemblyDefinitions) { foreach (TypeDefinition definition2 in definition.MainModule.Types) { if (definition2.Namespace.StartsWith("UnityEngine") && (((definition2.Fields.Count > 0) || (definition2.Methods.Count > 0)) || (definition2.Properties.Count > 0))) { string name = definition2.Name; set.Add(name); } } } AssemblyDefinition definition3 = null; for (int i = 0; i < assemblyFileNames.Length; i++) { if (assemblyFileNames[i] == "UnityEngine.dll") { definition3 = assemblyDefinitions[i]; } } foreach (AssemblyDefinition definition4 in assemblyDefinitions) { if (definition4 != definition3) { IEnumerator <TypeReference> enumerator = definition4.MainModule.GetTypeReferences().GetEnumerator(); try { while (enumerator.MoveNext()) { TypeReference current = enumerator.Current; if (current.Namespace.StartsWith("UnityEngine")) { string item = current.Name; set.Add(item); } } } finally { if (enumerator == null) { } enumerator.Dispose(); } } } return(set); }
private static HashSet <string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies) { HashSet <string> stringSet = new HashSet <string>(); AssemblyReferenceChecker referenceChecker = new AssemblyReferenceChecker(); bool withMethods = false; bool ignoreSystemDlls = false; referenceChecker.CollectReferencesFromRoots(directory, (IEnumerable <string>)rootAssemblies, withMethods, 0.0f, ignoreSystemDlls); string[] assemblyFileNames = referenceChecker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = referenceChecker.GetAssemblyDefinitions(); foreach (AssemblyDefinition assemblyDefinition in assemblyDefinitions) { using (Collection <TypeDefinition> .Enumerator enumerator = assemblyDefinition.get_MainModule().get_Types().GetEnumerator()) { // ISSUE: explicit reference operation while (((Collection <TypeDefinition> .Enumerator)@enumerator).MoveNext()) { // ISSUE: explicit reference operation TypeDefinition current = ((Collection <TypeDefinition> .Enumerator)@enumerator).get_Current(); if (((TypeReference)current).get_Namespace().StartsWith("UnityEngine") && (current.get_Fields().get_Count() > 0 || current.get_Methods().get_Count() > 0 || current.get_Properties().get_Count() > 0)) { string name = ((TypeReference)current).get_Name(); stringSet.Add(name); } } } } AssemblyDefinition assemblyDefinition1 = (AssemblyDefinition)null; for (int index = 0; index < assemblyFileNames.Length; ++index) { if (assemblyFileNames[index] == "UnityEngine.dll") { assemblyDefinition1 = assemblyDefinitions[index]; } } foreach (AssemblyDefinition assemblyDefinition2 in assemblyDefinitions) { if (assemblyDefinition2 != assemblyDefinition1) { using (IEnumerator <TypeReference> enumerator = assemblyDefinition2.get_MainModule().GetTypeReferences().GetEnumerator()) { while (((IEnumerator)enumerator).MoveNext()) { TypeReference current = enumerator.Current; if (current.get_Namespace().StartsWith("UnityEngine")) { string name = current.get_Name(); stringSet.Add(name); } } } } } return(stringSet); }
private static HashSet<string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies) { HashSet<string> set = new HashSet<string>(); AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); bool withMethods = false; bool ignoreSystemDlls = false; checker.CollectReferencesFromRoots(directory, rootAssemblies, withMethods, 0f, ignoreSystemDlls); string[] assemblyFileNames = checker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = checker.GetAssemblyDefinitions(); foreach (AssemblyDefinition definition in assemblyDefinitions) { foreach (TypeDefinition definition2 in definition.MainModule.Types) { if (definition2.Namespace.StartsWith("UnityEngine") && (((definition2.Fields.Count > 0) || (definition2.Methods.Count > 0)) || (definition2.Properties.Count > 0))) { string name = definition2.Name; set.Add(name); } } } AssemblyDefinition definition3 = null; for (int i = 0; i < assemblyFileNames.Length; i++) { if (assemblyFileNames[i] == "UnityEngine.dll") { definition3 = assemblyDefinitions[i]; } } foreach (AssemblyDefinition definition4 in assemblyDefinitions) { if (definition4 != definition3) { IEnumerator<TypeReference> enumerator = definition4.MainModule.GetTypeReferences().GetEnumerator(); try { while (enumerator.MoveNext()) { TypeReference current = enumerator.Current; if (current.Namespace.StartsWith("UnityEngine")) { string item = current.Name; set.Add(item); } } } finally { if (enumerator == null) { } enumerator.Dispose(); } } } return set; }
private static HashSet <string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies, StrippingInfo strippingInfo) { HashSet <string> set = new HashSet <string>(); AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); bool collectMethods = false; bool ignoreSystemDlls = false; checker.CollectReferencesFromRoots(directory, rootAssemblies, collectMethods, 0f, ignoreSystemDlls); string[] assemblyFileNames = checker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = checker.GetAssemblyDefinitions(); foreach (AssemblyDefinition definition in assemblyDefinitions) { foreach (TypeDefinition definition2 in definition.MainModule.Types) { if (definition2.Namespace.StartsWith("UnityEngine") && (((definition2.Fields.Count > 0) || (definition2.Methods.Count > 0)) || (definition2.Properties.Count > 0))) { string name = definition2.Name; set.Add(name); if ((strippingInfo != null) && !AssemblyReferenceChecker.IsIgnoredSystemDll(definition.Name.Name)) { strippingInfo.RegisterDependency(name, "Required by Scripts"); } } } } AssemblyDefinition definition3 = null; for (int i = 0; i < assemblyFileNames.Length; i++) { if (assemblyFileNames[i] == "UnityEngine.dll") { definition3 = assemblyDefinitions[i]; } } foreach (AssemblyDefinition definition4 in assemblyDefinitions) { if (definition4 != definition3) { foreach (TypeReference reference in definition4.MainModule.GetTypeReferences()) { if (reference.Namespace.StartsWith("UnityEngine")) { string item = reference.Name; set.Add(item); if ((strippingInfo != null) && !AssemblyReferenceChecker.IsIgnoredSystemDll(definition4.Name.Name)) { strippingInfo.RegisterDependency(item, "Required by Scripts"); } } } } } return(set); }
private static HashSet <string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies) { HashSet <string> hashSet = new HashSet <string>(); AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker(); bool withMethods = false; bool ignoreSystemDlls = false; assemblyReferenceChecker.CollectReferencesFromRoots(directory, rootAssemblies, withMethods, 0f, ignoreSystemDlls); string[] assemblyFileNames = assemblyReferenceChecker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = assemblyReferenceChecker.GetAssemblyDefinitions(); AssemblyDefinition[] array = assemblyDefinitions; for (int i = 0; i < array.Length; i++) { AssemblyDefinition assemblyDefinition = array[i]; foreach (TypeDefinition current in assemblyDefinition.MainModule.Types) { if (current.Namespace.StartsWith("UnityEngine") && (current.Fields.Count > 0 || current.Methods.Count > 0 || current.Properties.Count > 0)) { string name = current.Name; hashSet.Add(name); } } } AssemblyDefinition assemblyDefinition2 = null; for (int j = 0; j < assemblyFileNames.Length; j++) { if (assemblyFileNames[j] == "UnityEngine.dll") { assemblyDefinition2 = assemblyDefinitions[j]; } } AssemblyDefinition[] array2 = assemblyDefinitions; for (int k = 0; k < array2.Length; k++) { AssemblyDefinition assemblyDefinition3 = array2[k]; if (assemblyDefinition3 != assemblyDefinition2) { foreach (TypeReference current2 in assemblyDefinition3.MainModule.GetTypeReferences()) { if (current2.Namespace.StartsWith("UnityEngine")) { string name2 = current2.Name; hashSet.Add(name2); } } } } return(hashSet); }
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"); } }
public static void GenerateDependencies(string strippedAssemblyDir, 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); AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); checker.CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0f, true); if (checker.HasDefinedMethod("OnGUI")) { nativeModules.Add("IMGUI"); } }
// Collects all types from managed assemblies. // Follows assembly references from given root assemblies. // Assemblies should be already stripped. private static HashSet <string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies, StrippingInfo strippingInfo) { if (AssemblyStripper.UseUnityLinkerEngineModuleStripping) { throw new NotSupportedException("Don't want to rely on this method when UnityLinker EMS is used"); } HashSet <string> foundTypes = new HashSet <string>(); AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); bool collectMethods = false; bool ignoreSystemDlls = false; checker.CollectReferencesFromRoots(directory, rootAssemblies, collectMethods, 0.0f, ignoreSystemDlls); { string[] fileNames = checker.GetAssemblyFileNames(); AssemblyDefinition[] assemblies = checker.GetAssemblyDefinitions(); foreach (AssemblyDefinition definition in assemblies) { foreach (TypeDefinition typeDefinition in definition.MainModule.Types) { if (typeDefinition.Namespace.StartsWith("UnityEngine")) { // Skip blank types if (typeDefinition.Fields.Count > 0 || typeDefinition.Methods.Count > 0 || typeDefinition.Properties.Count > 0) { string className = typeDefinition.Name; foundTypes.Add(className); if (strippingInfo != null) { if (!AssemblyReferenceChecker.IsIgnoredSystemDll(definition)) { strippingInfo.RegisterDependency(className, StrippingInfo.RequiredByScripts); } } } } } } AssemblyDefinition unityEngineAssemblyDefinition = null; AssemblyDefinition unityEngineUIAssemblyDefinition = null; for (int i = 0; i < fileNames.Length; i++) { if (fileNames[i] == "UnityEngine.dll") { unityEngineAssemblyDefinition = assemblies[i]; } // UnityEngine.UI references UnityEngine.Collider, which causes the inclusion of Physics and Physics2D modules if // UnityEngine.UI is referenced. UnityEngine.UI code is designed to only actually access Colliders if these modules // are used, so don't include references from UnityEngine.UI here. if (fileNames[i] == "Unity.ugui.dll") { unityEngineUIAssemblyDefinition = assemblies[i]; } } foreach (AssemblyDefinition definition in assemblies) { if (definition != unityEngineAssemblyDefinition && definition != unityEngineUIAssemblyDefinition) { foreach (TypeReference typeReference in definition.MainModule.GetTypeReferences()) { if (typeReference.Namespace.StartsWith("UnityEngine")) { string className = typeReference.Name; foundTypes.Add(className); if (strippingInfo != null) { if (!AssemblyReferenceChecker.IsIgnoredSystemDll(definition)) { strippingInfo.RegisterDependency(className, StrippingInfo.RequiredByScripts); } } } } } } } return(foundTypes); }
public static void GenerateDependencies(string strippedAssemblyDir, string icallsListFile, RuntimeClassRegistry rcr, bool doStripping, out HashSet <UnityType> nativeClasses, out HashSet <string> nativeModules, IIl2CppPlatformProvider platformProvider) { if (AssemblyStripper.UseUnityLinkerEngineModuleStripping) { GenerateDependencies2(strippedAssemblyDir, doStripping, out nativeClasses, out nativeModules); return; } var strippingInfo = platformProvider == null ? null : StrippingInfo.GetBuildReportData(platformProvider.buildReport); var userAssemblies = GetUserAssemblies(strippedAssemblyDir); // [1] Extract native classes from scene and scripts nativeClasses = doStripping ? GenerateNativeClassList(rcr, strippedAssemblyDir, userAssemblies, strippingInfo) : null; // Exclude module managers (GlobalGameManager) if no dependent classes are used. if (nativeClasses != null) { ExcludeModuleManagers(ref nativeClasses); } // [2] Prepare a list of modules to register nativeModules = GetNativeModulesToRegister(nativeClasses, strippingInfo); if (nativeClasses != null && icallsListFile != null) { // Get required modules from icall list file var icallModules = GetModulesFromICalls(icallsListFile); // Add GameManager classes for modules foreach (var module in icallModules) { if (!nativeModules.Contains(module)) { if (strippingInfo != null) { strippingInfo.RegisterDependency(StrippingInfo.ModuleName(module), StrippingInfo.RequiredByScripts); } } var moduleClasses = ModuleMetadata.GetModuleTypes(module); foreach (var klass in moduleClasses) { if (klass.IsDerivedFrom(GameManagerTypeInfo)) { nativeClasses.Add(klass); } } } nativeModules.UnionWith(icallModules); } ApplyManualStrippingOverrides(nativeClasses, nativeModules, strippingInfo); bool didAdd = true; if (platformProvider != null) { while (didAdd) { didAdd = false; foreach (var module in nativeModules.ToList()) { var dependecies = ModuleMetadata.GetModuleDependencies(module); foreach (var dependentModule in dependecies) { if (!nativeModules.Contains(dependentModule)) { nativeModules.Add(dependentModule); didAdd = true; } if (strippingInfo != null) { var moduleName = StrippingInfo.ModuleName(module); strippingInfo.RegisterDependency(StrippingInfo.ModuleName(dependentModule), "Required by " + moduleName); strippingInfo.SetIcon("Required by " + moduleName, $"package/com.unity.modules.{module.ToLower()}"); } } } } } if (nativeClasses != null) { RemoveClassesFromRemovedModules(nativeClasses, nativeModules); } AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); checker.CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0.0f, true); if (strippingInfo != null) { foreach (var module in nativeModules) { strippingInfo.AddModule(module); } strippingInfo.AddModule("Core"); } if (nativeClasses != null && strippingInfo != null && platformProvider != null) { InjectCustomDependencies(platformProvider.target, strippingInfo, nativeClasses, nativeModules); } }
private static HashSet <string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies, StrippingInfo strippingInfo) { HashSet <string> hashSet = new HashSet <string>(); AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker(); bool collectMethods = false; bool ignoreSystemDlls = false; assemblyReferenceChecker.CollectReferencesFromRoots(directory, rootAssemblies, collectMethods, 0f, ignoreSystemDlls); string[] assemblyFileNames = assemblyReferenceChecker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = assemblyReferenceChecker.GetAssemblyDefinitions(); AssemblyDefinition[] array = assemblyDefinitions; for (int i = 0; i < array.Length; i++) { AssemblyDefinition assemblyDefinition = array[i]; foreach (TypeDefinition current in assemblyDefinition.MainModule.Types) { if (current.Namespace.StartsWith("UnityEngine")) { if (current.Fields.Count > 0 || current.Methods.Count > 0 || current.Properties.Count > 0) { string name = current.Name; hashSet.Add(name); if (strippingInfo != null) { string name2 = assemblyDefinition.Name.Name; if (!AssemblyReferenceChecker.IsIgnoredSystemDll(name2)) { strippingInfo.RegisterDependency(name, "Required by Scripts"); } } } } } } AssemblyDefinition assemblyDefinition2 = null; AssemblyDefinition assemblyDefinition3 = null; for (int j = 0; j < assemblyFileNames.Length; j++) { if (assemblyFileNames[j] == "UnityEngine.dll") { assemblyDefinition2 = assemblyDefinitions[j]; } if (assemblyFileNames[j] == "UnityEngine.UI.dll") { assemblyDefinition3 = assemblyDefinitions[j]; } } AssemblyDefinition[] array2 = assemblyDefinitions; for (int k = 0; k < array2.Length; k++) { AssemblyDefinition assemblyDefinition4 = array2[k]; if (assemblyDefinition4 != assemblyDefinition2 && assemblyDefinition4 != assemblyDefinition3) { foreach (TypeReference current2 in assemblyDefinition4.MainModule.GetTypeReferences()) { if (current2.Namespace.StartsWith("UnityEngine")) { string name3 = current2.Name; hashSet.Add(name3); if (strippingInfo != null) { string name4 = assemblyDefinition4.Name.Name; if (!AssemblyReferenceChecker.IsIgnoredSystemDll(name4)) { strippingInfo.RegisterDependency(name3, "Required by Scripts"); } } } } } } return(hashSet); }
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); } }
private static HashSet<string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies) { HashSet<string> stringSet = new HashSet<string>(); AssemblyReferenceChecker referenceChecker = new AssemblyReferenceChecker(); bool withMethods = false; bool ignoreSystemDlls = false; referenceChecker.CollectReferencesFromRoots(directory, (IEnumerable<string>) rootAssemblies, withMethods, 0.0f, ignoreSystemDlls); string[] assemblyFileNames = referenceChecker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = referenceChecker.GetAssemblyDefinitions(); foreach (AssemblyDefinition assemblyDefinition in assemblyDefinitions) { using (Collection<TypeDefinition>.Enumerator enumerator = assemblyDefinition.get_MainModule().get_Types().GetEnumerator()) { // ISSUE: explicit reference operation while (((Collection<TypeDefinition>.Enumerator) @enumerator).MoveNext()) { // ISSUE: explicit reference operation TypeDefinition current = ((Collection<TypeDefinition>.Enumerator) @enumerator).get_Current(); if (((TypeReference) current).get_Namespace().StartsWith("UnityEngine") && (current.get_Fields().get_Count() > 0 || current.get_Methods().get_Count() > 0 || current.get_Properties().get_Count() > 0)) { string name = ((TypeReference) current).get_Name(); stringSet.Add(name); } } } } AssemblyDefinition assemblyDefinition1 = (AssemblyDefinition) null; for (int index = 0; index < assemblyFileNames.Length; ++index) { if (assemblyFileNames[index] == "UnityEngine.dll") assemblyDefinition1 = assemblyDefinitions[index]; } foreach (AssemblyDefinition assemblyDefinition2 in assemblyDefinitions) { if (assemblyDefinition2 != assemblyDefinition1) { using (IEnumerator<TypeReference> enumerator = assemblyDefinition2.get_MainModule().GetTypeReferences().GetEnumerator()) { while (((IEnumerator) enumerator).MoveNext()) { TypeReference current = enumerator.Current; if (current.get_Namespace().StartsWith("UnityEngine")) { string name = current.get_Name(); stringSet.Add(name); } } } } } return stringSet; }
private static HashSet <string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies, StrippingInfo strippingInfo) { HashSet <string> hashSet = new HashSet <string>(); AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker(); bool collectMethods = false; bool ignoreSystemDlls = false; assemblyReferenceChecker.CollectReferencesFromRoots(directory, rootAssemblies, collectMethods, 0f, ignoreSystemDlls); string[] assemblyFileNames = assemblyReferenceChecker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = assemblyReferenceChecker.GetAssemblyDefinitions(); AssemblyDefinition[] array = assemblyDefinitions; for (int i = 0; i < array.Length; i++) { AssemblyDefinition assemblyDefinition = array[i]; using (Collection <TypeDefinition> .Enumerator enumerator = assemblyDefinition.get_MainModule().get_Types().GetEnumerator()) { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.get_Current(); if (current.get_Namespace().StartsWith("UnityEngine")) { if (current.get_Fields().get_Count() > 0 || current.get_Methods().get_Count() > 0 || current.get_Properties().get_Count() > 0) { string name = current.get_Name(); hashSet.Add(name); if (strippingInfo != null) { string name2 = assemblyDefinition.get_Name().get_Name(); if (!AssemblyReferenceChecker.IsIgnoredSystemDll(name2)) { strippingInfo.RegisterDependency(name, "Required by Scripts"); } } } } } } } AssemblyDefinition assemblyDefinition2 = null; for (int j = 0; j < assemblyFileNames.Length; j++) { if (assemblyFileNames[j] == "UnityEngine.dll") { assemblyDefinition2 = assemblyDefinitions[j]; } } AssemblyDefinition[] array2 = assemblyDefinitions; for (int k = 0; k < array2.Length; k++) { AssemblyDefinition assemblyDefinition3 = array2[k]; if (assemblyDefinition3 != assemblyDefinition2) { foreach (TypeReference current2 in assemblyDefinition3.get_MainModule().GetTypeReferences()) { if (current2.get_Namespace().StartsWith("UnityEngine")) { string name3 = current2.get_Name(); hashSet.Add(name3); if (strippingInfo != null) { string name4 = assemblyDefinition3.get_Name().get_Name(); if (!AssemblyReferenceChecker.IsIgnoredSystemDll(name4)) { strippingInfo.RegisterDependency(name3, "Required by Scripts"); } } } } } } return(hashSet); }
private static HashSet<string> CollectManagedTypeReferencesFromRoots(string directory, string[] rootAssemblies) { HashSet<string> hashSet = new HashSet<string>(); AssemblyReferenceChecker assemblyReferenceChecker = new AssemblyReferenceChecker(); bool withMethods = false; bool ignoreSystemDlls = false; assemblyReferenceChecker.CollectReferencesFromRoots(directory, rootAssemblies, withMethods, 0f, ignoreSystemDlls); string[] assemblyFileNames = assemblyReferenceChecker.GetAssemblyFileNames(); AssemblyDefinition[] assemblyDefinitions = assemblyReferenceChecker.GetAssemblyDefinitions(); AssemblyDefinition[] array = assemblyDefinitions; for (int i = 0; i < array.Length; i++) { AssemblyDefinition assemblyDefinition = array[i]; foreach (TypeDefinition current in assemblyDefinition.MainModule.Types) { if (current.Namespace.StartsWith("UnityEngine") && (current.Fields.Count > 0 || current.Methods.Count > 0 || current.Properties.Count > 0)) { string name = current.Name; hashSet.Add(name); } } } AssemblyDefinition assemblyDefinition2 = null; for (int j = 0; j < assemblyFileNames.Length; j++) { if (assemblyFileNames[j] == "UnityEngine.dll") { assemblyDefinition2 = assemblyDefinitions[j]; } } AssemblyDefinition[] array2 = assemblyDefinitions; for (int k = 0; k < array2.Length; k++) { AssemblyDefinition assemblyDefinition3 = array2[k]; if (assemblyDefinition3 != assemblyDefinition2) { foreach (TypeReference current2 in assemblyDefinition3.MainModule.GetTypeReferences()) { if (current2.Namespace.StartsWith("UnityEngine")) { string name2 = current2.Name; hashSet.Add(name2); } } } } return hashSet; }
public static void GenerateDependencies(string strippedAssemblyDir, 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); AssemblyReferenceChecker checker = new AssemblyReferenceChecker(); checker.CollectReferencesFromRoots(strippedAssemblyDir, userAssemblies, true, 0f, true); if (checker.HasDefinedMethod("OnGUI")) { nativeModules.Add("IMGUI"); } }