From 7b0c7f2f9680c17ed12d0740a40b2c3bcb3f0e5b Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Tue, 14 Dec 2021 20:50:01 -0600 Subject: [PATCH] Fix GeneratedConfig.WriteSyncObject --- IPA.Loader/Config/Config.cs | 2 +- IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs | 4 ++-- IPA.Loader/Loader/PluginInitInjector.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/IPA.Loader/Config/Config.cs b/IPA.Loader/Config/Config.cs index 0e4c19f1..d818e5b8 100644 --- a/IPA.Loader/Config/Config.cs +++ b/IPA.Loader/Config/Config.cs @@ -81,7 +81,7 @@ namespace IPA.Config /// Registers a to use for configs. /// /// the type to register - public static void Register() where T : IConfigProvider => Register(typeof(T)); + public static void Register() where T : IConfigProvider, new() => Register(typeof(T)); /// /// Registers a to use for configs. diff --git a/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs b/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs index c80ef1ea..c11af324 100644 --- a/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs +++ b/IPA.Loader/Config/Stores/GeneratedStoreImpl/MakeCreator.cs @@ -436,7 +436,7 @@ namespace IPA.Config.Stores var IConfigStore_ReadFrom = IConfigStore_t.GetMethod(nameof(IConfigStore.ReadFrom)); #region IConfigStore.SyncObject - var syncObjProp = typeBuilder.DefineProperty(nameof(IConfigStore.SyncObject), PropertyAttributes.None, typeof(WaitHandle), null); + var syncObjProp = typeBuilder.DefineProperty(nameof(IConfigStore.SyncObject), PropertyAttributes.None, IConfigStore_GetSyncObject.ReturnType, null); var syncObjPropGet = typeBuilder.DefineMethod($"{nameof(IConfigStore.SyncObject)}", virtualPropertyMethodAttr, syncObjProp.PropertyType, Type.EmptyTypes); syncObjProp.SetGetMethod(syncObjPropGet); typeBuilder.DefineMethodOverride(syncObjPropGet, IConfigStore_GetSyncObject); @@ -451,7 +451,7 @@ namespace IPA.Config.Stores } #endregion #region IConfigStore.WriteSyncObject - var writeSyncObjProp = typeBuilder.DefineProperty(nameof(IConfigStore.WriteSyncObject), PropertyAttributes.None, typeof(WaitHandle), null); + var writeSyncObjProp = typeBuilder.DefineProperty(nameof(IConfigStore.WriteSyncObject), PropertyAttributes.None, IConfigStore_GetWriteSyncObject.ReturnType, null); var writeSyncObjPropGet = typeBuilder.DefineMethod($"{nameof(IConfigStore.WriteSyncObject)}", virtualPropertyMethodAttr, writeSyncObjProp.PropertyType, Type.EmptyTypes); writeSyncObjProp.SetGetMethod(writeSyncObjPropGet); typeBuilder.DefineMethodOverride(writeSyncObjPropGet, IConfigStore_GetWriteSyncObject); diff --git a/IPA.Loader/Loader/PluginInitInjector.cs b/IPA.Loader/Loader/PluginInitInjector.cs index c7b42f43..0d5052e5 100644 --- a/IPA.Loader/Loader/PluginInitInjector.cs +++ b/IPA.Loader/Loader/PluginInitInjector.cs @@ -152,10 +152,10 @@ namespace IPA.Loader if (!target.IsAssignableFrom(source)) return null; if (!target.IsInterface && !source.IsSubclassOf(target)) return int.MinValue; - int value = 0; + int value = int.MaxValue - 1; while (true) { - if (source == null) return value; + if (source is null) return value; if (target.IsInterface && source.GetInterfaces().Contains(target)) return value; else if (target == source)