From 7344366e9856ed7962290bc9a5070409fcc93062 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 11 Aug 2019 19:04:12 -0500 Subject: [PATCH] Loader now checks for manifest before plugin class --- IPA.Loader/Loader/PluginLoader.cs | 61 ++++++++++++++------------- Refs/Unity.TextMeshPro.dll | Bin 84480 -> 84480 bytes Refs/UnityEngine.CoreModule.Net4.dll | Bin 613888 -> 613888 bytes 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index c493b842..f2f51735 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -184,38 +184,15 @@ namespace IPA.Loader AssemblyResolver = new CecilLibLoader() }).MainModule; - foreach (var type in pluginModule.Types) - { - foreach (var inter in type.Interfaces) - { - var ifType = inter.InterfaceType; - - if (typeof(IBeatSaberPlugin).FullName == ifType.FullName) - { - metadata.PluginType = type; - break; - } - } - - if (metadata.PluginType != null) break; - } - - if (metadata.PluginType == null) - { - Logger.loader.Notice( - #if DIRE_LOADER_WARNINGS - $"Could not find plugin type for {Path.GetFileName(plugin)}" - #else - $"New plugin type not present in {Path.GetFileName(plugin)}; maybe an old plugin?" - #endif - ); - continue; - } + string pluginNs = ""; foreach (var resource in pluginModule.Resources) { + const string manifestSuffix = ".manifest.json"; if (!(resource is EmbeddedResource embedded) || - embedded.Name != $"{metadata.PluginType.Namespace}.manifest.json") continue; + !embedded.Name.EndsWith(manifestSuffix)) continue; + + pluginNs = embedded.Name.Substring(0, embedded.Name.Length - manifestSuffix.Length); string manifest; using (var manifestReader = new StreamReader(embedded.GetResourceStream())) @@ -227,8 +204,32 @@ namespace IPA.Loader if (metadata.Manifest == null) { - Logger.loader.Error("Could not find manifest.json in namespace " + - $"{metadata.PluginType.Namespace} for {Path.GetFileName(plugin)}"); +#if DIRE_LOADER_WARNINGS + Logger.loader.Error($"Could not find manifest.json for {Path.GetFileName(plugin)}"); +#else + Logger.loader.Notice($"No manifest.json in {Path.GetFileName(plugin)}"); +#endif + continue; + } + + foreach (var type in pluginModule.Types) + { + if (type.Namespace != pluginNs) continue; + + foreach (var inter in type.Interfaces) + { + if (typeof(IBeatSaberPlugin).FullName == inter.InterfaceType.FullName) + { + metadata.PluginType = type; + goto type_loop_done; // break out of both loops + } + } + } + + type_loop_done: + if (metadata.PluginType == null) + { + Logger.loader.Error($"No plugin found in the manifest namespace ({pluginNs}) in {Path.GetFileName(plugin)}"); continue; } diff --git a/Refs/Unity.TextMeshPro.dll b/Refs/Unity.TextMeshPro.dll index a37e311ac055c56b2df0f179490f9471260ec338..5b4e9492f6607a391f21f6c015041c79e416aab4 100644 GIT binary patch delta 42 ycmZpe!rCx}bwUTT;024u?ycR7wrT<=`Z=!sf12dFr8{!U5i3dG?KjjIHIxB(%@KG2 delta 42 ycmZpe!rCx}bwUU8;s5{u