1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22: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 // 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)) if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(fieldDef->mFieldDeclaration))
{ {
@ -4353,15 +4353,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
else else
{ {
BfTypeState typeState; SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
typeState.mPrevState = mContext->mCurTypeState;
typeState.mCurFieldDef = fieldDef;
typeState.mCurTypeDef = fieldDef->mDeclaringType;
typeState.mType = typeInstance;
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field); fieldInstance->mCustomAttributes = GetCustomAttributes(fieldDef->mFieldDeclaration->mAttributes, fieldDef->mIsStatic ? BfAttributeTargets_StaticField : BfAttributeTargets_Field);
for (auto customAttr : fieldInstance->mCustomAttributes->mAttributes) for (auto customAttr : fieldInstance->mCustomAttributes->mAttributes)
{ {
if (TypeToString(customAttr.mType) == "System.ThreadStaticAttribute") if (TypeToString(customAttr.mType) == "System.ThreadStaticAttribute")
@ -4554,18 +4548,13 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (propDef->mFieldDeclaration != NULL) if (propDef->mFieldDeclaration != NULL)
{ {
BfTypeState typeState; SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, propDef);
typeState.mPrevState = mContext->mCurTypeState;
typeState.mCurTypeDef = propDef->mDeclaringType;
typeState.mCurFieldDef = propDef;
typeState.mType = typeInstance;
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
BfAttributeTargets target = BfAttributeTargets_Property; BfAttributeTargets target = BfAttributeTargets_Property;
if (propDef->IsExpressionBodied()) if (propDef->IsExpressionBodied())
target = (BfAttributeTargets)(target | BfAttributeTargets_Method); target = (BfAttributeTargets)(target | BfAttributeTargets_Method);
if (propDef->mFieldDeclaration->mAttributes != NULL) if ((propDef->mFieldDeclaration->mAttributes != NULL) && (!typeInstance->mTypeFailed))
{ {
auto customAttrs = GetCustomAttributes(propDef->mFieldDeclaration->mAttributes, target); auto customAttrs = GetCustomAttributes(propDef->mFieldDeclaration->mAttributes, target);
delete customAttrs; delete customAttrs;