Skip to content

Commit b8dd2be

Browse files
committed
[revert] Revert "[new] support preserve UnityEngine core types when GenerateLinkXml"
This reverts commit 82163d2.
1 parent de7b606 commit b8dd2be

6 files changed

Lines changed: 6 additions & 55 deletions

File tree

Editor/Commands/LinkGeneratorCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static void GenerateLinkXml(BuildTarget target)
2828
List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
2929

3030
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies));
31-
var refTypes = analyzer.CollectRefs(hotfixAssemblies, !ls.dontPreserveUnityEngineCoreTypesInLinkXml);
31+
var refTypes = analyzer.CollectRefs(hotfixAssemblies);
3232

3333
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
3434
var linkXmlWriter = new LinkXmlWriter();

Editor/Link/Analyzer.cs

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.IO;
43
using System.Linq;
54
using System.Reflection;
65
using System.Text;
@@ -22,48 +21,12 @@ public Analyzer(IAssemblyResolver resolver)
2221
_resolver = resolver;
2322
}
2423

25-
26-
public HashSet<ITypeDefOrRef> CollectRefs(List<string> rootAssemblies, bool includeUnityEngineCoreTypes)
27-
{
28-
var typeRefs = new HashSet<ITypeDefOrRef>(TypeEqualityComparer.Instance);
29-
CollectHotUpdateRefs(rootAssemblies, typeRefs);
30-
31-
if (includeUnityEngineCoreTypes)
32-
{
33-
CollectUnityEngineCoreTypes(typeRefs);
34-
}
35-
return typeRefs;
36-
}
37-
38-
private void CollectUnityEngineCoreTypes(HashSet<ITypeDefOrRef> preservedTypes)
39-
{
40-
Debug.Log("CollectUnityEngineCoreTypes");
41-
string unityEngineDllPath = $"{EditorApplication.applicationContentsPath}/Managed/UnityEngine";
42-
43-
var assCollector = new AssemblyCache(_resolver);
44-
foreach (string unityEngineDll in Directory.GetFiles(unityEngineDllPath, "UnityEngine.*.dll", SearchOption.AllDirectories))
45-
{
46-
// because of bug of unity 2019.4.x, preserving types in this dll will cause crash in android build
47-
if (unityEngineDll.EndsWith("UnityEngine.PerformanceReportingModule.dll", StringComparison.InvariantCulture))
48-
{
49-
continue;
50-
}
51-
ModuleDefMD mod = assCollector.LoadModuleFromFileWithoutCache(unityEngineDll);
52-
foreach (TypeDef type in mod.GetTypes())
53-
{
54-
if (type.Methods.Any(m => m.IsInternalCall || m.IsPinvokeImpl))
55-
{
56-
preservedTypes.Add(type);
57-
}
58-
}
59-
}
60-
}
61-
62-
public void CollectHotUpdateRefs(List<string> rootAssemblies, HashSet<ITypeDefOrRef> preservedTypes)
24+
public HashSet<TypeRef> CollectRefs(List<string> rootAssemblies)
6325
{
6426
var assCollector = new AssemblyCache(_resolver);
6527
var rootAssemblyNames = new HashSet<string>(rootAssemblies);
6628

29+
var typeRefs = new HashSet<TypeRef>(TypeEqualityComparer.Instance);
6730
foreach (var rootAss in rootAssemblies)
6831
{
6932
var dnAss = assCollector.LoadModule(rootAss, false);
@@ -76,10 +39,11 @@ public void CollectHotUpdateRefs(List<string> rootAssemblies, HashSet<ITypeDefOr
7639
}
7740
if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString()))
7841
{
79-
preservedTypes.Add(type);
42+
typeRefs.Add(type);
8043
}
8144
}
8245
}
46+
return typeRefs;
8347
}
8448
}
8549
}

Editor/Link/LinkXmlWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace HybridCLR.Editor.Link
1111
{
1212
internal class LinkXmlWriter
1313
{
14-
public void Write(string outputLinkXmlFile, HashSet<ITypeDefOrRef> refTypes)
14+
public void Write(string outputLinkXmlFile, HashSet<TypeRef> refTypes)
1515
{
1616
string parentDir = Directory.GetParent(outputLinkXmlFile).FullName;
1717
Directory.CreateDirectory(parentDir);

Editor/Meta/AssemblyCacheBase.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ public ModuleDefMD LoadModule(string moduleName, bool loadReferenceAssemblies =
7171
return mod;
7272
}
7373

74-
public ModuleDefMD LoadModuleFromFileWithoutCache(string dllPath)
75-
{
76-
ModuleDefMD mod = ModuleDefMD.Load(File.ReadAllBytes(dllPath), _modCtx);
77-
mod.EnableTypeDefFindCache = true;
78-
return mod;
79-
}
80-
8174
private void LoadNetStandard()
8275
{
8376
string netstandardDllPath = _assemblyPathResolver.ResolveAssembly("netstandard", false);

Editor/Settings/HybridCLRSettingProvider.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class HybridCLRSettingsProvider : SettingsProvider
2121
private SerializedProperty _externalHotUpdateAssembliyDirs;
2222
private SerializedProperty _strippedAOTDllOutputRootDir;
2323
private SerializedProperty _patchAOTAssemblies;
24-
private SerializedProperty _dontPreserveUnityEngineCoreTypesInLinkXml;
2524
private SerializedProperty _outputLinkFile;
2625
private SerializedProperty _outputAOTGenericReferenceFile;
2726
private SerializedProperty _maxGenericReferenceIteration;
@@ -52,7 +51,6 @@ private void InitGUI()
5251
_externalHotUpdateAssembliyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs");
5352
_strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir");
5453
_patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies");
55-
_dontPreserveUnityEngineCoreTypesInLinkXml = _serializedObject.FindProperty("dontPreserveUnityEngineCoreTypesInLinkXml");
5654
_outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
5755
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
5856
_maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration");
@@ -142,7 +140,6 @@ public override void OnGUI(string searchContext)
142140
EditorGUILayout.PropertyField(_externalHotUpdateAssembliyDirs);
143141
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
144142
EditorGUILayout.PropertyField(_patchAOTAssemblies);
145-
EditorGUILayout.PropertyField(_dontPreserveUnityEngineCoreTypesInLinkXml);
146143
EditorGUILayout.PropertyField(_outputLinkFile);
147144
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
148145
EditorGUILayout.PropertyField(_maxGenericReferenceIteration);

Editor/Settings/HybridCLRSettings.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ public class HybridCLRSettings : ScriptableSingleton<HybridCLRSettings>
3939
[Tooltip("supplementary metadata assembly names(without .dll suffix)")]
4040
public string[] patchAOTAssemblies;
4141

42-
[Tooltip("don't preserve UnityEngine core types in link.xml")]
43-
public bool dontPreserveUnityEngineCoreTypesInLinkXml;
44-
4542
[Tooltip("output file of automatic generated link.xml by scanning hot update assemblies")]
4643
public string outputLinkFile = "HybridCLRGenerate/link.xml";
4744

0 commit comments

Comments
 (0)