From f4a49de2538a2f538d17ff5d8351542b8fb803fa Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 28 Mar 2021 18:17:23 -0500 Subject: [PATCH] Add check that loaded plugins depend on loader --- IPA.Loader/Loader/PluginLoader.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index e4992032..67c7b269 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -823,10 +823,12 @@ namespace IPA.Loader } } - // TODO: bsipa dependency check // first load dependencies + var dependsOnSelf = false; foreach (var dep in plugin.Manifest.Dependencies) { + if (dep.Key == SelfMeta.Id) + dependsOnSelf = true; if (!TryResolveId(dep.Key, out var depMeta, out var depDisabled, out var depIgnored)) { Logger.loader.Warn($"Dependency '{dep.Key}@{dep.Value}' for '{plugin.Id}' does not exist; ignoring '{plugin.Id}'"); @@ -862,6 +864,19 @@ namespace IPA.Loader _ = plugin.Dependencies.Add(depMeta); } + // make sure the plugin depends on the loader (assuming it actually needs to) + if (!dependsOnSelf && !plugin.IsSelf && !plugin.IsBare) + { + Logger.loader.Warn($"Plugin '{plugin.Id}' does not depend on any particular loader version; assuming its incompatible"); + ignoredPlugins.Add(plugin, new(Reason.Dependency) + { + ReasonText = "Does not depend on any loader version, so it is assumed to be incompatible", + RelatedTo = SelfMeta + }); + ignored = true; + return; + } + // handle LoadsAfter populated by Features processing foreach (var loadAfter in plugin.LoadsAfter) {