From a46947ac618767a7500c5783033affb59afbe763 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 4 Nov 2019 20:12:06 +0100 Subject: [PATCH] Model: Add MemberInfo.GetCustomAttributes(string) --- Il2CppInspector/Reflection/MemberInfo.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Il2CppInspector/Reflection/MemberInfo.cs b/Il2CppInspector/Reflection/MemberInfo.cs index 3960783..f22d838 100644 --- a/Il2CppInspector/Reflection/MemberInfo.cs +++ b/Il2CppInspector/Reflection/MemberInfo.cs @@ -5,6 +5,7 @@ */ using System.Collections.Generic; +using System.Linq; using System.Reflection; namespace Il2CppInspector.Reflection { @@ -16,6 +17,8 @@ namespace Il2CppInspector.Reflection { // Custom attributes for this member public abstract IEnumerable CustomAttributes { get; } + public TypeInfo[] GetCustomAttributes(string fullTypeName) => CustomAttributes.Where(a => a.AttributeType.FullName == fullTypeName).Select(x => x.AttributeType).ToArray(); + // Type that this type is declared in for nested types protected int declaringTypeDefinitionIndex { private get; set; } = -1; public TypeInfo DeclaringType => declaringTypeDefinitionIndex != -1? Assembly.Model.TypesByDefinitionIndex[declaringTypeDefinitionIndex] : null;