From f8d6f1405a92e1a31bef13f42339a5efc897be28 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 22 Feb 2022 21:44:52 -0800 Subject: [PATCH] Fixed circular data check with attributes on fields and properties --- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index ab3d706f..21d7a2a7 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -4345,7 +4345,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy { // Already handled } - else if ((fieldDef != NULL) && (fieldDef->mFieldDeclaration != NULL) && (fieldDef->mFieldDeclaration->mAttributes != NULL)) + else if ((fieldDef != NULL) && (fieldDef->mFieldDeclaration != NULL) && (fieldDef->mFieldDeclaration->mAttributes != NULL) && (!typeInstance->mTypeFailed)) { if (auto propDecl = BfNodeDynCast(fieldDef->mFieldDeclaration)) { @@ -4353,15 +4353,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy } else { - BfTypeState typeState; - typeState.mPrevState = mContext->mCurTypeState; - typeState.mCurFieldDef = fieldDef; - typeState.mCurTypeDef = fieldDef->mDeclaringType; - typeState.mType = typeInstance; - SetAndRestoreValue prevTypeState(mContext->mCurTypeState, &typeState); - + SetAndRestoreValue prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef); + fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field); - for (auto customAttr : fieldInstance->mCustomAttributes->mAttributes) { if (TypeToString(customAttr.mType) == "System.ThreadStaticAttribute") @@ -4554,18 +4548,13 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy if (propDef->mFieldDeclaration != NULL) { - BfTypeState typeState; - typeState.mPrevState = mContext->mCurTypeState; - typeState.mCurTypeDef = propDef->mDeclaringType; - typeState.mCurFieldDef = propDef; - typeState.mType = typeInstance; - SetAndRestoreValue prevTypeState(mContext->mCurTypeState, &typeState); + SetAndRestoreValue prevTypeRef(mContext->mCurTypeState->mCurFieldDef, propDef); BfAttributeTargets target = BfAttributeTargets_Property; if (propDef->IsExpressionBodied()) target = (BfAttributeTargets)(target | BfAttributeTargets_Method); - if (propDef->mFieldDeclaration->mAttributes != NULL) + if ((propDef->mFieldDeclaration->mAttributes != NULL) && (!typeInstance->mTypeFailed)) { auto customAttrs = GetCustomAttributes(propDef->mFieldDeclaration->mAttributes, target); delete customAttrs;