Fixed bug where certain null objects in deserialization was not handled
This commit is contained in:
parent
098c621316
commit
17662abef1
|
@ -142,6 +142,31 @@ namespace SHADE
|
||||||
bool SerialisationUtilities::fieldAssignYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
|
bool SerialisationUtilities::fieldAssignYaml(System::Reflection::FieldInfo^ fieldInfo, Object^ object, YAML::Node& node)
|
||||||
{
|
{
|
||||||
System::Object^ valueObj = fieldInfo->GetValue(object);
|
System::Object^ valueObj = fieldInfo->GetValue(object);
|
||||||
|
if (valueObj == nullptr)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_same_v<FieldType, System::Enum>)
|
||||||
|
{
|
||||||
|
if (fieldInfo->FieldType->IsSubclassOf(System::Enum::typeid))
|
||||||
|
{
|
||||||
|
valueObj = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (fieldInfo->FieldType == FieldType::typeid)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_same_v<FieldType, System::String>)
|
||||||
|
{
|
||||||
|
valueObj = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
valueObj = FieldType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (varAssignYamlInternal<FieldType>(valueObj, node))
|
if (varAssignYamlInternal<FieldType>(valueObj, node))
|
||||||
{
|
{
|
||||||
fieldInfo->SetValue(object, valueObj);
|
fieldInfo->SetValue(object, valueObj);
|
||||||
|
|
Loading…
Reference in New Issue