From b220599ec73b7dce63d4ed9897c36abcbacb6878 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 1 Feb 2021 14:24:17 -0800 Subject: [PATCH] Fixed autoprop custom attribute issue --- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 37 ++++++++++++++---------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 0612b1d9..b2ac8df9 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -3950,25 +3950,32 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy auto fieldDef = fieldInstance->GetFieldDef(); - BF_ASSERT(fieldInstance->mCustomAttributes == NULL); + BF_ASSERT(fieldInstance->mCustomAttributes == NULL); if ((fieldDef != NULL) && (fieldDef->mFieldDeclaration != NULL) && (fieldDef->mFieldDeclaration->mAttributes != NULL)) - { - BfTypeState typeState; - typeState.mPrevState = mContext->mCurTypeState; - typeState.mCurFieldDef = fieldDef; - typeState.mCurTypeDef = fieldDef->mDeclaringType; - typeState.mTypeInstance = typeInstance; - SetAndRestoreValue prevTypeState(mContext->mCurTypeState, &typeState); - - fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field); - - for (auto customAttr : fieldInstance->mCustomAttributes->mAttributes) + { + if (auto propDecl = BfNodeDynCast(fieldDef->mFieldDeclaration)) { - 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 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); + } } } }