From 48c359acf9bf6b99acec3ad8033662178e4a30df Mon Sep 17 00:00:00 2001
From: hazre <37149950+hazre@users.noreply.github.com>
Date: Thu, 18 Sep 2025 17:56:07 +0200
Subject: [PATCH] Extend plugin attributes with optional fields
---
BepInEx.Core/Contract/Attributes.cs | 25 ++++++++++++++++---
BepInEx.Core/Contract/PluginInfo.cs | 10 +++++++-
BepInEx.Preloader.Core/Patching/Attributes.cs | 25 ++++++++++++++++---
3 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/BepInEx.Core/Contract/Attributes.cs b/BepInEx.Core/Contract/Attributes.cs
index 843e1cd48..53829bf22 100644
--- a/BepInEx.Core/Contract/Attributes.cs
+++ b/BepInEx.Core/Contract/Attributes.cs
@@ -21,11 +21,15 @@ public class BepInPlugin : Attribute
/// The unique identifier of the plugin. Should not change between plugin versions.
/// The user friendly name of the plugin. Is able to be changed between versions.
/// The specific version of the plugin.
- public BepInPlugin(string GUID, string Name, string Version)
+ /// The author of the plugin.
+ /// The link to the plugin's website or repository.
+ public BepInPlugin(string GUID, string Name, string Version, string Author = null, string Link = null)
{
this.GUID = GUID;
this.Name = Name;
this.Version = TryParseLongVersion(Version);
+ this.Author = Author;
+ this.Link = Link;
}
///
@@ -45,6 +49,16 @@ public BepInPlugin(string GUID, string Name, string Version)
///
public Version Version { get; protected set; }
+ ///
+ /// The author of the plugin.
+ ///
+ public string Author { get; protected set; }
+
+ ///
+ /// The link to the plugin's website or repository.
+ ///
+ public string Link { get; protected set; }
+
private static Version TryParseLongVersion(string version)
{
if (Version.TryParse(version, out var v))
@@ -70,9 +84,12 @@ internal static BepInPlugin FromCecilType(TypeDefinition td)
if (attr == null)
return null;
- return new BepInPlugin((string) attr.ConstructorArguments[0].Value,
- (string) attr.ConstructorArguments[1].Value,
- (string) attr.ConstructorArguments[2].Value);
+ return new BepInPlugin(
+ (string) attr.ConstructorArguments[0].Value,
+ (string) attr.ConstructorArguments[1].Value,
+ (string) attr.ConstructorArguments[2].Value,
+ attr.ConstructorArguments.Count > 3 ? (string) attr.ConstructorArguments[3].Value : null,
+ attr.ConstructorArguments.Count > 4 ? (string) attr.ConstructorArguments[4].Value : null);
}
}
diff --git a/BepInEx.Core/Contract/PluginInfo.cs b/BepInEx.Core/Contract/PluginInfo.cs
index 0aa7585cc..9a7adb602 100644
--- a/BepInEx.Core/Contract/PluginInfo.cs
+++ b/BepInEx.Core/Contract/PluginInfo.cs
@@ -56,6 +56,9 @@ void ICacheable.Save(BinaryWriter bw)
bw.Write(Metadata.Name);
bw.Write(Metadata.Version.ToString());
+ bw.Write(Metadata.Author ?? string.Empty);
+ bw.Write(Metadata.Link ?? string.Empty);
+
var processList = Processes.ToList();
bw.Write(processList.Count);
foreach (var bepInProcess in processList)
@@ -79,7 +82,12 @@ void ICacheable.Load(BinaryReader br)
TypeName = br.ReadString();
Location = br.ReadString();
- Metadata = new BepInPlugin(br.ReadString(), br.ReadString(), br.ReadString());
+ Metadata = new BepInPlugin(
+ br.ReadString(),
+ br.ReadString(),
+ br.ReadString(),
+ br.ReadString(),
+ br.ReadString());
var processListCount = br.ReadInt32();
var processList = new List(processListCount);
diff --git a/BepInEx.Preloader.Core/Patching/Attributes.cs b/BepInEx.Preloader.Core/Patching/Attributes.cs
index 95b21c424..bf234f26d 100644
--- a/BepInEx.Preloader.Core/Patching/Attributes.cs
+++ b/BepInEx.Preloader.Core/Patching/Attributes.cs
@@ -14,11 +14,15 @@ public class PatcherPluginInfoAttribute : Attribute
/// The unique identifier of the plugin. Should not change between plugin versions.
/// The user friendly name of the plugin. Is able to be changed between versions.
/// The specific version of the plugin.
- public PatcherPluginInfoAttribute(string GUID, string Name, string Version)
+ /// The author of the plugin.
+ /// The link to the plugin's website or repository.
+ public PatcherPluginInfoAttribute(string GUID, string Name, string Version, string Author = null, string Link = null)
{
this.GUID = GUID;
this.Name = Name;
this.Version = TryParseLongVersion(Version);
+ this.Author = Author;
+ this.Link = Link;
}
///
@@ -38,6 +42,16 @@ public PatcherPluginInfoAttribute(string GUID, string Name, string Version)
///
public Version Version { get; protected set; }
+ ///
+ /// The author of the plugin.
+ ///
+ public string Author { get; protected set; }
+
+ ///
+ /// The link to the plugin's website or repository.
+ ///
+ public string Link { get; protected set; }
+
private static Version TryParseLongVersion(string version)
{
if (Version.TryParse(version, out var v))
@@ -63,9 +77,12 @@ internal static PatcherPluginInfoAttribute FromCecilType(TypeDefinition td)
if (attr == null)
return null;
- return new PatcherPluginInfoAttribute((string) attr.ConstructorArguments[0].Value,
- (string) attr.ConstructorArguments[1].Value,
- (string) attr.ConstructorArguments[2].Value);
+ return new PatcherPluginInfoAttribute(
+ (string) attr.ConstructorArguments[0].Value,
+ (string) attr.ConstructorArguments[1].Value,
+ (string) attr.ConstructorArguments[2].Value,
+ attr.ConstructorArguments.Count > 3 ? (string) attr.ConstructorArguments[3].Value : null,
+ attr.ConstructorArguments.Count > 4 ? (string) attr.ConstructorArguments[4].Value : null);
}
internal static PatcherPluginInfoAttribute FromType(Type type)