Model: Add MemberInfo.GetCustomAttributes(string)

This commit is contained in:
Katy Coe
2019-11-04 20:12:06 +01:00
parent f372be188a
commit a46947ac61

View File

@@ -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<CustomAttributeData> 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;