From f9d5aaa10d2795c04f63386acc26597bf74b8dd7 Mon Sep 17 00:00:00 2001 From: Nytra <14206961+Nytra@users.noreply.github.com> Date: Sat, 25 Jul 2026 16:35:39 +0100 Subject: [PATCH 1/2] Inherit patcher types and attributes --- BepInEx.Core/Bootstrap/BaseChainloader.cs | 2 +- BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs | 12 ++++++++---- BepInEx.Preloader.Core/Patching/Attributes.cs | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) 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..8cb90b5ff 100644 --- a/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs +++ b/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs @@ -65,6 +65,7 @@ public void Dispose() private PatcherPluginMetadata ToPatcherPlugin(TypeDefinition type, string assemblyPath) { + if (type.IsInterface || type.IsAbstract && !type.IsSealed) return null; @@ -115,12 +116,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; From fed5f18e4af531b4fd642175297f81a83a175408 Mon Sep 17 00:00:00 2001 From: Nytra <14206961+Nytra@users.noreply.github.com> Date: Sat, 25 Jul 2026 16:36:36 +0100 Subject: [PATCH 2/2] Remove empty line --- BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs b/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs index 8cb90b5ff..9df4935a9 100644 --- a/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs +++ b/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs @@ -65,7 +65,6 @@ public void Dispose() private PatcherPluginMetadata ToPatcherPlugin(TypeDefinition type, string assemblyPath) { - if (type.IsInterface || type.IsAbstract && !type.IsSealed) return null;