Skip to content

Discussion: Should we make the enums forward-compatible? #1071

@Kwok-he-Chu

Description

@Kwok-he-Chu

Describe the bug
When the models are generated using the sdk-automation based on the OpenApi Specifications, the enums fields in C# are assigned their respective integer values based on alphabetical order. This may pose a problem when f.e. developers upgrade the library and have stored it previously as integers.

See also: dotnet/csharplang#2849
The AWS-dotnet SDK, takes a forward compatible approach

When enums are removed, or added, the following happens:

To Reproduce:

Similar enum changes can be found here during the generation process:

Considered options

  • Leave it-as-is with a README notice (see PR)
  • Change all enums to strings (make them forward compatible)
    • Con: Developer will have no any idea what string value it should enter unless it's mentioned in a description/summary or documentation
  • Change all enums to a class that holds a string enum, See branche with a proof-of-concept
    • Con: Classes cannot be parameterized in unittests as constants. If we keep the names the same, we can keep the functionality of the library similar.

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