Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BepInEx.Core/Bootstrap/BaseChainloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

namespace BepInEx.Bootstrap;

public abstract class BaseChainloader<TPlugin>

Check warning on line 15 in BepInEx.Core/Bootstrap/BaseChainloader.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'BaseChainloader<TPlugin>'
{
protected static readonly string CurrentAssemblyName = Assembly.GetExecutingAssembly().GetName().Name;

Check warning on line 17 in BepInEx.Core/Bootstrap/BaseChainloader.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'BaseChainloader<TPlugin>.CurrentAssemblyName'
protected static readonly Version CurrentAssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;

Check warning on line 18 in BepInEx.Core/Bootstrap/BaseChainloader.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'BaseChainloader<TPlugin>.CurrentAssemblyVersion'
private static readonly Dictionary<string, bool> RefCache = new();
private static Regex allowedGuidRegex { get; } = new(@"^[a-zA-Z0-9\._\-]+$");

Expand Down Expand Up @@ -88,7 +88,7 @@
Location = assemblyLocation
};
}
static bool ReferencesThisAssembly(AssemblyDefinition ass, HashSet<string> seen = null)
internal static bool ReferencesThisAssembly(AssemblyDefinition ass, HashSet<string> seen = null)
{
seen ??= new HashSet<string>(StringComparer.OrdinalIgnoreCase);

Expand All @@ -107,7 +107,7 @@
}
return RefCache[key] = false;
}
protected static bool HasBepinPlugins(AssemblyDefinition ass)

Check warning on line 110 in BepInEx.Core/Bootstrap/BaseChainloader.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'BaseChainloader<TPlugin>.HasBepinPlugins(AssemblyDefinition)'
{
if (!ReferencesThisAssembly(ass))
return false;
Expand Down
11 changes: 7 additions & 4 deletions BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BepInPlugin>.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;
}

Expand Down
2 changes: 1 addition & 1 deletion BepInEx.Preloader.Core/Patching/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private static Version TryParseLongVersion(string version)

internal static PatcherPluginInfoAttribute FromCecilType(TypeDefinition td)
{
var attr = MetadataHelper.GetCustomAttributes<PatcherPluginInfoAttribute>(td, false).FirstOrDefault();
var attr = MetadataHelper.GetCustomAttributes<PatcherPluginInfoAttribute>(td, false, true).FirstOrDefault();

if (attr == null)
return null;
Expand Down
Loading