umbraco / Announcements

Subscribe to this repo to be notified about major changes in Umbraco-CMS, Deploy and Forms
MIT License
21 stars 0 forks source link

[Breaking change]: Default property value converters will be added for all value types in Umbraco 13 #12

Open kjac opened 1 year ago

kjac commented 1 year ago

Description

It is possible to create property editors without backing property value converters. Usually this is done using manifests. These property editors still declare a value type, which should be one of the predefined ones in ValueTypes.

However, the resulting property value output for these property editor types are not always typed according to their declared value types.

Moving forward we will introduce default property value converters to handle the conversion of all value types (except JSON, as it's already handled). Thus, property editors without backing property value converters will still have their property value outputs translated into types corresponding to their declared value types.

Besides having correctly typed property value outputs, this also ensures that the properties in ModelsBuilder generated models are typed correctly.

This change only affects custom property editors with no property value converters. Existing and/or custom property value converters will take precedence over these new default property value converters.

Version

Umbraco 13

Previous behavior

The following applies only to custom property editors with no backing property value converters.

Properties of any other value type than JSON are represented as type object in ModelsBuilder generated classes. JSON value type properties are represented as JToken.

New behavior

The following applies only to custom property editors with no backing property value converters.

Properties of any type are represented by their corresponding type in ModelsBuilder generated classes:

Type of breaking change

Reason for change

To ensure type safety for all value types, not only for JSON-

Recommended action

If you have no custom property editors, or all custom property editors have backing property value converters, no action is necessary.

Regenerate ModelsBuilder models and recompile against the newly generated models.

Revisit any explicit parsing or casting when consuming property editor data from "property-value-converter-less" properties. Likely the assumptions will be wrong, as the property output values are now typed correctly.

Affected APIs

IPublishedContent and IPublishedElement