Skip to content

Use custom versioning method for SimulationResult Identifier property #354

Description

@Tom-Kingstone

Description:

Probably this should be also raised in the Serialisation Engine, as this is specifically an issue with Immutable BHoMObjects where a json document contains properties that aren't arguments in the constructor, but it would be expected that these would exist in the CustomData (with a warning noting that the property has been placed in custom data). Though upgrades that have already been applied get applied again, causing duplicate property names.

BH.oM.LadybugTools.SimulationResult is being updated to replace usage of the base "name" property with "identifier", when done through the versioning json the above causes the upgrader to erroneously add an extra "Identifier" property to the collection thus breaking normal usage.
As a stop-gap measure, the following would stop the upgrader from duplicating this property, but this doesn't fix the underlying issue.

        [VersioningTarget("BH.oM.LadybugTools.SimulationResult")]
        public static Dictionary<string, object> UpgradeSimulationResult(Dictionary<string, object> oldVersion)
        {
            Dictionary<string, object> newVersion = new Dictionary<string, object>(oldVersion);

            if (!newVersion.ContainsKey("Identifier"))
            {
                newVersion.Add("Identifier", oldVersion["Name"]);
                newVersion["Name"] = "";
            }

            return newVersion;
        }

Steps to reproduce:

Run the RunSimulationResult Execute Command and see the UI error, but the object returned is valid anyway.

Expected behaviour:

No UI error.

Test file(s):

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type:bugError or unexpected behaviour

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions