Add version-independent helper for retrieving assembly attributes

This commit is contained in:
ghorsington committed 2020-11-30 15:49:21 +02:00
1 parent cfa6857bb0
commit 28671ceb6f
2 files changed
+13 -3

No files matched your search

+12 -1
View File
@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using BepInEx.Bootstrap;
using BepInEx.Core;
using Mono.Cecil;
namespace BepInEx
@@ -269,6 +269,17 @@ namespace BepInEx
return (T[])pluginType.GetCustomAttributes(typeof(T), true);
}
/// <summary>
/// Gets the specified attributes of an assembly, if they exist.
/// </summary>
/// <param name="assembly">The assembly.</param>
/// <typeparam name="T">The attribute type to retrieve.</typeparam>
/// <returns>The attributes of the type, if existing.</returns>
public static T[] GetAttributes<T>(Assembly assembly) where T : Attribute
{
return (T[])assembly.GetCustomAttributes(typeof(T), true);
}
/// <summary>
/// Gets the specified attributes of an instance, if they exist.
/// </summary>