|
@@ -13,7 +13,7 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
|
|
- public class BepInPlugin : Attribute
|
|
|
+ public class PluginMetadata : Attribute
|
|
|
{
|
|
|
|
|
|
|
|
@@ -35,7 +35,7 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
|
|
|
- public BepInPlugin(string GUID, string Name, string Version)
|
|
|
+ public PluginMetadata(string GUID, string Name, string Version)
|
|
|
{
|
|
|
this.GUID = GUID;
|
|
|
this.Name = Name;
|
|
@@ -50,14 +50,15 @@ namespace BepInEx
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- internal static BepInPlugin FromCecilType(TypeDefinition td)
|
|
|
+ internal static PluginMetadata FromCecilType(TypeDefinition td)
|
|
|
{
|
|
|
- var attr = MetadataHelper.GetCustomAttributes<BepInPlugin>(td, false).FirstOrDefault();
|
|
|
+ var attr = MetadataHelper.GetCustomAttributes<PluginMetadata>(td, false).FirstOrDefault()
|
|
|
+ ?? MetadataHelper.GetCustomAttributes<BepInPlugin>(td, false).FirstOrDefault();
|
|
|
|
|
|
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 PluginMetadata((string)attr.ConstructorArguments[0].Value, (string)attr.ConstructorArguments[1].Value, (string)attr.ConstructorArguments[2].Value);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -65,7 +66,7 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
|
|
- public class BepInDependency : Attribute, ICacheable
|
|
|
+ public class PluginDependency : Attribute, ICacheable
|
|
|
{
|
|
|
public enum DependencyFlags
|
|
|
{
|
|
@@ -101,7 +102,7 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
|
|
|
- public BepInDependency(string DependencyGUID, DependencyFlags Flags = DependencyFlags.HardDependency)
|
|
|
+ public PluginDependency(string DependencyGUID, DependencyFlags Flags = DependencyFlags.HardDependency)
|
|
|
{
|
|
|
this.DependencyGUID = DependencyGUID;
|
|
|
this.Flags = Flags;
|
|
@@ -115,20 +116,20 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
|
|
|
- public BepInDependency(string DependencyGUID, string MinimumDependencyVersion) : this(DependencyGUID)
|
|
|
+ public PluginDependency(string DependencyGUID, string MinimumDependencyVersion) : this(DependencyGUID)
|
|
|
{
|
|
|
MinimumVersion = new Version(MinimumDependencyVersion);
|
|
|
}
|
|
|
|
|
|
- internal static IEnumerable<BepInDependency> FromCecilType(TypeDefinition td)
|
|
|
+ internal static IEnumerable<PluginDependency> FromCecilType(TypeDefinition td)
|
|
|
{
|
|
|
- var attrs = MetadataHelper.GetCustomAttributes<BepInDependency>(td, true);
|
|
|
+ var attrs = MetadataHelper.GetCustomAttributes<PluginDependency>(td, true);
|
|
|
return attrs.Select(customAttribute =>
|
|
|
{
|
|
|
var dependencyGuid = (string)customAttribute.ConstructorArguments[0].Value;
|
|
|
var secondArg = customAttribute.ConstructorArguments[1].Value;
|
|
|
- if (secondArg is string minVersion) return new BepInDependency(dependencyGuid, minVersion);
|
|
|
- return new BepInDependency(dependencyGuid, (DependencyFlags)secondArg);
|
|
|
+ if (secondArg is string minVersion) return new PluginDependency(dependencyGuid, minVersion);
|
|
|
+ return new PluginDependency(dependencyGuid, (DependencyFlags)secondArg);
|
|
|
}).ToList();
|
|
|
}
|
|
|
|
|
@@ -151,7 +152,7 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
|
|
- public class BepInIncompatibility : Attribute, ICacheable
|
|
|
+ public class PluginIncompatibility : Attribute, ICacheable
|
|
|
{
|
|
|
|
|
|
|
|
@@ -163,18 +164,18 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
|
|
|
- public BepInIncompatibility(string IncompatibilityGUID)
|
|
|
+ public PluginIncompatibility(string IncompatibilityGUID)
|
|
|
{
|
|
|
this.IncompatibilityGUID = IncompatibilityGUID;
|
|
|
}
|
|
|
|
|
|
- internal static IEnumerable<BepInIncompatibility> FromCecilType(TypeDefinition td)
|
|
|
+ internal static IEnumerable<PluginIncompatibility> FromCecilType(TypeDefinition td)
|
|
|
{
|
|
|
- var attrs = MetadataHelper.GetCustomAttributes<BepInIncompatibility>(td, true);
|
|
|
+ var attrs = MetadataHelper.GetCustomAttributes<PluginIncompatibility>(td, true);
|
|
|
return attrs.Select(customAttribute =>
|
|
|
{
|
|
|
var dependencyGuid = (string)customAttribute.ConstructorArguments[0].Value;
|
|
|
- return new BepInIncompatibility(dependencyGuid);
|
|
|
+ return new PluginIncompatibility(dependencyGuid);
|
|
|
}).ToList();
|
|
|
}
|
|
|
|
|
@@ -193,7 +194,7 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
|
|
- public class BepInProcess : Attribute
|
|
|
+ public class ProcessFilter : Attribute
|
|
|
{
|
|
|
|
|
|
|
|
@@ -201,20 +202,62 @@ namespace BepInEx
|
|
|
public string ProcessName { get; protected set; }
|
|
|
|
|
|
|
|
|
- public BepInProcess(string ProcessName)
|
|
|
+ public ProcessFilter(string ProcessName)
|
|
|
{
|
|
|
this.ProcessName = ProcessName;
|
|
|
}
|
|
|
|
|
|
- internal static List<BepInProcess> FromCecilType(TypeDefinition td)
|
|
|
+ internal static List<ProcessFilter> FromCecilType(TypeDefinition td)
|
|
|
{
|
|
|
- var attrs = MetadataHelper.GetCustomAttributes<BepInProcess>(td, true);
|
|
|
- return attrs.Select(customAttribute => new BepInProcess((string)customAttribute.ConstructorArguments[0].Value)).ToList();
|
|
|
+ var attrs = MetadataHelper.GetCustomAttributes<ProcessFilter>(td, true);
|
|
|
+ return attrs.Select(customAttribute => new ProcessFilter((string)customAttribute.ConstructorArguments[0].Value)).ToList();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region Shims
|
|
|
+
|
|
|
+ [Obsolete("Use PluginMetadata instead")]
|
|
|
+ public class BepInPlugin : PluginMetadata
|
|
|
+ {
|
|
|
+ public BepInPlugin(string GUID, string Name, string Version) : base(GUID, Name, Version) { }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Obsolete("Use PluginDependency instead")]
|
|
|
+ public class BepInDependency : PluginDependency
|
|
|
+ {
|
|
|
+ public enum DependencyFlags
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ HardDependency = 1,
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ SoftDependency = 2,
|
|
|
+ }
|
|
|
+
|
|
|
+ public BepInDependency(string DependencyGUID, DependencyFlags Flags = DependencyFlags.HardDependency) : base(DependencyGUID, (PluginDependency.DependencyFlags)(int)Flags) { }
|
|
|
+ public BepInDependency(string DependencyGUID, string MinimumDependencyVersion) : base(DependencyGUID, MinimumDependencyVersion) { }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Obsolete("Use PluginIncompatibility instead")]
|
|
|
+ public class BepInIncompatibility : PluginIncompatibility
|
|
|
+ {
|
|
|
+ public BepInIncompatibility(string IncompatibilityGUID) : base(IncompatibilityGUID) { }
|
|
|
+ }
|
|
|
+
|
|
|
+ [Obsolete("Use ProcessFilter instead")]
|
|
|
+ public class BepInProcess : ProcessFilter
|
|
|
+ {
|
|
|
+ public BepInProcess(string ProcessName) : base(ProcessName) { }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region MetadataHelper
|
|
|
|
|
|
|
|
@@ -239,26 +282,28 @@ namespace BepInEx
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
- public static BepInPlugin GetMetadata(Type pluginType)
|
|
|
+
|
|
|
+ public static PluginMetadata GetMetadata(Type pluginType)
|
|
|
{
|
|
|
- object[] attributes = pluginType.GetCustomAttributes(typeof(BepInPlugin), false);
|
|
|
+ object[] attributes = pluginType.GetCustomAttributes(typeof(PluginMetadata), false)
|
|
|
+ .Concat(pluginType.GetCustomAttributes(typeof(BepInPlugin), false))
|
|
|
+ .ToArray();
|
|
|
|
|
|
if (attributes.Length == 0)
|
|
|
return null;
|
|
|
|
|
|
- return (BepInPlugin)attributes[0];
|
|
|
+ return (PluginMetadata)attributes[0];
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
- public static BepInPlugin GetMetadata(object plugin)
|
|
|
+
|
|
|
+ public static PluginMetadata GetMetadata(object plugin)
|
|
|
=> GetMetadata(plugin.GetType());
|
|
|
|
|
|
|
|
@@ -286,9 +331,9 @@ namespace BepInEx
|
|
|
|
|
|
|
|
|
|
|
|
- public static IEnumerable<BepInDependency> GetDependencies(Type plugin)
|
|
|
+ public static IEnumerable<PluginDependency> GetDependencies(Type plugin)
|
|
|
{
|
|
|
- return plugin.GetCustomAttributes(typeof(BepInDependency), true).Cast<BepInDependency>();
|
|
|
+ return plugin.GetCustomAttributes(typeof(PluginDependency), true).Cast<PluginDependency>();
|
|
|
}
|
|
|
}
|
|
|
|