diff --git a/Editor/Commands/LinkGeneratorCommand.cs b/Editor/Commands/LinkGeneratorCommand.cs index 1a5b7b7..c545ff5 100644 --- a/Editor/Commands/LinkGeneratorCommand.cs +++ b/Editor/Commands/LinkGeneratorCommand.cs @@ -28,7 +28,7 @@ namespace HybridCLR.Editor.Commands List hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved; var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies)); - var refTypes = analyzer.CollectRefs(hotfixAssemblies, !ls.dontPreserveUnityEngineCoreTypesInLinkXml); + var refTypes = analyzer.CollectRefs(hotfixAssemblies); Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}"); var linkXmlWriter = new LinkXmlWriter(); diff --git a/Editor/Link/Analyzer.cs b/Editor/Link/Analyzer.cs index c2ca3e9..ffbb93d 100644 --- a/Editor/Link/Analyzer.cs +++ b/Editor/Link/Analyzer.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -22,48 +21,12 @@ namespace HybridCLR.Editor.Link _resolver = resolver; } - - public HashSet CollectRefs(List rootAssemblies, bool includeUnityEngineCoreTypes) - { - var typeRefs = new HashSet(TypeEqualityComparer.Instance); - CollectHotUpdateRefs(rootAssemblies, typeRefs); - - if (includeUnityEngineCoreTypes) - { - CollectUnityEngineCoreTypes(typeRefs); - } - return typeRefs; - } - - private void CollectUnityEngineCoreTypes(HashSet preservedTypes) - { - Debug.Log("CollectUnityEngineCoreTypes"); - string unityEngineDllPath = $"{EditorApplication.applicationContentsPath}/Managed/UnityEngine"; - - var assCollector = new AssemblyCache(_resolver); - foreach (string unityEngineDll in Directory.GetFiles(unityEngineDllPath, "UnityEngine.*.dll", SearchOption.AllDirectories)) - { - // because of bug of unity 2019.4.x, preserving types in this dll will cause crash in android build - if (unityEngineDll.EndsWith("UnityEngine.PerformanceReportingModule.dll", StringComparison.InvariantCulture)) - { - continue; - } - ModuleDefMD mod = assCollector.LoadModuleFromFileWithoutCache(unityEngineDll); - foreach (TypeDef type in mod.GetTypes()) - { - if (type.Methods.Any(m => m.IsInternalCall || m.IsPinvokeImpl)) - { - preservedTypes.Add(type); - } - } - } - } - - public void CollectHotUpdateRefs(List rootAssemblies, HashSet preservedTypes) + public HashSet CollectRefs(List rootAssemblies) { var assCollector = new AssemblyCache(_resolver); var rootAssemblyNames = new HashSet(rootAssemblies); + var typeRefs = new HashSet(TypeEqualityComparer.Instance); foreach (var rootAss in rootAssemblies) { var dnAss = assCollector.LoadModule(rootAss, false); @@ -76,10 +39,11 @@ namespace HybridCLR.Editor.Link } if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString())) { - preservedTypes.Add(type); + typeRefs.Add(type); } } } + return typeRefs; } } } diff --git a/Editor/Link/LinkXmlWriter.cs b/Editor/Link/LinkXmlWriter.cs index 2667308..ab5d448 100644 --- a/Editor/Link/LinkXmlWriter.cs +++ b/Editor/Link/LinkXmlWriter.cs @@ -11,7 +11,7 @@ namespace HybridCLR.Editor.Link { internal class LinkXmlWriter { - public void Write(string outputLinkXmlFile, HashSet refTypes) + public void Write(string outputLinkXmlFile, HashSet refTypes) { string parentDir = Directory.GetParent(outputLinkXmlFile).FullName; Directory.CreateDirectory(parentDir); diff --git a/Editor/Meta/AssemblyCacheBase.cs b/Editor/Meta/AssemblyCacheBase.cs index 4955223..04f2d15 100644 --- a/Editor/Meta/AssemblyCacheBase.cs +++ b/Editor/Meta/AssemblyCacheBase.cs @@ -71,13 +71,6 @@ namespace HybridCLR.Editor.Meta return mod; } - public ModuleDefMD LoadModuleFromFileWithoutCache(string dllPath) - { - ModuleDefMD mod = ModuleDefMD.Load(File.ReadAllBytes(dllPath), _modCtx); - mod.EnableTypeDefFindCache = true; - return mod; - } - private void LoadNetStandard() { string netstandardDllPath = _assemblyPathResolver.ResolveAssembly("netstandard", false); diff --git a/Editor/Settings/HybridCLRSettingProvider.cs b/Editor/Settings/HybridCLRSettingProvider.cs index 47da29d..122187c 100644 --- a/Editor/Settings/HybridCLRSettingProvider.cs +++ b/Editor/Settings/HybridCLRSettingProvider.cs @@ -21,7 +21,6 @@ namespace HybridCLR.Editor.Settings private SerializedProperty _externalHotUpdateAssembliyDirs; private SerializedProperty _strippedAOTDllOutputRootDir; private SerializedProperty _patchAOTAssemblies; - private SerializedProperty _dontPreserveUnityEngineCoreTypesInLinkXml; private SerializedProperty _outputLinkFile; private SerializedProperty _outputAOTGenericReferenceFile; private SerializedProperty _maxGenericReferenceIteration; @@ -52,7 +51,6 @@ namespace HybridCLR.Editor.Settings _externalHotUpdateAssembliyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs"); _strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir"); _patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies"); - _dontPreserveUnityEngineCoreTypesInLinkXml = _serializedObject.FindProperty("dontPreserveUnityEngineCoreTypesInLinkXml"); _outputLinkFile = _serializedObject.FindProperty("outputLinkFile"); _outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile"); _maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration"); @@ -142,7 +140,6 @@ namespace HybridCLR.Editor.Settings EditorGUILayout.PropertyField(_externalHotUpdateAssembliyDirs); EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir); EditorGUILayout.PropertyField(_patchAOTAssemblies); - EditorGUILayout.PropertyField(_dontPreserveUnityEngineCoreTypesInLinkXml); EditorGUILayout.PropertyField(_outputLinkFile); EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile); EditorGUILayout.PropertyField(_maxGenericReferenceIteration); diff --git a/Editor/Settings/HybridCLRSettings.cs b/Editor/Settings/HybridCLRSettings.cs index bcf3578..ef0e153 100644 --- a/Editor/Settings/HybridCLRSettings.cs +++ b/Editor/Settings/HybridCLRSettings.cs @@ -39,9 +39,6 @@ namespace HybridCLR.Editor.Settings [Tooltip("supplementary metadata assembly names(without .dll suffix)")] public string[] patchAOTAssemblies; - [Tooltip("don't preserve UnityEngine core types in link.xml")] - public bool dontPreserveUnityEngineCoreTypesInLinkXml; - [Tooltip("output file of automatic generated link.xml by scanning hot update assemblies")] public string outputLinkFile = "HybridCLRGenerate/link.xml";