From bc823f47950d770d49622fb6194166bb214d71f0 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sun, 8 Jan 2023 08:27:31 +1000 Subject: [PATCH] Clear props of type `ApiContainer` when clearing injected API props --- src/BizHawk.Client.Common/Api/ApiInjector.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.Common/Api/ApiInjector.cs b/src/BizHawk.Client.Common/Api/ApiInjector.cs index 5ae04eac19..352fee3566 100644 --- a/src/BizHawk.Client.Common/Api/ApiInjector.cs +++ b/src/BizHawk.Client.Common/Api/ApiInjector.cs @@ -17,7 +17,12 @@ namespace BizHawk.Client.Common { Type targetType = target.GetType(); object[] tmp = new object[1]; - + foreach (var mi in targetType.GetProperties(ReflectionExtensions.DI_TARGET_PROPS) + .Where(static pi => pi.PropertyType == typeof(ApiContainer)) + .Select(static pi => pi.SetMethod)) + { + mi?.Invoke(target, new object[] { null }); + } foreach (var propinfo in targetType.GetPropertiesWithAttrib(typeof(RequiredApiAttribute)) .Concat(targetType.GetPropertiesWithAttrib(typeof(OptionalApiAttribute))))