summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShockah <me@shockah.pl>2022-02-09 21:02:41 +0100
committerShockah <me@shockah.pl>2022-02-09 21:02:41 +0100
commit354527bb810d06f69f2a8c45d1a23f294d228caf (patch)
tree4e4b765acd219e2aa47330d004a0a48648fbd3e2
parent688fccc0246be6756a07933696a235dca8f1a395 (diff)
downloadSMAPI-354527bb810d06f69f2a8c45d1a23f294d228caf.tar.gz
SMAPI-354527bb810d06f69f2a8c45d1a23f294d228caf.tar.bz2
SMAPI-354527bb810d06f69f2a8c45d1a23f294d228caf.zip
stop proxying nulls
-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