diff --git a/Dalamud/Plugin/Internal/LocalDevPlugin.cs b/Dalamud/Plugin/Internal/LocalDevPlugin.cs index 3615c01a9..27989531c 100644 --- a/Dalamud/Plugin/Internal/LocalDevPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalDevPlugin.cs @@ -21,8 +21,8 @@ namespace Dalamud.Plugin.Internal // Ref to Dalamud.Configuration.DevPluginSettings private readonly DevPluginSettings devSettings; - private FileSystemWatcher fileWatcher; - private CancellationTokenSource fileWatcherTokenSource; + private FileSystemWatcher? fileWatcher; + private CancellationTokenSource fileWatcherTokenSource = new(); private int reloadCounter; /// @@ -125,7 +125,7 @@ namespace Dalamud.Plugin.Internal var current = Interlocked.Increment(ref this.reloadCounter); Task.Delay(500).ContinueWith( - task => + _ => { if (this.fileWatcherTokenSource.IsCancellationRequested) { diff --git a/Dalamud/Plugin/Internal/LocalPlugin.cs b/Dalamud/Plugin/Internal/LocalPlugin.cs index 4a17f8369..1c6edd15a 100644 --- a/Dalamud/Plugin/Internal/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalPlugin.cs @@ -112,6 +112,9 @@ namespace Dalamud.Plugin.Internal else { 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. diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index d7ef38f05..83b436bca 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -74,12 +74,12 @@ namespace Dalamud.Plugin.Internal /// /// An event that fires when the installed plugins have changed. /// - public event Action OnInstalledPluginsChanged; + public event Action? OnInstalledPluginsChanged; /// /// An event that fires when the available plugins have changed. /// - public event Action OnAvailablePluginsChanged; + public event Action? OnAvailablePluginsChanged; /// /// Gets a list of all loaded plugins. @@ -512,16 +512,13 @@ namespace Dalamud.Plugin.Internal /// If this plugin is being loaded at boot. /// Don't load the plugin, just don't do it. /// The loaded plugin. - 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 loadPlugin = !doNotLoad; LocalPlugin plugin; - if (!manifest.CheckSanity()) - throw new InvalidOperationException("Plugin manifest is not sane."); - if (isDev) { Log.Information($"Loading dev plugin {name}"); @@ -1045,7 +1042,7 @@ namespace Dalamud.Plugin.Internal private struct PluginDef { - public PluginDef(FileInfo dllFile, LocalPluginManifest manifest, bool isDev) + public PluginDef(FileInfo dllFile, LocalPluginManifest? manifest, bool isDev) { this.DllFile = dllFile; this.Manifest = manifest; @@ -1054,7 +1051,7 @@ namespace Dalamud.Plugin.Internal public FileInfo DllFile { get; init; } - public LocalPluginManifest Manifest { get; init; } + public LocalPluginManifest? Manifest { get; init; } public bool IsDev { get; init; } @@ -1086,8 +1083,8 @@ namespace Dalamud.Plugin.Internal /// internal static readonly Dictionary PluginLocations = new(); - private MonoMod.RuntimeDetour.Hook assemblyLocationMonoHook; - private MonoMod.RuntimeDetour.Hook assemblyCodeBaseMonoHook; + private MonoMod.RuntimeDetour.Hook? assemblyLocationMonoHook; + private MonoMod.RuntimeDetour.Hook? assemblyCodeBaseMonoHook; /// /// 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 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); this.assemblyLocationMonoHook = new MonoMod.RuntimeDetour.Hook(locationTarget, locationPatch);