mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 12:02:21 +02:00
Fixed autoprop custom attribute issue
This commit is contained in:
parent
a9f5027d72
commit
b220599ec7
1 changed files with 22 additions and 15 deletions
|
@ -3953,22 +3953,29 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
BF_ASSERT(fieldInstance->mCustomAttributes == NULL);
|
BF_ASSERT(fieldInstance->mCustomAttributes == NULL);
|
||||||
if ((fieldDef != NULL) && (fieldDef->mFieldDeclaration != NULL) && (fieldDef->mFieldDeclaration->mAttributes != NULL))
|
if ((fieldDef != NULL) && (fieldDef->mFieldDeclaration != NULL) && (fieldDef->mFieldDeclaration->mAttributes != NULL))
|
||||||
{
|
{
|
||||||
BfTypeState typeState;
|
if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(fieldDef->mFieldDeclaration))
|
||||||
typeState.mPrevState = mContext->mCurTypeState;
|
|
||||||
typeState.mCurFieldDef = fieldDef;
|
|
||||||
typeState.mCurTypeDef = fieldDef->mDeclaringType;
|
|
||||||
typeState.mTypeInstance = typeInstance;
|
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
|
||||||
|
|
||||||
fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field);
|
|
||||||
|
|
||||||
for (auto customAttr : fieldInstance->mCustomAttributes->mAttributes)
|
|
||||||
{
|
{
|
||||||
if (TypeToString(customAttr.mType) == "System.ThreadStaticAttribute")
|
// Handled elsewhere
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BfTypeState typeState;
|
||||||
|
typeState.mPrevState = mContext->mCurTypeState;
|
||||||
|
typeState.mCurFieldDef = fieldDef;
|
||||||
|
typeState.mCurTypeDef = fieldDef->mDeclaringType;
|
||||||
|
typeState.mTypeInstance = typeInstance;
|
||||||
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
|
|
||||||
|
fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field);
|
||||||
|
|
||||||
|
for (auto customAttr : fieldInstance->mCustomAttributes->mAttributes)
|
||||||
{
|
{
|
||||||
if ((!fieldDef->mIsStatic) || (fieldDef->mIsConst))
|
if (TypeToString(customAttr.mType) == "System.ThreadStaticAttribute")
|
||||||
{
|
{
|
||||||
Fail("ThreadStatic attribute can only be used on static fields", fieldDef->mFieldDeclaration->mAttributes);
|
if ((!fieldDef->mIsStatic) || (fieldDef->mIsConst))
|
||||||
|
{
|
||||||
|
Fail("ThreadStatic attribute can only be used on static fields", fieldDef->mFieldDeclaration->mAttributes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue