From ee78ab3c3710639ec7eecb3d2edc7f26ff998407 Mon Sep 17 00:00:00 2001 From: Shockah Date: Wed, 9 Feb 2022 20:38:14 +0100 Subject: fix stack overflow for proxied types referencing each other --- src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Framework/Reflection/InterfaceProxyFactory.cs') 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; } -- cgit