Obsolescence
When the functionalities of an application change from one version to another, it can be useful to keep an old implementation in order to avoir breaking changes. For this purpose, in Neos Studio, you can flag the old implementation as obsolete. This allows :
- to make changes progressively
- developers to know an element is obsolete, to avoid using and an know what element to use instead
- to have visible warnings that inform obsolete elements are in use
Here is the list of metadata that can be defined as obsolete :
- Data objects
- Entities and their properties
- Entity views and their properties
- Enums
- Server methods
- Lookups
- Notifications
- Themes
- UI components
- UI views and their properties
How to check if obsolete metadata is used
Detecting obsolete elements referenced in metadata
The neos check-metadata command analyses if an obsolete element is directly referenced in the metadata of another element of the application. When an obsolete element is referenced, it appears as a warning.
Warning
Obsolete elements that are not directly referenced in metadata are ignored. For example, an obsolete UI component used in the template of a UI view will not be detected.
Detecting obsolete elements not directly referenced in metadata
The neos generate -rb is able to detect the use of obsolete elements that are not directly referenced in metadata.
In the previous scenario where an obsolete UI view is used in the template of a UI view, the command will be able to log a warning.
Building the C# solution
The C# Obsolete attribute can be used to flag code as obsolete. C# code generated by Neos from an element flagged as obsolete in Neos Studio (for example, from an obsolete entity view) is automatically flagged using this attribute.
To be able to detect obsolete C# code, you need to manually build the solution.
Obsolete highlight in Neos studio
In Neos Studio, obsolete elements are highlighted :
- the background color of the header of an obsolete element is orange
- the color of the name of an obsolete property is orange
Obsolete metadata screen in Neos Studio
If Neos Studio, in the Tools section of the menu by type, you can find the Obsolete metadata screen.
This allows you to see all elements that are flagged as obsolete in the application.
Planing the end of support of an element
By default, obsolete metadata are logged as warning.
However, it is possible to set a threshold version in the Error after version property of an element: the obsolete element stays a warning up to and including that version, and is logged as an error for any strictly later module version.
This is useful for planning when an obsolete element should be deleted to avoid polluting the code base indefinitely.
For example, if you develop a module A in version 1.20.0 that contains a UI view B that is obsolete.
To give developers who use your module A some time to replace the use of UI view B, you can set the Error after version property of the UI view to 1.23.0.
A warning is logged up to and including version 1.23.0; from the next version (1.23.1) onward an error is logged instead.