Serialiser_Engine: Converting from string (or other System type) to IObject does not check that data has been lost
- Dominant language
- C#
- Stars
- 30
- Forks
- 13
- Avg merge
- 7d 10h
- Merged PRs (30d)
- 5
Description
#### Description:
When a property of an object has been converted from a system type (e.g. `System.String`) to an `IObject`, when deserialising from an old version, the property in question (if the old property is not null) deserialises as null, which is a valid value for an `IObject`, so deserialisation carries on as normal.
There is no check that the original value was not null. This leads to data loss as the deserialiser doesn't have mismatches on property types, so the upgrader for the object is not run, which means that explicit versioning upgrades are not applied unless there is some other issue with the object.
#### Steps to reproduce:
clone the [LadybugTools_Toolkit](https://github.com/BHoM/LadybugTools_Toolkit) repository, checkout `LadybugTools_Toolkit-#296-SeparateSimulationFromPlotting` and build, then clone [Versioning_Toolkit](https://github.com/BHoM/Versioning_Toolkit), checkout the same named branch there and build. Then open the provided grasshopper script.
The `FromJson` method should return a `SimulationResult`, but the `EpwFile` `FileSettings` property will be missing `FileName` and `Directory` information.
#### Expected behaviour:
`FileName` and `Directory` should be set.
#### Test file(s):
Unzip this and make sure that both the json and gh files are in the same folder, then run the gh script:
[serialiser.zip](https://github.com/user-attachments/files/18848105/serialiser.zip)
@IsakNaslundBh
Contributor guide
Assessment
This issue has not been assessed yet.