Weaver.ImportCorLibType: avoid MixIn exception when calling ImportReference with a null type. Log the type that we failed to resolve instead.

This commit is contained in:
vis2k 2019-04-11 22:09:14 +02:00
parent 286983a8f8
commit eb4b2f40c5

View File

@ -262,7 +262,12 @@ static void SetupCorLib()
static TypeReference ImportCorLibType(string fullName) static TypeReference ImportCorLibType(string fullName)
{ {
TypeDefinition type = CorLibModule.GetType(fullName) ?? CorLibModule.ExportedTypes.First(t => t.FullName == fullName).Resolve(0); TypeDefinition type = CorLibModule.GetType(fullName) ?? CorLibModule.ExportedTypes.First(t => t.FullName == fullName).Resolve(0);
return CurrentAssembly.MainModule.ImportReference(type); if (type != null)
{
return CurrentAssembly.MainModule.ImportReference(type);
}
Error("Failed to import mscorlib type: " + fullName + " because Resolve failed. (Might happen when trying to Resolve in NetStandard dll, see also: https://github.com/vis2k/Mirror/issues/791)");
return null;
} }
static void SetupTargetTypes() static void SetupTargetTypes()