[fix] 修复ResolveClass某些情况下抛出NullReferenceException的bug

main
walon 2022-09-26 12:49:10 +08:00
parent d544133227
commit 3440f79421
2 changed files with 8 additions and 0 deletions

View File

@ -1,6 +1,7 @@
using dnlib.DotNet;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace HybridCLR.Editor.Meta
{
@ -61,6 +62,11 @@ namespace HybridCLR.Editor.Meta
return null;
}
TypeDef def = type.ResolveTypeDef();
if (def == null)
{
Debug.LogError($"type:{type} ResolveTypeDef() == null");
return null;
}
var klassInst = ctx != null ? sig.GenericArguments.Select(ga => MetaUtil.Inflate(ga, ctx)).ToList() : sig.GenericArguments.ToList();
return new GenericClass(def, klassInst);
}

View File

@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace HybridCLR.Editor.Meta
{
@ -87,6 +88,7 @@ namespace HybridCLR.Editor.Meta
methodDef = method.ResolveMethodDef();
if (methodDef == null)
{
Debug.LogError($"method:{method} ResolveMethodDef() == null");
return null;
}
if (method is MethodSpec methodSpec)