From 752e4b0c6e66fc016b85d13d5dc1890b929ceb9c Mon Sep 17 00:00:00 2001 From: Tides Date: Sun, 17 Mar 2024 20:25:20 -0400 Subject: [PATCH] Add dependency when loaded --- Obsidian/Plugins/PluginFileEntry.cs | 1 - Obsidian/Plugins/PluginManager.cs | 4 ++++ Obsidian/Plugins/PluginProviders/PackedPluginProvider.cs | 2 +- SamplePlugin/SamplePlugin.csproj | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Obsidian/Plugins/PluginFileEntry.cs b/Obsidian/Plugins/PluginFileEntry.cs index eeaa95e6..77556b39 100644 --- a/Obsidian/Plugins/PluginFileEntry.cs +++ b/Obsidian/Plugins/PluginFileEntry.cs @@ -1,5 +1,4 @@ using Org.BouncyCastle.Crypto; -using System.Buffers; using System.IO; using System.IO.Compression; diff --git a/Obsidian/Plugins/PluginManager.cs b/Obsidian/Plugins/PluginManager.cs index 3478fbfb..98c6a71f 100644 --- a/Obsidian/Plugins/PluginManager.cs +++ b/Obsidian/Plugins/PluginManager.cs @@ -110,6 +110,10 @@ public async Task LoadPluginsAsync() foreach (var canLoad in waitingForDepend.Where(x => x.IsDependency(pluginContainer.Info.Id)).ToList()) { packedPluginProvider.InitializePlugin(canLoad); + + //Add dependency to plugin + canLoad.LoadContext.AddDependency(pluginContainer.LoadContext); + this.HandlePlugin(canLoad); waitingForDepend.Remove(canLoad); diff --git a/Obsidian/Plugins/PluginProviders/PackedPluginProvider.cs b/Obsidian/Plugins/PluginProviders/PackedPluginProvider.cs index 9b0942d8..4ac80ea1 100644 --- a/Obsidian/Plugins/PluginProviders/PackedPluginProvider.cs +++ b/Obsidian/Plugins/PluginProviders/PackedPluginProvider.cs @@ -48,7 +48,7 @@ public sealed class PackedPluginProvider(PluginManager pluginManager, ILogger lo var entries = await this.InitializeEntriesAsync(reader, fs); - var partialContainer = BuildPartialContainer(loadContext, path, entries, isSigValid); + var partialContainer = this.BuildPartialContainer(loadContext, path, entries, isSigValid); //Can't load until those plugins are loaded if (partialContainer.Info.Dependencies.Any(x => x.Required && !this.pluginManager.Plugins.Any(d => d.Info.Id == x.Id))) diff --git a/SamplePlugin/SamplePlugin.csproj b/SamplePlugin/SamplePlugin.csproj index 1e40e82c..be1bab1c 100644 --- a/SamplePlugin/SamplePlugin.csproj +++ b/SamplePlugin/SamplePlugin.csproj @@ -36,7 +36,6 @@ PreserveNewest -