diff --git a/BepInEx.Core/Bootstrap/BaseChainloader.cs b/BepInEx.Core/Bootstrap/BaseChainloader.cs index a100d75c6..d42a0acc4 100644 --- a/BepInEx.Core/Bootstrap/BaseChainloader.cs +++ b/BepInEx.Core/Bootstrap/BaseChainloader.cs @@ -88,7 +88,7 @@ public static PluginInfo ToPluginInfo(TypeDefinition type, string assemblyLocati Location = assemblyLocation }; } - static bool ReferencesThisAssembly(AssemblyDefinition ass, HashSet seen = null) + internal static bool ReferencesThisAssembly(AssemblyDefinition ass, HashSet seen = null) { seen ??= new HashSet(StringComparer.OrdinalIgnoreCase); diff --git a/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs b/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs index 4ba5396c0..9df4935a9 100644 --- a/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs +++ b/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs @@ -115,12 +115,15 @@ private PatcherPluginMetadata ToPatcherPlugin(TypeDefinition type, string assemb private bool HasPatcherPlugins(AssemblyDefinition ass) { - if (ass.MainModule.AssemblyReferences.All(r => r.Name != CurrentAssemblyName) && - ass.Name.Name != CurrentAssemblyName) - return false; + if (!BepInEx.Bootstrap.BaseChainloader.ReferencesThisAssembly(ass)) return false; if (ass.MainModule.GetTypeReferences().All(r => r.FullName != typeof(BasePatcher).FullName)) + { + if (ass.MainModule.GetTypeReferences().Any((TypeReference r) => MetadataHelper.TypeInheretsFrom(r, typeof(BasePatcher)))) + { + return true; + } return false; - + } return true; } diff --git a/BepInEx.Preloader.Core/Patching/Attributes.cs b/BepInEx.Preloader.Core/Patching/Attributes.cs index 95b21c424..b5e12e085 100644 --- a/BepInEx.Preloader.Core/Patching/Attributes.cs +++ b/BepInEx.Preloader.Core/Patching/Attributes.cs @@ -58,7 +58,7 @@ private static Version TryParseLongVersion(string version) internal static PatcherPluginInfoAttribute FromCecilType(TypeDefinition td) { - var attr = MetadataHelper.GetCustomAttributes(td, false).FirstOrDefault(); + var attr = MetadataHelper.GetCustomAttributes(td, false, true).FirstOrDefault(); if (attr == null) return null;