From 0c99afd58ec3a54b4026cb23bd1c31a2d68db9d6 Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 18 Dec 2024 18:21:37 +0800 Subject: [PATCH] [fix] fix the bug where MissingMetadataChecker can't detect references to newly added AOT assemblies. --- Editor/HotUpdate/MissingMetadataChecker.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Editor/HotUpdate/MissingMetadataChecker.cs b/Editor/HotUpdate/MissingMetadataChecker.cs index b7f8ba9..2459b48 100644 --- a/Editor/HotUpdate/MissingMetadataChecker.cs +++ b/Editor/HotUpdate/MissingMetadataChecker.cs @@ -13,17 +13,19 @@ namespace HybridCLR.Editor.HotUpdate { private readonly HashSet _aotAssNames; + private readonly HashSet _hotUpdateAssNames; + private readonly AssemblyCache _assCache; - public MissingMetadataChecker(string aotDllDir, IEnumerable excludeDllNames) + public MissingMetadataChecker(string aotDllDir, IEnumerable hotUpdateAssNames) { - var excludeDllNameSet = new HashSet(excludeDllNames ?? new List()); + _hotUpdateAssNames = new HashSet(hotUpdateAssNames ?? new List()); _aotAssNames = new HashSet(); foreach (var aotFile in Directory.GetFiles(aotDllDir, "*.dll")) { string aotAssName = Path.GetFileNameWithoutExtension(aotFile); - if (excludeDllNameSet.Contains(aotAssName)) + if (_hotUpdateAssNames.Contains(aotAssName)) { continue; } @@ -34,6 +36,8 @@ namespace HybridCLR.Editor.HotUpdate public bool Check(string hotUpdateDllPath) { + bool anyMissing = false; + ModuleDef mod = ModuleDefMD.Load(File.ReadAllBytes(hotUpdateDllPath), _assCache.ModCtx); foreach (var refass in mod.GetAssemblyRefs()) @@ -43,9 +47,13 @@ namespace HybridCLR.Editor.HotUpdate { _assCache.LoadModule(refass.Name, true); } + else if (!_hotUpdateAssNames.Contains(refAssName)) + { + UnityEngine.Debug.LogError($"Missing AOT Assembly: {refAssName}"); + anyMissing = true; + } } - bool anyMissing = false; foreach (TypeRef typeRef in mod.GetTypeRefs()) {