summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs
diff options
context:
space:
mode:
authorShockah <me@shockah.pl>2022-02-09 20:38:14 +0100
committerShockah <me@shockah.pl>2022-02-09 20:38:14 +0100
commitee78ab3c3710639ec7eecb3d2edc7f26ff998407 (patch)
tree8f97fa3f9ed749da26e6a72c0f2a3ca9b01c004e /src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs
parent43ad219b75740ef71ad9bad496b00c076182619b (diff)
downloadSMAPI-ee78ab3c3710639ec7eecb3d2edc7f26ff998407.tar.gz
SMAPI-ee78ab3c3710639ec7eecb3d2edc7f26ff998407.tar.bz2
SMAPI-ee78ab3c3710639ec7eecb3d2edc7f26ff998407.zip
fix stack overflow for proxied types referencing each other
Diffstat (limited to 'src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs')
-rw-r--r--src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs b/src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs
index 8ce187bf..72b4254c 100644
--- a/src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs
+++ b/src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs
@@ -57,8 +57,17 @@ namespace StardewModdingAPI.Framework.Reflection
string proxyTypeName = $"StardewModdingAPI.Proxies.From<{sourceModID}_{interfaceType.FullName}>_To<{targetModID}_{targetType.FullName}>";
if (!this.Builders.TryGetValue(proxyTypeName, out InterfaceProxyBuilder builder))
{
- builder = new InterfaceProxyBuilder(this, proxyTypeName, this.ModuleBuilder, interfaceType, targetType, sourceModID, targetModID);
+ builder = new InterfaceProxyBuilder(targetType, proxyTypeName);
this.Builders[proxyTypeName] = builder;
+ try
+ {
+ builder.SetupProxyType(this, this.ModuleBuilder, interfaceType, sourceModID, targetModID);
+ }
+ catch
+ {
+ this.Builders.Remove(proxyTypeName);
+ throw;
+ }
}
return builder;
}