Skip to content

Preserve explicit enum member numbers in Screenplay extraction #91

Closed

Description

@woksin

Cratis/Screenplay#643 and accepted decision 0065 make the model own stored enum identity with all-or-none name = N member syntax (unique int32 values). Authoring ships in Screenplay 4.137.0; ESM admission follows separately.

Preserve explicit/sparse enum numbers during extraction so a generated model does not silently change stored numeric identities. Emit all numbers and round-trip member names and values; reject aliases or unsupported flag combinations rather than defaulting to positional numbering. Update the focused docs/examples and add a sparse/reordered enum regression.

Reference: https://github.com/Cratis/Screenplay/blob/main/decisions/0065-explicit-enum-member-numbers.md

Activity

  1. self-assigned this
    on Oct 11, 2026
  2. woksin commented on Oct 29, 2026

    @woksin
    CollaboratorAuthor

    Analysis and proposed solution

    Current behaviour

    Source/DotNET/CritterStack/EnumConceptFacts.cs:107 populates EnumerationValues from the extracted values. Its lowering guard at Source/DotNET/CritterStack/EnumConceptFacts.cs:297 validates a list of strings. This representation preserves names but does not itself carry explicit numeric member identities. The shared Generation packages are pinned to 0.18.2 in Directory.Packages.props:9–12.

    Root cause / gap

    A name-only enumeration cannot distinguish positional numbering from explicit sparse or reordered persisted values. Updating printed syntax alone would not fix information already lost during contribution construction.

    Proposed change

    Read each enum field's Roslyn constant value and retain explicit numeric identity in the shared concept representation. Validate unique int32 values and reject aliases, unsupported ranges and flag combinations with located diagnostics. Emit complete member numbering whenever numeric identity is represented; never silently fall back to positions. Extend EnumConceptFacts.cs, focused documentation and enum fixtures. Add when_* specifications for sparse and reordered members, negative values, aliases, flags and out-of-range underlying types, followed by compiler-backed generation assertions that verify names and numbers together.

    Size, risk and release intent

    M; medium data-identity risk; minor.

    Dependencies and blockers

    Coordinate authoring and semantic-model support with Cratis/Screenplay#643. Shared Generation contracts must preserve member numbers before this adapter can safely emit them end to end.

  3. removed their assignment
    on Nov 4, 2026
  4. self-assigned this
    on Nov 21, 2026
  5. woksin commented on Nov 21, 2026

    @woksin
    CollaboratorAuthor

    Partial progress in #119: enums whose members are not numbered positionally (explicit sparse, reordered, negative, alias, flags or out-of-range values) now get a located CRITTERSTACK0005 warning, so the lost numbering is reported. Positional enums are unchanged. Emitting the numbers needs ConceptDefinition in Screenplay.Generation to carry them; that is requested in Cratis/Screenplay.Generation#102. This issue stays open until then. (The pinned Generation version mentioned in the description is now 0.21.2.)

  6. github-actions commented on Nov 22, 2026

    @github-actions
    Contributor

    Closed by release v0.28.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions