mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
fix: NRE when loading devPlugins without a manifest
This commit is contained in:
parent
ebdf641e3c
commit
25fbfd5cc1
3 changed files with 14 additions and 14 deletions
|
|
@ -21,8 +21,8 @@ namespace Dalamud.Plugin.Internal
|
||||||
// Ref to Dalamud.Configuration.DevPluginSettings
|
// Ref to Dalamud.Configuration.DevPluginSettings
|
||||||
private readonly DevPluginSettings devSettings;
|
private readonly DevPluginSettings devSettings;
|
||||||
|
|
||||||
private FileSystemWatcher fileWatcher;
|
private FileSystemWatcher? fileWatcher;
|
||||||
private CancellationTokenSource fileWatcherTokenSource;
|
private CancellationTokenSource fileWatcherTokenSource = new();
|
||||||
private int reloadCounter;
|
private int reloadCounter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -125,7 +125,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
var current = Interlocked.Increment(ref this.reloadCounter);
|
var current = Interlocked.Increment(ref this.reloadCounter);
|
||||||
|
|
||||||
Task.Delay(500).ContinueWith(
|
Task.Delay(500).ContinueWith(
|
||||||
task =>
|
_ =>
|
||||||
{
|
{
|
||||||
if (this.fileWatcherTokenSource.IsCancellationRequested)
|
if (this.fileWatcherTokenSource.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,9 @@ namespace Dalamud.Plugin.Internal
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.Manifest = manifest;
|
this.Manifest = manifest;
|
||||||
|
|
||||||
|
if (!manifest.CheckSanity())
|
||||||
|
throw new InvalidOperationException("Plugin manifest is not sane.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This converts from the ".disabled" file feature to the manifest instead.
|
// This converts from the ".disabled" file feature to the manifest instead.
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,12 @@ namespace Dalamud.Plugin.Internal
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event that fires when the installed plugins have changed.
|
/// An event that fires when the installed plugins have changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action OnInstalledPluginsChanged;
|
public event Action? OnInstalledPluginsChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An event that fires when the available plugins have changed.
|
/// An event that fires when the available plugins have changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action OnAvailablePluginsChanged;
|
public event Action? OnAvailablePluginsChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of all loaded plugins.
|
/// Gets a list of all loaded plugins.
|
||||||
|
|
@ -512,16 +512,13 @@ namespace Dalamud.Plugin.Internal
|
||||||
/// <param name="isBoot">If this plugin is being loaded at boot.</param>
|
/// <param name="isBoot">If this plugin is being loaded at boot.</param>
|
||||||
/// <param name="doNotLoad">Don't load the plugin, just don't do it.</param>
|
/// <param name="doNotLoad">Don't load the plugin, just don't do it.</param>
|
||||||
/// <returns>The loaded plugin.</returns>
|
/// <returns>The loaded plugin.</returns>
|
||||||
public LocalPlugin LoadPlugin(FileInfo dllFile, LocalPluginManifest manifest, PluginLoadReason reason, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
|
public LocalPlugin LoadPlugin(FileInfo dllFile, LocalPluginManifest? manifest, PluginLoadReason reason, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
|
||||||
{
|
{
|
||||||
var name = manifest?.Name ?? dllFile.Name;
|
var name = manifest?.Name ?? dllFile.Name;
|
||||||
var loadPlugin = !doNotLoad;
|
var loadPlugin = !doNotLoad;
|
||||||
|
|
||||||
LocalPlugin plugin;
|
LocalPlugin plugin;
|
||||||
|
|
||||||
if (!manifest.CheckSanity())
|
|
||||||
throw new InvalidOperationException("Plugin manifest is not sane.");
|
|
||||||
|
|
||||||
if (isDev)
|
if (isDev)
|
||||||
{
|
{
|
||||||
Log.Information($"Loading dev plugin {name}");
|
Log.Information($"Loading dev plugin {name}");
|
||||||
|
|
@ -1045,7 +1042,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
|
|
||||||
private struct PluginDef
|
private struct PluginDef
|
||||||
{
|
{
|
||||||
public PluginDef(FileInfo dllFile, LocalPluginManifest manifest, bool isDev)
|
public PluginDef(FileInfo dllFile, LocalPluginManifest? manifest, bool isDev)
|
||||||
{
|
{
|
||||||
this.DllFile = dllFile;
|
this.DllFile = dllFile;
|
||||||
this.Manifest = manifest;
|
this.Manifest = manifest;
|
||||||
|
|
@ -1054,7 +1051,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
|
|
||||||
public FileInfo DllFile { get; init; }
|
public FileInfo DllFile { get; init; }
|
||||||
|
|
||||||
public LocalPluginManifest Manifest { get; init; }
|
public LocalPluginManifest? Manifest { get; init; }
|
||||||
|
|
||||||
public bool IsDev { get; init; }
|
public bool IsDev { get; init; }
|
||||||
|
|
||||||
|
|
@ -1086,8 +1083,8 @@ namespace Dalamud.Plugin.Internal
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static readonly Dictionary<string, PluginPatchData> PluginLocations = new();
|
internal static readonly Dictionary<string, PluginPatchData> PluginLocations = new();
|
||||||
|
|
||||||
private MonoMod.RuntimeDetour.Hook assemblyLocationMonoHook;
|
private MonoMod.RuntimeDetour.Hook? assemblyLocationMonoHook;
|
||||||
private MonoMod.RuntimeDetour.Hook assemblyCodeBaseMonoHook;
|
private MonoMod.RuntimeDetour.Hook? assemblyCodeBaseMonoHook;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Patch method for internal class RuntimeAssembly.Location, also known as Assembly.Location.
|
/// Patch method for internal class RuntimeAssembly.Location, also known as Assembly.Location.
|
||||||
|
|
@ -1168,7 +1165,7 @@ namespace Dalamud.Plugin.Internal
|
||||||
{
|
{
|
||||||
var targetType = typeof(PluginManager).Assembly.GetType();
|
var targetType = typeof(PluginManager).Assembly.GetType();
|
||||||
|
|
||||||
var locationTarget = targetType.GetProperty(nameof(Assembly.Location)).GetGetMethod();
|
var locationTarget = targetType.GetProperty(nameof(Assembly.Location))!.GetGetMethod();
|
||||||
var locationPatch = typeof(PluginManager).GetMethod(nameof(PluginManager.AssemblyLocationPatch), BindingFlags.NonPublic | BindingFlags.Static);
|
var locationPatch = typeof(PluginManager).GetMethod(nameof(PluginManager.AssemblyLocationPatch), BindingFlags.NonPublic | BindingFlags.Static);
|
||||||
this.assemblyLocationMonoHook = new MonoMod.RuntimeDetour.Hook(locationTarget, locationPatch);
|
this.assemblyLocationMonoHook = new MonoMod.RuntimeDetour.Hook(locationTarget, locationPatch);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue