1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed circular data check with attributes on fields and properties

This commit is contained in:
Brian Fiete 2022-02-22 21:44:52 -08:00
parent 6f8ee9aef0
commit f8d6f1405a

View file

@ -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<BfPropertyDeclaration>(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<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
SetAndRestoreValue<BfFieldDef*> 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<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
SetAndRestoreValue<BfFieldDef*> 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;