Skip to Content
Stoatly Docs
Unity

Keep your code working

Generated code follows your schema, and each pull request regenerates it. That keeps your code honest: a change in Stoatly shows up as a compile error where it matters. It also means some changes need your code updated at the same time. These are the ones to watch.

What breaks, and what doesn't

Change in StoatlyEffect on your code
Add a field, enum value, object type or formulaNothing breaks. New members appear
Rename a labelNothing. Keys and code names stay the same
Deprecate a field or enum valueA compiler warning where it's used
Delete a fieldThe property is removed. Code that used it stops compiling
Delete an enum, or an enum value that never shippedThe type or member is removed
Change a shipped enum value's C# nameCode that used the old name stops compiling
Delete an object typeThe class is removed, along with its records
Change a record's slugLoad with the old slug returns null, with no compile error
Rename or change a runtime formula's parametersCode that calls it stops compiling
Change the namespaceEvery file regenerates. Code using the old namespace stops compiling
Move the code or data foldersFiles move. References by path need updating

Changing a field's type isn't allowed, so it can't break your code.

Formula field properties now end in Field, so Dps is DpsField. Code that reads a formula field needs updating after the next regeneration.

Make a change safely

  1. Deprecate first. Deprecating a field or an enum value keeps it working and gives you warnings that show every use. Update the code, then delete in a later pull request.
  2. Search before you rename. Stoatly lists the files in your repository that mention an enum value before you change its C# name. It only finds direct references, so also search for aliases.
  3. Change code and data together. Put the schema change and your code fix in the same branch if you can, so the project compiles at every step.
  4. Keep slugs stable. Record slugs are strings in your code, so a rename doesn't fail until runtime.
  5. Read the impact notice. Delete and deprecate dialogs count the records affected before you confirm, as described in Change a schema safely.

After a pull request merges

Pull the new files into your Unity project. Unity recompiles, and any code that no longer matches the schema shows as errors or warnings. Fix them, and commit the result alongside the generated files.

Never edit generated files

Your edits to generated files are overwritten by the next pull request. Put your own code in your own files, for example as extension methods on the generated classes.

On this page