Skip to content

Commit 0c99afd

Browse files
committed
[fix] fix the bug where MissingMetadataChecker can't detect references to newly added AOT assemblies.
1 parent 2458c9a commit 0c99afd

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

Editor/HotUpdate/MissingMetadataChecker.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ public class MissingMetadataChecker
1313
{
1414
private readonly HashSet<string> _aotAssNames;
1515

16+
private readonly HashSet<string> _hotUpdateAssNames;
17+
1618
private readonly AssemblyCache _assCache;
1719

18-
public MissingMetadataChecker(string aotDllDir, IEnumerable<string> excludeDllNames)
20+
public MissingMetadataChecker(string aotDllDir, IEnumerable<string> hotUpdateAssNames)
1921
{
2022

21-
var excludeDllNameSet = new HashSet<string>(excludeDllNames ?? new List<string>());
23+
_hotUpdateAssNames = new HashSet<string>(hotUpdateAssNames ?? new List<string>());
2224
_aotAssNames = new HashSet<string>();
2325
foreach (var aotFile in Directory.GetFiles(aotDllDir, "*.dll"))
2426
{
2527
string aotAssName = Path.GetFileNameWithoutExtension(aotFile);
26-
if (excludeDllNameSet.Contains(aotAssName))
28+
if (_hotUpdateAssNames.Contains(aotAssName))
2729
{
2830
continue;
2931
}
@@ -34,6 +36,8 @@ public MissingMetadataChecker(string aotDllDir, IEnumerable<string> excludeDllNa
3436

3537
public bool Check(string hotUpdateDllPath)
3638
{
39+
bool anyMissing = false;
40+
3741
ModuleDef mod = ModuleDefMD.Load(File.ReadAllBytes(hotUpdateDllPath), _assCache.ModCtx);
3842

3943
foreach (var refass in mod.GetAssemblyRefs())
@@ -43,9 +47,13 @@ public bool Check(string hotUpdateDllPath)
4347
{
4448
_assCache.LoadModule(refass.Name, true);
4549
}
50+
else if (!_hotUpdateAssNames.Contains(refAssName))
51+
{
52+
UnityEngine.Debug.LogError($"Missing AOT Assembly: {refAssName}");
53+
anyMissing = true;
54+
}
4655
}
4756

48-
bool anyMissing = false;
4957

5058
foreach (TypeRef typeRef in mod.GetTypeRefs())
5159
{

0 commit comments

Comments
 (0)