Fix boxing in custom attributes
@@ -4837,10 +4837,17 @@ HRESULT CLR_RT_AttributeParser::ReadString(CLR_RT_HeapBlock *&value)
NANOCLR_HEADER();
CLR_UINT32 tk;
+
+ CLR_RT_TypeDescriptor desc;
+ NANOCLR_CHECK_HRESULT(desc.InitializeFromType(g_CLR_RT_WellKnownTypes.m_String));
+
NANOCLR_READ_UNALIGNED_UINT16(tk, m_blob);
NANOCLR_CHECK_HRESULT(CLR_RT_HeapBlock_String::CreateInstance(*value, CLR_TkFromType(TBL_Strings, tk), m_assm));
+ // need to box this
+ value->PerformBoxing(desc.m_handlerCls);
+
NANOCLR_NOCLEANUP();
}
@@ -4852,6 +4859,9 @@ HRESULT CLR_RT_AttributeParser::ReadNumericValue(
{
NANOCLR_HEADER();
+ CLR_RT_TypeDescriptor desc;
+ NANOCLR_CHECK_HRESULT(desc.InitializeFromType(*m_cls));
+
NANOCLR_CHECK_HRESULT(g_CLR_RT_ExecutionEngine.NewObjectFromIndex(*value, g_CLR_RT_WellKnownTypes.m_TypeStatic));
// need to setup reflection and data type Id to properly setup the object
@@ -4865,8 +4875,6 @@ HRESULT CLR_RT_AttributeParser::ReadNumericValue(
NANOCLR_READ_UNALIGNED_UINT8(boolValue, m_blob);
value->SetBoolean((bool)boolValue);
- // this is a bool so need to box it
- value->PerformBoxingIfNeeded();
}
else
{
@@ -4877,6 +4885,9 @@ HRESULT CLR_RT_AttributeParser::ReadNumericValue(
m_blob += size;
}
+ // need to box this
+ value->PerformBoxing(desc.m_handlerCls);
+
NANOCLR_NOCLEANUP();
}
