Skip to content

Allow the generation of Swift code that follows the normal case conventions. #2276

Open
@pixlwave

Description

@pixlwave

Semi-related to #1426, it would be great if UniFFI could generate Swift function/variable/argument/type names that conform to the “Follow case conventions” point in the Swift API Design Guidelines:

Acronyms and initialisms that commonly appear as all upper case in American English should be uniformly up- or down-cased according to case conventions.

A couple of examples:

Rust Swift (current) Swift (desirable)
avatar_url avatarUrl avatarURL
raw_json_string rawJsonString rawJSONString

Some obvious thoughts that came out of an initial conversation:

  • This should be opt-in to avoid breaking backwards compatibility.
  • The set of acronyms/initialisms should probably be defined by each project in their uniffi.toml as whilst some conversions like URL and JSON aren't debatable, other such as ID may raise discussion as to whether or not they count (and this clearly isn't UniFFI's problem to deal with).
    • This could also make incremental adoption easy as a project could migrate acronym by acronym.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions