Skip to content

[code_assets] Make LinkMode and LinkModePreference closed#3462

Open
dcharkes wants to merge 1 commit into
mainfrom
code-assets-close-link-mode
Open

[code_assets] Make LinkMode and LinkModePreference closed#3462
dcharkes wants to merge 1 commit into
mainfrom
code-assets-close-link-mode

Conversation

@dcharkes

@dcharkes dcharkes commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Makes the link mode and link mode preference closed enums / a closed tagged union.

#3413 (comment)

Code assets changes:

  • Changes the JSON schema to a closed enum for link mode preference and closed tagged union for link mode.
    • So encountering an unknown value in a json is now a parse error.
    • And will print a more elaborate error message.
  • Sealed the LinkMode class.
  • Skipping a version bump, we'll bump to 2.0 in the next PR due to breaking changes.

JSON syntax generator changes:

  • Updated closed enum generation to pass valid enum values to _throwFormatException.
  • Updated closed tagged union generationto pass valid discriminator tag values to _throwFormatException.
  • Added Set<String>? expectedValues parameter to throwFormatException and errorString to format error messages as Expected one of 'a', 'b'.
  • Made expectedType an optional named parameter on throwFormatException and errorString in helper_library.dart.
  • Added a json path to the constructor for enums to be able to give the json path in the error message.

Other package changes:

  • Update all the generated syntax (no functional change as they have no closed enums).

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

PR Health

Breaking changes ⚠️
Package Change Current Version New Version Needed Version Looking good?
hooks_runner Non-Breaking 1.5.0 1.6.0-wip 1.6.0-wip ✔️
code_assets Non-Breaking 1.2.1 1.2.1 1.3.0
Got "1.2.1" expected >= "1.3.0" (non-breaking changes)
⚠️
data_assets None 0.20.0 0.20.0 0.20.0 ✔️
hooks Non-Breaking 2.0.2 2.1.0-wip 2.1.0-wip ✔️
record_use Non-Breaking 0.6.0 1.0.0-wip 1.0.0-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

@dcharkes
dcharkes force-pushed the code-assets-close-link-mode branch from 1c27232 to fa60898 Compare July 9, 2026 09:20
@dcharkes
dcharkes requested a review from goderbauer July 9, 2026 09:42
@dcharkes
dcharkes marked this pull request as ready for review July 9, 2026 09:43
@dcharkes
dcharkes force-pushed the code-assets-close-link-mode branch from fa60898 to 0a837af Compare July 10, 2026 07:33

@goderbauer goderbauer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants