Skip to content

fix: Carry enum options into every catalog style listing - #2256

Merged
DaveSkender merged 2 commits into
mainfrom
test/catalog-enum-options
Sep 24, 2026
Merged

DaveSkender merged 2 commits into
mainfrom
test/catalog-enum-options

Conversation

@DaveSkender

@DaveSkender DaveSkender commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Closes #2230.

Enum parameters reached consumers with DataType: "enum" and no EnumOptions, so a catalog-driven UI couldn't offer a select or validate a value.

AddEnumParameter did fill EnumOptions, but only on each indicator's Common listing. Every style listing is built from that base through the CatalogListingBuilder(IndicatorListing) copy constructor, which rebuilt each parameter field by field and left EnumOptions out. Catalog.Get() returns only style listings, so every enum parameter a consumer could see had EnumOptions: null, both in-process and from ToJson().

Changes

  • The copy constructor copies each parameter with with, so it can't drop a property added later, and EnumOptions gets its own dictionary per copy. Results have no mutable members, so inherited listings share them.

Tests

  • EveryEnumParameterListsItsValues (library, Catalog.Binding.Tests.cs) takes each parameter's type from the bound method signature, not from the catalog's own DataType. Any parameter the method takes as an enum must be catalogued as enum, with EnumOptions equal to that enum's members. On main it reports every enum parameter in the catalog.
  • InheritedListingCopiesEveryMember (library) checks that an inherited listing's parameters and results are equivalent to its base, and that it doesn't share its options dictionary.
  • tests/PublicApi/Catalog.EnumOptions.Tests.cs reads the options the way a consumer does: from each style listing and from the JSON export.
  • Mutations, each red against the committed tests:
    • Dropping EnumOptions in the copy fails all four new tests.
    • Sharing the base dictionary fails InheritedListingCopiesEveryMember.
    • Declaring BETA's type through AddParameter<BetaType> fails EveryEnumParameterListsItsValues, naming the listing.
  • Every changed line in src is covered by the library suite, both branches of the EnumOptions copy included.

Decision record

  • Chosen: fix the copy, and guard it from the method signature.
  • Discarded: adding EnumOptions to the field-by-field list. It fixes this property and leaves the same trap for the next one.
  • What would reverse it: a property that must differ between a base listing and its styles. That property would be set explicitly in the with expression.

@codacy-production

codacy-production Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · -0.02% coverage variation

Metric Results
Coverage variation ✅ -0.02% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (7828c69) 19609 18921 96.49%
Head commit (df5bd99) 19636 (+27) 18944 (+23) 96.48% (-0.02%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#2256) 3 3 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@DaveSkender
DaveSkender marked this pull request as ready for review September 24, 2026 03:02
@DaveSkender
DaveSkender requested a review from a team September 24, 2026 03:02
@facioquoqa

facioquoqa Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

:neckbeard: FaciōQuōqa Mage Reviewer is standing by.

  • Trigger review

@DaveSkender
DaveSkender added this pull request to stack #2258 September 24, 2026 03:21
@DaveSkender
DaveSkender merged commit e7225b6 into main Sep 24, 2026
11 checks passed
@DaveSkender
DaveSkender deleted the test/catalog-enum-options branch September 24, 2026 03:53
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum parameters are catalogued without their permitted values

1 participant