Object name change and associated custom create method - BHoM/documentation GitHub Wiki
Object name change and associated custom create method
In the Audience_oM I want to change the object name for ProfileParameters
to TierProfileParameters
. There are two Create
methods that will also need to be upgraded. This page describes the steps to achieve that.
First I am going to set up some files and data to help with the process
-
Capture the JSON string of the object to change as described here.
-
Set up a simple file with the auto generated object create method component and related methods that the changes will impact:
-
Use the
VersioningKey
component to get the string that will later be used for the thePreviousVersion
Attribute that I will add to the affected methods. -
Copy the output of
VersioningKey
and paste into a text editor.
Change the code to change the object name
-
Change the object name and the file name for this object.
-
In the Engine and oM projects replace all instances of the old name with the new name.
I'm using find and replace for the renaming - care should be taken here.
-
Check the solution builds.
-
Create and add the versioning JSON file to the project. See here for the content of an empty
Versioning_XX.json
file. -
Add the key value pairs to describe the
ToNew
andToOld
upgrade / downgrade..
-
At this we can rebuild the solution and rebuild the
Versioning_Toolkit
. -
First I'll check the upgrade using the json string and
ToNewVersion
: -
If this fails double check all the steps above.
-
Open Rhino and the simple test file.
-
We'll see the auto generated create method has correctly upgraded, but the others show errors:
Change the code to change the methods
-
I need to add the
PreviousVersion
attribute to ensure the methods are upgraded. -
The text we saved earlier looks like:
BH.Engine.Audience.Create.ProfileParameters(System.Double) BH.Engine.Audience.Create.ProfileParameters(System.Double, System.Double, System.Double, System.Double, System.Int32, System.Double, BH.oM.Humans.ViewQuality.EyePositionParameters, BH.oM.Audience.PlatformParameters)
-
I'll use the first of those two as arguments to the
PreviousVersion
attribute which will be added to the first method like this: -
And adding the
PreviousVersion
attribute to the second method with more arguments will look like this: -
For compliance I will also change the name of the file containing those methods to match the renamed object type they return
TierProfileParameters
. -
We can now rebuild the solution and the
Versioning_Toolkit
and check again if this has worked.