weaver: apply generic arguments as you climb up the base types

This commit is contained in:
JohnCorby 2022-03-04 01:13:22 -08:00
parent e54892367f
commit 156ff291e3
2 changed files with 10 additions and 6 deletions

View File

@ -3,9 +3,9 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" />
<PackageReference Include="OWML" Version="2.3.2" />
<PackageReference Include="HarmonyX" Version="2.9.0" />
<Reference Include="../Mirror/*.dll" />
</ItemGroup>
</Project>

View File

@ -52,9 +52,11 @@ public static class QSBReaderWriterProcessor
{
var argType = calledMethod.GenericArguments[0];
if (argType is GenericParameter genericParameter && genericParameter.Owner == currentTypeDef)
if (currentType is GenericInstanceType genericInstanceType &&
argType is GenericParameter genericParameter &&
genericParameter.Owner == currentTypeDef)
{
argType = ((GenericInstanceType)currentType).GenericArguments[genericParameter.Position];
argType = genericInstanceType.GenericArguments[genericParameter.Position];
}
writers.GetWriteFunc(argType, ref weavingFailed);
@ -65,9 +67,11 @@ public static class QSBReaderWriterProcessor
{
var argType = calledMethod.GenericArguments[0];
if (argType is GenericParameter genericParameter && genericParameter.Owner == currentTypeDef)
if (currentType is GenericInstanceType genericInstanceType &&
argType is GenericParameter genericParameter &&
genericParameter.Owner == currentTypeDef)
{
argType = ((GenericInstanceType)currentType).GenericArguments[genericParameter.Position];
argType = genericInstanceType.GenericArguments[genericParameter.Position];
}
readers.GetReadFunc(argType, ref weavingFailed);
@ -76,7 +80,7 @@ public static class QSBReaderWriterProcessor
}
}
currentType = currentTypeDef.BaseType;
currentType = currentTypeDef.BaseType?.ApplyGenericParameters(currentType);
}
}