From 9066e6e7ed7450335eb22bfd7f0c39ee0917a398 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sat, 18 Nov 2023 23:13:15 -0600 Subject: [PATCH] Prefer shared types in plugin loader --- Source/ACE.Server/Mods/ModContainer.cs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/Source/ACE.Server/Mods/ModContainer.cs b/Source/ACE.Server/Mods/ModContainer.cs index 984513cd67..2f65002322 100644 --- a/Source/ACE.Server/Mods/ModContainer.cs +++ b/Source/ACE.Server/Mods/ModContainer.cs @@ -16,7 +16,7 @@ public class ModContainer public ModMetadata Meta { get; set; } public ModStatus Status = ModStatus.Unloaded; - public Assembly ModAssembly { get; set; } + public Assembly ModAssembly { get; set; } public Type ModType { get; set; } public IHarmonyMod Instance { get; set; } @@ -36,7 +36,6 @@ public class ModContainer ModAssembly.ManifestModule.ScopeName.Replace(".dll", "." + ModMetadata.TYPENAME); public PluginLoader Loader { get; private set; } - //private FileSystemWatcher _dllWatcher; private DateTime _lastChange = DateTime.Now; /// @@ -50,31 +49,16 @@ public void Initialize() return; } - //Watching for changes in the dll might be needed if it has unreleased resources? - //https://github.com/natemcmaster/DotNetCorePlugins/issues/86 - //_dllWatcher = new FileSystemWatcher() - //{ - // Path = FolderPath, - // //Filter = DllPath, - // Filter = $"{FolderName}.dll", - // EnableRaisingEvents = true, - // NotifyFilter = NotifyFilters.LastWrite //? - //}; - //_dllWatcher.Changed += ModDll_Changed; - //_dllWatcher.Created += ModDll_Created; - //_dllWatcher.Renamed += ModDll_Renamed; - //_dllWatcher.Deleted += ModDll_Changed; - //_dllWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName; - Loader = PluginLoader.CreateFromAssemblyFile( assemblyFile: DllPath, isUnloadable: true, - sharedTypes: new Type[] { }, + sharedTypes: new Type[] { }, configure: config => { config.EnableHotReload = Meta.HotReload; - config.IsLazyLoaded = false; //? - } + config.IsLazyLoaded = false; + config.PreferSharedTypes = true; + } ); Loader.Reloaded += Reload;