adding static check before adding this arg (#1668)

This commit is contained in:
James Frowen 2020-04-07 18:50:48 +01:00 committed by GitHub
parent 60678d9bc7
commit 7a06815d75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,7 +216,11 @@ public static MethodDefinition ProcessSyncVarSet(TypeDefinition td, FieldDefinit
setWorker.Append(setWorker.Create(OpCodes.Call, Weaver.setSyncVarHookGuard));
// call hook (oldValue, newValue)
setWorker.Append(setWorker.Create(OpCodes.Ldarg_0));
// dont add this (Ldarg_0) if method is static
if (!hookFunctionMethod.IsStatic)
{
setWorker.Append(setWorker.Create(OpCodes.Ldarg_0));
}
setWorker.Append(setWorker.Create(OpCodes.Ldloc, oldValue));
setWorker.Append(setWorker.Create(OpCodes.Ldarg_1));
setWorker.Append(setWorker.Create(OpCodes.Callvirt, hookFunctionMethod));