Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer shared types in plugin loader #4060

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions Source/ACE.Server/Mods/ModContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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;

/// <summary>
Expand All @@ -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;

Expand Down