Reply To: "Default value for parameter", serialization, and 2.7 / 2.8 differences

Forums 💬 FlowCanvas ⚙️ Support "Default value for parameter", serialization, and 2.7 / 2.8 differences Reply To: "Default value for parameter", serialization, and 2.7 / 2.8 differences

#21960
kalms
Participant

    After a good night’s sleep I have a better understanding of what the ‘no distinct “default value”‘ model would mean.

    Description:

    (I think this is how NodeCanvas 2.7 worked)

    When you add a new node to a flow graph, the node’s value inputs will be assigned values according to default(T) for each input.
    All the node values will be serialized and deserialized, even values that happen to match default(T) at the time of serialization.

    If a node is deserialized and there is information missing for some value inputs (because new value inputs have been added to the node’s C# implementation), then default(T) will be assigned as the node’s value input.

    The UI will display values for value inputs that match default(T) in discrete semi-transparent text, and values that do not match in strong non-transparent text.

    There is a possibility here to support the feature of allowing the C# programmer to change the default value for value inputs. With This would be done not by modifying the class’s default constructor, but either by adding extra arguments to the ValueInput<> type or by keeping the default-value as a member of each ValueInput object. This programmer-specified value would override the use of default(T) in all places in the above text.

    It means that if a C# programmer modifies the default value for an existing value input, then it will only affect new nodes, and nodes which were serialized with an old format where the value input didn’t exist. If the FlowGraph programmer has ever seen (and saved) the node with a certain value displayed for a value input, that value will remain fixed.

    For FlowCanvas 2.7 we could sort-of accomplish this this by modifying .serializedValue for an input during RegisterPorts(). However, that did not propagate to the UI as described below (which would make the logical model more consistent):

    The UI’s semi-transparent colouring of a value input means: The value of this value input matches the C#-programmer-specified default value right now. It does not mean that the value is the default value, nor that it changes along with the default value. A “Reset to default” function could exist, which would change any value input to its current default value.