diff --git a/BeefLibs/corlib/src/Reflection/FieldInfo.bf b/BeefLibs/corlib/src/Reflection/FieldInfo.bf index 18b0ca3c..562a8a01 100644 --- a/BeefLibs/corlib/src/Reflection/FieldInfo.bf +++ b/BeefLibs/corlib/src/Reflection/FieldInfo.bf @@ -230,6 +230,24 @@ namespace System.Reflection *((*(T2**)&data)++) } + public bool HasCustomAttribute() where T : Attribute + { + if (Compiler.IsComptime) + { + int32 attrIdx = -1; + Type attrType = null; + repeat + { + attrType = Type.[Friend]Comptime_Field_GetCustomAttributeType((int32)mTypeInstance.TypeId, mFieldData.mCustomAttributesIdx, ++attrIdx); + if (attrType == typeof(T)) + return true; + } + while (attrType != null); + return false; + } + return mTypeInstance.[Friend]HasCustomAttribute(mFieldData.mCustomAttributesIdx); + } + public Result GetCustomAttribute() where T : Attribute { if (Compiler.IsComptime) diff --git a/BeefLibs/corlib/src/Reflection/MethodInfo.bf b/BeefLibs/corlib/src/Reflection/MethodInfo.bf index 17ab4673..95bc79d7 100644 --- a/BeefLibs/corlib/src/Reflection/MethodInfo.bf +++ b/BeefLibs/corlib/src/Reflection/MethodInfo.bf @@ -133,6 +133,24 @@ namespace System.Reflection return mTypeInstance.[Friend]GetCustomAttributes(mData.mMethodData.mParamData[paramIdx].mCustomAttributesIdx); } + public bool HasCustomAttribute() where T : Attribute + { + if (Compiler.IsComptime) + { + int32 attrIdx = -1; + Type attrType = null; + repeat + { + attrType = Type.[Friend]Comptime_Method_GetCustomAttributeType(mData.mComptimeMethodInstance, ++attrIdx); + if (attrType == typeof(T)) + return true; + } + while (attrType != null); + return false; + } + return mTypeInstance.[Friend]HasCustomAttribute(mData.mMethodData.mCustomAttributesIdx); + } + public Result GetCustomAttribute() where T : Attribute { if (Compiler.IsComptime)