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 Stoatly | Effect on your code |
|---|---|
| Add a field, enum value, object type or formula | Nothing breaks. New members appear |
| Rename a label | Nothing. Keys and code names stay the same |
| Deprecate a field or enum value | A compiler warning where it's used |
| Delete a field | The property is removed. Code that used it stops compiling |
| Delete an enum, or an enum value that never shipped | The type or member is removed |
| Change a shipped enum value's C# name | Code that used the old name stops compiling |
| Delete an object type | The class is removed, along with its records |
| Change a record's slug | Load with the old slug returns null, with no compile error |
| Rename or change a runtime formula's parameters | Code that calls it stops compiling |
| Change the namespace | Every file regenerates. Code using the old namespace stops compiling |
| Move the code or data folders | Files 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
- 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.
- 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.
- 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.
- Keep slugs stable. Record slugs are strings in your code, so a rename doesn't fail until runtime.
- 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.