Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum: several key-value pairs not identical #4201

Open
14 tasks
boghyon opened this issue Jan 31, 2025 · 1 comment
Open
14 tasks

Enum: several key-value pairs not identical #4201

boghyon opened this issue Jan 31, 2025 · 1 comment
Assignees

Comments

@boghyon
Copy link
Contributor

boghyon commented Jan 31, 2025

Problem

According to the documentation topic Defining Control Properties, there are specific restrictions when defining a new enum type:

  • The value for each key must be a string literal, equal to the key itself.
  • [...] only keys and values of type string are supported.
...

Apart from the above documented restrictions; when assigning enum values declaratively in XML or manifest.json, the actual enum values visible in the source code must be passed instead of the keys. This leads to issues like #1703 where the documented key name "Put" was attempted but the actual expected value is "PUT".

While the real values can be accessed and assigned via sap.ui.define / require in JS, it is difficult to do so declaratively in XML or JSON. Developers would have to inspect the source framework code to discover the actual enum values since only the keys are visible in the API reference. Additionally, non-ManagedObject properties, such as the roundingMode in formatOptions, are not validated either unlike in #2166.

Findings

Here are public enum types that I've looped through and that do not align with the above documented restrictions:1

OpenUI5

  • CA-UI5-TBL

    sap/ui/table/library.SharedDomRef

    /**
    * Shared DOM Reference IDs of the table.
    *
    * Contains IDs of shared DOM references, which should be accessible to inheriting controls via getDomRef() function.
    *
    * @version ${version}
    * @enum {string}
    * @public
    */
    thisLib.SharedDomRef = {
    /**
    * The element id of the Horizontal Scroll Bar of the sap.ui.table.Table.
    * @public
    */
    HorizontalScrollBar: "hsb",
    /**
    * The element id of the Vertical Scroll Bar of the sap.ui.table.Table.
    * @public
    */
    VerticalScrollBar: "vsb"
    };

  • CA-UI5-CTR

    sap/ui/unified/library.CalendarIntervalType where OneMonth !== "One Month".
    (Btw. Week and OneMonth are not public intentionally?)

    /**
    * Interval types in a <code>CalendarRow</code>.
    *
    * @enum {string}
    * @public
    * @since 1.34.0
    */
    thisLib.CalendarIntervalType = {
    /**
    * Intervals have the size of one hour.
    * @public
    */
    Hour : "Hour",
    /**
    * Intervals have the size of one day.
    * @public
    */
    Day : "Day",
    /**
    * Intervals have the size of one month.
    * @public
    */
    Month : "Month",
    /**
    * Intervals have the size of one day where 7 days are displayed, starting with the first day of the week.
    *
    * Note: This interval type is NOT supported when creating a custom sap.m.PlanningCalendarView.
    *
    * @since 1.44
    */
    Week : "Week",
    /**
    * Intervals have the size of one day where 31 days are displayed, starting with the first day of the month.
    *
    * Note: This interval type is NOT supported when creating a custom sap.m.PlanningCalendarView.
    *
    * @since 1.46
    */
    OneMonth : "One Month"
    };

    sap/ui/unified/FileUploaderHttpRequestMethod

    /**
    * Types of HTTP request methods.
    *
    * @enum {string}
    * @alias sap.ui.unified.FileUploaderHttpRequestMethod
    * @public
    * @since 1.81.0
    */
    var FileUploaderHttpRequestMethod = {
    /**
    * HTTP request POST method.
    * @public
    */
    Post : "POST",
    /**
    * HTTP request PUT method.
    * @public
    */
    Put : "PUT"
    };

    sap/m/library.DialogRoleType

    /**
    * Enum for the ARIA role of {@link sap.m.Dialog} control.
    *
    * @enum {string}
    * @since 1.65
    * @public
    */
    thisLib.DialogRoleType = {
    /**
    * Represents the ARIA role <code>dialog</code>.
    * @public
    */
    Dialog : "dialog",
    /**
    * Represents the ARIA role <code>alertdialog</code>.
    * @public
    */
    AlertDialog : "alertdialog"
    };

    sap/m/library.LightBoxLoadingStates

    /**
    * Types of LightBox loading stages.
    *
    * @enum {string}
    * @public
    * @since 1.40
    */
    thisLib.LightBoxLoadingStates = {
    /**
    * The LightBox image is still loading.
    * @public
    */
    Loading : "LOADING",
    /**
    * The LightBox image has loaded.
    * @public
    */
    Loaded : "LOADED",
    /**
    * The LightBox image has timed out, could not load.
    * @public
    */
    TimeOutError : "TIME_OUT_ERROR",
    /**
    * The LightBox image could not load.
    * @public
    */
    Error : "ERROR"
    };

    sap/m/MessageBox.Icon

    /**
    * Enumeration of the pre-defined icons that can be used in a MessageBox.
    * @enum {string}
    * @public
    */
    MessageBox.Icon = {
    /**
    * Shows no icon in the message box.
    * @public
    */
    NONE: undefined,

    sap/m/library.PlanningCalendarBuiltInView

    /**
    * A list of the default built-in views in a {@link sap.m.PlanningCalendar}, described by their keys.
    *
    * @enum {string}
    * @public
    * @since 1.50
    */
    thisLib.PlanningCalendarBuiltInView = {
    /**
    * Represents the key of the built-in view, in which the intervals have the size of one hour.
    * @public
    */
    Hour : "Hour",
    /**
    * Represents the key of the built-in view, in which the intervals have the size of one day.
    * @public
    */
    Day : "Day",
    /**
    * Represents the key of the built-in view, in which the intervals have the size of one month.
    * @public
    */
    Month : "Month",
    /**
    * Represents the key of the built-in view, in which the intervals have the size of one day
    * where 7 days are displayed, starting with the first day of the week.
    * @public
    */
    Week : "Week",
    /**
    * Represents the key of the built-in view, in which the intervals have the size of one day
    * where 31 days are displayed, starting with the first day of the month.
    * @public
    */
    OneMonth : "One Month"
    };

    sap/m/library.SharingMode

    /**
    * Enumeration of the <code>SharingMode</code> that can be used in a <code>VariantItem</code>.
    * @enum {string}
    * @public
    */
    thisLib.SharingMode = {
    /**
    * Public mode of the <code>VariantItem</code>.
    * @public
    */
    Public: "public",
    /**
    * Private mode of the <code>VariantItem</code>.
    * @public
    */
    Private: "private"
    };

    sap/m/upload/UploaderHttpRequestMethod

    /**
    * Types of HTTP request methods.
    *
    * @enum {string}
    * @alias sap.m.upload.UploaderHttpRequestMethod
    * @public
    * @since 1.90
    */
    var UploaderHttpRequestMethod = {
    /**
    * HTTP request POST method.
    * @public
    */
    Post : "POST",
    /**
    * HTTP request PUT method.
    * @public
    */
    Put : "PUT"
    };

  • CA-UI5-MDC

    sap/ui/mdc/enums/FilterBarValidationStatus

    /**
    * Enumeration of the possible validation types.
    *
    * @enum {int}
    * @public
    * @since 1.115
    * @alias sap.ui.mdc.enums.FilterBarValidationStatus
    */
    const FilterBarValidationStatus = {
    /**
    * No errors detected.
    * @public
    */
    NoError: -1,
    /**
    * Required filter field without a value.
    * @public
    */
    RequiredHasNoValue: 0,
    /**
    * Filter field in error state.
    * @public
    */
    FieldInErrorState: 1,
    /**
    * Ongoing asynchronous validation.
    * @private
    * @ui5-restricted sap.ui.mdc
    */
    AsyncValidation: 2,
    /**
    * Change is being applied.
    * @private
    * @ui5-restricted sap.ui.mdc
    */
    OngoingChangeAppliance: 3
    };

    sap/ui/mdc/enums/OperatorValueType

    /**
    * Defines what data type is used for parse or format the condition values on a {@link sap.ui.mdc.condition.Operator Operator}.
    *
    * @enum {string}
    * @public
    * @since 1.115
    * @alias sap.ui.mdc.enums.OperatorValueType
    */
    const OperatorValueType = {
    /**
    * The <code>Type</code> of the <code>Field</code> or <code>FilterField</code> using the <code>Operator</code> is used.
    *
    * @public
    */
    Self: "self",
    /**
    * A simple string type is used to display static text.
    *
    * @public
    */
    Static: "static",
    /**
    * The <code>Type</code> of the <code>Field</code> or <code>FilterField</code> using the <code>Operator</code> is used
    * for validation, but the user input is used as value.
    *
    * @public
    */
    SelfNoParse: "selfNoParse"
    };

    sap/ui/mdc/enums/ReasonMode

    /**
    * Enumeration of the possible reasons for the search event.
    *
    * @enum {string}
    * @public
    * @since 1.115
    * @alias sap.ui.mdc.enums.ReasonMode
    */
    const ReasonMode = {
    /**
    * The applied variant is marked as Apply Automatically.
    * @ui5-restricted sap.ui.mdc
    * @public
    */
    Variant: "Variant",
    /**
    * Enter pressed in filter field.
    * @public
    */
    Enter: "Enter",
    /**
    * Go button pressed.
    * @public
    */
    Go: "Go",
    /**
    * Used if the mentioned reasons are not applicable.
    * @public
    */
    Unclear: ""
    };

  • CA-UI5-COR

    sap/base/Log.Level

    /**
    * Enumeration of the configurable log levels that a Logger should persist to the log.
    *
    * Only if the current LogLevel is higher than the level {@link module:sap/base/Log.Level} of the currently added log entry,
    * then this very entry is permanently added to the log. Otherwise it is ignored.
    * @enum {int}
    * @public
    */
    Log.Level = {
    /**
    * Do not log anything
    * @public
    */
    NONE : -1,
    /**
    * Fatal level. Use this for logging unrecoverable situations
    * @public
    */
    FATAL : 0,
    /**
    * Error level. Use this for logging of erroneous but still recoverable situations
    * @public
    */
    ERROR : 1,
    /**
    * Warning level. Use this for logging unwanted but foreseen situations
    * @public
    */
    WARNING : 2,
    /**
    * Info level. Use this for logging information of purely informative nature
    * @public
    */
    INFO : 3,
    /**
    * Debug level. Use this for logging information necessary for debugging
    * @public
    */
    DEBUG : 4,
    /**
    * Trace level. Use this for tracing the program flow.
    * @public
    */
    TRACE : 5,
    /**
    * Trace level to log everything.
    * @public
    */
    ALL : (5 + 1)
    };

    sap/ui/events/KeyCodes

    /**
    * @enum {int}
    * @since 1.58
    * @alias module:sap/ui/events/KeyCodes
    * @public
    */
    var mKeyCodes = {
    /**
    * @type int
    * @public
    */
    BACKSPACE: 8,
    /**
    * @type int
    * @public
    */
    TAB: 9,
    /**
    * @type int
    * @public
    */
    ENTER: 13,
    /**
    * @type int
    * @public
    */
    SHIFT: 16,
    /**
    * @type int
    * @public
    */
    CONTROL: 17,
    /**
    * @type int
    * @public
    */
    ALT: 18,
    /**
    * @type int
    * @public
    */
    BREAK: 19,
    /**
    * @type int
    * @public
    */
    CAPS_LOCK: 20,
    /**
    * @type int
    * @public
    */
    ESCAPE: 27,
    /**
    * @type int
    * @public
    */
    SPACE: 32,
    /**
    * @type int
    * @public
    */
    PAGE_UP: 33,
    /**
    * @type int
    * @public
    */
    PAGE_DOWN: 34,
    /**
    * @type int
    * @public
    */
    END: 35,
    /**
    * @type int
    * @public
    */
    HOME: 36,
    /**
    * @type int
    * @public
    */
    ARROW_LEFT: 37,
    /**
    * @type int
    * @public
    */
    ARROW_UP: 38,
    /**
    * @type int
    * @public
    */
    ARROW_RIGHT: 39,
    /**
    * @type int
    * @public
    */
    ARROW_DOWN: 40,
    /**
    * @type int
    * @public
    */
    PRINT: 44,
    /**
    * @type int
    * @public
    */
    INSERT: 45,
    /**
    * @type int
    * @public
    */
    DELETE: 46,
    /**
    * @type int
    * @public
    */
    DIGIT_0: 48,
    /**
    * @type int
    * @public
    */
    DIGIT_1: 49,
    /**
    * @type int
    * @public
    */
    DIGIT_2: 50,
    /**
    * @type int
    * @public
    */
    DIGIT_3: 51,
    /**
    * @type int
    * @public
    */
    DIGIT_4: 52,
    /**
    * @type int
    * @public
    */
    DIGIT_5: 53,
    /**
    * @type int
    * @public
    */
    DIGIT_6: 54,
    /**
    * @type int
    * @public
    */
    DIGIT_7: 55,
    /**
    * @type int
    * @public
    */
    DIGIT_8: 56,
    /**
    * @type int
    * @public
    */
    DIGIT_9: 57,
    /**
    * @type int
    * @public
    */
    A: 65,
    /**
    * @type int
    * @public
    */
    B: 66,
    /**
    * @type int
    * @public
    */
    C: 67,
    /**
    * @type int
    * @public
    */
    D: 68,
    /**
    * @type int
    * @public
    */
    E: 69,
    /**
    * @type int
    * @public
    */
    F: 70,
    /**
    * @type int
    * @public
    */
    G: 71,
    /**
    * @type int
    * @public
    */
    H: 72,
    /**
    * @type int
    * @public
    */
    I: 73,
    /**
    * @type int
    * @public
    */
    J: 74,
    /**
    * @type int
    * @public
    */
    K: 75,
    /**
    * @type int
    * @public
    */
    L: 76,
    /**
    * @type int
    * @public
    */
    M: 77,
    /**
    * @type int
    * @public
    */
    N: 78,
    /**
    * @type int
    * @public
    */
    O: 79,
    /**
    * @type int
    * @public
    */
    P: 80,
    /**
    * @type int
    * @public
    */
    Q: 81,
    /**
    * @type int
    * @public
    */
    R: 82,
    /**
    * @type int
    * @public
    */
    S: 83,
    /**
    * @type int
    * @public
    */
    T: 84,
    /**
    * @type int
    * @public
    */
    U: 85,
    /**
    * @type int
    * @public
    */
    V: 86,
    /**
    * @type int
    * @public
    */
    W: 87,
    /**
    * @type int
    * @public
    */
    X: 88,
    /**
    * @type int
    * @public
    */
    Y: 89,
    /**
    * @type int
    * @public
    */
    Z: 90,
    /**
    * @type int
    * @public
    */
    WINDOWS: 91,
    /**
    * @type int
    * @public
    */
    CONTEXT_MENU: 93,
    /**
    * @type int
    * @public
    */
    TURN_OFF: 94,
    /**
    * @type int
    * @public
    */
    SLEEP: 95,
    /**
    * @type int
    * @public
    */
    NUMPAD_0: 96,
    /**
    * @type int
    * @public
    */
    NUMPAD_1: 97,
    /**
    * @type int
    * @public
    */
    NUMPAD_2: 98,
    /**
    * @type int
    * @public
    */
    NUMPAD_3: 99,
    /**
    * @type int
    * @public
    */
    NUMPAD_4: 100,
    /**
    * @type int
    * @public
    */
    NUMPAD_5: 101,
    /**
    * @type int
    * @public
    */
    NUMPAD_6: 102,
    /**
    * @type int
    * @public
    */
    NUMPAD_7: 103,
    /**
    * @type int
    * @public
    */
    NUMPAD_8: 104,
    /**
    * @type int
    * @public
    */
    NUMPAD_9: 105,
    /**
    * @type int
    * @public
    */
    NUMPAD_ASTERISK: 106,
    /**
    * @type int
    * @public
    */
    NUMPAD_PLUS: 107,
    /**
    * @type int
    * @public
    */
    NUMPAD_MINUS: 109,
    /**
    * @type int
    * @public
    */
    NUMPAD_COMMA: 110,
    /**
    * @type int
    * @public
    */
    NUMPAD_SLASH: 111,
    /**
    * @type int
    * @public
    */
    F1: 112,
    /**
    * @type int
    * @public
    */
    F2: 113,
    /**
    * @type int
    * @public
    */
    F3: 114,
    /**
    * @type int
    * @public
    */
    F4: 115,
    /**
    * @type int
    * @public
    */
    F5: 116,
    /**
    * @type int
    * @public
    */
    F6: 117,
    /**
    * @type int
    * @public
    */
    F7: 118,
    /**
    * @type int
    * @public
    */
    F8: 119,
    /**
    * @type int
    * @public
    */
    F9: 120,
    /**
    * @type int
    * @public
    */
    F10: 121,
    /**
    * @type int
    * @public
    */
    F11: 122,
    /**
    * @type int
    * @public
    */
    F12: 123,
    /**
    * @type int
    * @public
    */
    NUM_LOCK: 144,
    /**
    * @type int
    * @public
    */
    SCROLL_LOCK: 145,
    /**
    * @type int
    * @public
    */
    OPEN_BRACKET: 186,
    /**
    * @type int
    * @public
    */
    PLUS: 187,
    /**
    * @type int
    * @public
    */
    COMMA: 188,
    /**
    * @type int
    * @public
    */
    SLASH: 189,
    /**
    * @type int
    * @public
    */
    DOT: 190,
    /**
    * @type int
    * @public
    */
    PIPE: 191,
    /**
    * @type int
    * @public
    */
    SEMICOLON: 192,
    /**
    * @type int
    * @public
    */
    MINUS: 219,
    /**
    * @type int
    * @public
    */
    GREAT_ACCENT: 220,
    /**
    * @type int
    * @public
    */
    EQUALS: 221,
    /**
    * @type int
    * @public
    */
    SINGLE_QUOTE: 222,
    /**
    * @type int
    * @public
    */
    BACKSLASH: 226
    };

    sap/ui/core/mvc/XMLView.PreprocessorType

    /**
    * Specifies the available preprocessor types for XMLViews
    *
    * @see sap.ui.core.mvc.XMLView
    * @see sap.ui.core.mvc.View.Preprocessor
    * @enum {string}
    * @since 1.34
    * @public
    */
    XMLView.PreprocessorType = {
    /**
    * This preprocessor receives the plain xml source of the view and should also return a valid
    * xml ready for view creation
    * @public
    */
    XML : "xml",
    /**
    * This preprocessor receives a valid xml source for View creation without any template tags but with control
    * declarations. These include their full IDs by which they can also be queried during runtime.
    * @public
    */
    VIEWXML : "viewxml",
    /**
    * This preprocessor receives the control tree produced through the view source
    * @public
    */
    CONTROLS : "controls"
    };

    sap/ui/core/Popup.Dock

    /**
    * Enumeration providing options for docking of some element to another.
    *
    * "Right" and "Left" will stay the same in RTL mode, but "Begin" and "End" will flip to the other side ("Begin" is "Right" in RTL).
    *
    * @public
    * @enum {string}
    */
    Popup.Dock = {
    /**
    * @public
    * @type {string}
    */
    BeginTop : "begin top",
    /**
    * @public
    * @type {string}
    */
    BeginCenter : "begin center",
    /**
    * @public
    * @type {string}
    */
    BeginBottom : "begin bottom",
    /**
    * @public
    * @type {string}
    */
    LeftTop : "left top",
    /**
    * @public
    * @type {string}
    */
    LeftCenter : "left center",
    /**
    * @public
    * @type {string}
    */
    LeftBottom : "left bottom",
    /**
    * @public
    * @type {string}
    */
    CenterTop : "center top",
    /**
    * @public
    * @type {string}
    */
    CenterCenter : "center center",
    /**
    * @public
    * @type {string}
    */
    CenterBottom : "center bottom",
    /**
    * @public
    * @type {string}
    */
    RightTop : "right top",
    /**
    * @public
    * @type {string}
    */
    RightCenter : "right center",
    /**
    * @public
    * @type {string}
    */
    RightBottom : "right bottom",
    /**
    * @public
    * @type {string}
    */
    EndTop : "end top",
    /**
    * @public
    * @type {string}
    */
    EndCenter : "end center",
    /**
    * @public
    * @type {string}
    */
    EndBottom : "end bottom"
    };

    sap/ui/core/ws/ReadyState

    /**
    * Defines the different ready states for a WebSocket connection.
    *
    * @version ${version}
    * @enum {int}
    * @public
    * @alias sap.ui.core.ws.ReadyState
    */
    var ReadyState = {
    /**
    * The connection has not yet been established.
    * @public
    */
    CONNECTING: 0,
    /**
    * The WebSocket connection is established and communication is possible.
    * @public
    */
    OPEN: 1,
    /**
    * The connection is going through the closing handshake.
    * @public
    */
    CLOSING: 2,
    /**
    * The connection has been closed or could not be opened.
    * @public
    */
    CLOSED: 3
    };

    sap/ui/core/ws/SapPcpWebSocket.SUPPORTED_PROTOCOLS

    /**
    * Protocol versions.
    *
    * One (or more) of these have to be selected to create an SapPcpWebSocket connection
    * (or no protocol at all).
    *
    * @enum {string}
    * @public
    * @static
    */
    SapPcpWebSocket.SUPPORTED_PROTOCOLS = {
    /**
    * Protocol v10.pcp.sap.com
    * @public
    * @name sap.ui.core.ws.SapPcpWebSocket.SUPPORTED_PROTOCOLS.v10
    */
    v10 : "v10.pcp.sap.com"
    };

    sap/ui/model/analytics/odata4analytics.SortOrder

    /**
    * Sort order of a property.
    *
    * @enum {string}
    * @public
    */
    odata4analytics.SortOrder = {
    /**
    * Sort Order: ascending.
    *
    * @public
    */
    Ascending : "asc",
    /**
    * Sort Order: descending.
    *
    * @public
    */
    Descending : "desc"
    };

    sap/ui/model/ChangeReason

    /**
    * Change Reason for Model/ListBinding/TreeBinding.
    *
    * @enum {string}
    * @public
    * @alias sap.ui.model.ChangeReason
    */
    var ChangeReason = {
    /**
    * The list was sorted
    * @public
    */
    Sort: "sort",
    /**
    * The List was filtered
    * @public
    */
    Filter: "filter",
    /**
    * The list has changed
    * @public
    */
    Change: "change",
    /**
    * The list context has changed
    * @public
    */
    Context: "context",
    /**
    * The list was refreshed
    * @public
    */
    Refresh: "refresh",
    /**
    * The tree node was expanded
    * @public
    */
    Expand: "expand",
    /**
    * The tree node was collapsed
    * @public
    */
    Collapse: "collapse",
    /**
    * A context was removed from a binding.
    * @public
    */
    Remove: "remove",
    /**
    * A context was added to a binding.
    * @public
    */
    Add: "add",
    /**
    * Binding changes a model property value
    * @public
    */
    Binding: "binding"
    };

    sap/ui/model/odata/UpdateMethod

    /**
    * Different methods for update operations.
    *
    * @enum {string}
    * @public
    * @alias sap.ui.model.odata.UpdateMethod
    */
    var UpdateMethod = {
    /**
    * Update requests will be send with HTTP method <code>MERGE</code>.
    *
    * @public
    */
    Merge: "MERGE",
    /**
    * Update requests will be send with HTTP method <code>PUT</code>.
    * @public
    */
    Put: "PUT"
    };

SAPUI5

  • CA-UI5-CUX

    sap/cux/home/library.NewsType

  • CA-UI5-VTK

    sap/ui/vk/CameraFOVBindingType

    sap/ui/vk/CameraProjectionType

    sap/ui/vk/DrawerToolbarButton

    sap/ui/vk/ObjectType

    sap/ui/vk/SelectionMode

    sap/ui/vk/VisibilityMode

    sap/ui/vk/ZoomTo

  • GA-GTF-VBZ

    sap/ui/vbm/library.ClusterInfoType

  • CA-UI5-CMP

    sap/ui/comp/library.smartchart.SelectionMode

    sap/ui/comp/library.smartfield.ControlContextType

    sap/ui/comp/library.smartfield.ControlProposalType

    sap/ui/comp/library.smartfilterbar.SelectOptionSign

    sap/ui/comp/library.TextArrangementType

  • CA-UI5-SC

    sap/suite/ui/commons/library.CalculationBuilderFunctionType

    sap/suite/ui/commons/library.SelectionModes

  • CA-UI5-RUL

    sap/rules/ui/library.DecisionTableFormat

    sap/rules/ui/library.RuleHitPolicy

    sap/rules/ui/library.RuleType

  • CA-UI5-CTR-GNT

    sap/gantt/library.config.TimeUnit

    sap/gantt/library.def.filter.ColorMatrixValue

    sap/gantt/library.def.filter.MorphologyOperator

    sap/gantt/library.shape.ext.rls.RelationshipType

    sap/gantt/library.shape.ShapeCategory

  • LOD-ANA-FLY-DF

    sap/sac/df/types/DocumentsSupportType

    sap/sac/df/types/SortDirection

    sap/sac/df/types/SortType

  • BI-CVM

    sap/chart/data/MeasureSemantics

    sap/chart/library.MessageId

    sap/chart/library.SelectionBehavior

    sap/chart/library.SelectionMode

  • BI-CVM-UI5

    sap/viz/ui5/format/ChartFormatter.DefaultPattern

Similar issues / fixes in the past

Ideas to reduce future issues?

  • UI5 linter detecting faulty enum definitions
  • Future fatal logging by DataType.registerEnum if the passed object contains faulty enum definitions
  • Allowing enums to be required and assigned in XML such as to ManagedObject properties and binding infos (Cf. https://x.com/wridgeu/status/1567955929051570178 by @wridgeu)
  • Downporting fixes
  • Adding a test to ensure future introduction of new enums comply with the documented restrictions

Footnotes

  1. Excluded from the search were the libs sap.apf, sap.ca.scfld.md, sap.fiori, sap.ui.demoapps, sap.ui.documentation, sap.ui.server.java, sap.ui.server.abap, sap.ui.support, sap.ushell_abap, themelib*, *.test*, *.tools*, and libs / enum types that are either deprecated or restricted. Types related to MockServer, jQuery, and test were also skipped. IllustratedMessageType is ignored too since the IllustratedMessage property illustrationType explicitly states that the illustration set name (e.g. sapIllus-) must be prepended.

@codeworrior
Copy link
Member

Some comments:

Apart from the above documented restrictions; when assigning enum values declaratively in XML or manifest.json, the actual enum values visible in the source code must be passed instead of the keys

This is partially wrong: in XML, you have to use the key, not the value. This is by intention as developers should not be forced to look up values in the source code (see implementation of DataType#parseValue for enum types)

Use cases in the manifest (e.g. model settings as in #1703, but there are others, too) are not covered so far and we might have to re-consider our rules (see next paragraph).

By intention, not every enum in UI5 has to comply with the key === value rule, only when it is intended to be used as type for a managed property. For that reason, our internal metadata validation tool (not visible to the outside, therefore not linking it) checks enums once they are found in a managed property of control / element or other managed object. IMO this might apply to several of the above enums.

Unfortunately, the metadata validation is forcefully bypassed by several SAPUI5 libs. We are already in the process of enforcing its use (for other reasons than the enums).

Any existing enums that are used or foreseeable will be used in managed properties (or in the manifest, sigh) and which don't comply with the key === value constraint. need to be fixed.

P.S.: Not everyone can read the full content of the post on "X".

@i556484 i556484 self-assigned this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants