# 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

1. Capture the JSON string of the object to change as described here.
2. Set up a simple file with the auto generated object create method component and related methods that the changes will impact:

1. Use the VersioningKey component to get the string that will later be used for the the PreviousVersion Attribute that I will add to the affected methods.

1. Copy the output of VersioningKey and paste into a text editor.

## Change the code to change the object name

1. Change the object name and the file name for this object.
2. 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.

3. Check the solution builds.

4. Create and add the versioning JSON file to the project. See here for the content of an empty Versioning_XX.json file.
5. Add the key value pairs to describe the ToNew and ToOld upgrade / downgrade.

. 1. At this we can rebuild the solution and rebuild the Versioning_Toolkit. 1. First I'll check the upgrade using the json string and ToNewVersion:

1. If this fails double check all the steps above. 1. Open Rhino and the simple test file. 1. We'll see the auto generated create method has correctly upgraded, but the others show errors:

## Change the code to change the methods

1. I need to add the PreviousVersion attribute to ensure the methods are upgraded.
2. 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)

3. I'll use the first of those two as arguments to the PreviousVersion attribute which will be added to the first method like this:

1. And adding the PreviousVersion attribute to the second method with more arguments will look like this:

4. For compliance I will also change the name of the file containing those methods to match the renamed object type they return TierProfileParameters.

5. We can now rebuild the solution and the Versioning_Toolkit and check again if this has worked.

Last update: March 17, 2023