summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/SMAPI/Framework/Reflection/InterfaceProxyBuilder.cs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/Reflection/InterfaceProxyBuilder.cs b/src/SMAPI/Framework/Reflection/InterfaceProxyBuilder.cs
index 99aea75c..1b6bf1d6 100644
--- a/src/SMAPI/Framework/Reflection/InterfaceProxyBuilder.cs
+++ b/src/SMAPI/Framework/Reflection/InterfaceProxyBuilder.cs
@@ -265,12 +265,24 @@ namespace StardewModdingAPI.Framework.Reflection
}
else
{
- // this.Glue.CreateInstanceForProxyTypeName(proxyTypeName, this.Instance.Call(args))
+ var resultLocal = il.DeclareLocal(typeof(object)); // we store both unmodified and modified in here
+ EmitCallInstance();
+ il.Emit(OpCodes.Stloc, resultLocal);
+
+ // if (unmodifiedResultLocal == null) jump
+ var isNullLabel = il.DefineLabel();
+ il.Emit(OpCodes.Ldloc, resultLocal);
+ il.Emit(OpCodes.Brfalse, isNullLabel);
+
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldfld, glueField);
il.Emit(OpCodes.Ldstr, returnValueProxyTypeName);
- EmitCallInstance();
+ il.Emit(OpCodes.Ldloc, resultLocal);
il.Emit(OpCodes.Call, CreateInstanceForProxyTypeNameMethod);
+ il.Emit(OpCodes.Stloc, resultLocal);
+
+ il.MarkLabel(isNullLabel);
+ il.Emit(OpCodes.Ldloc, resultLocal);
}
// return result