Skip to content

[pigeon] make swift enum CaseIterable#11702

Open
HannesGitH wants to merge 6 commits into
flutter:mainfrom
HannesGitH:186447-pigeon-swift-enum-caseiterable
Open

[pigeon] make swift enum CaseIterable#11702
HannesGitH wants to merge 6 commits into
flutter:mainfrom
HannesGitH:186447-pigeon-swift-enum-caseiterable

Conversation

@HannesGitH
Copy link
Copy Markdown

@HannesGitH HannesGitH commented May 13, 2026

instead of generating

enum FooEnum: Int {
  case foo = 0
  ...

we will now generate

enum FooEnum: Int, CaseIterable {
  case foo = 0
  ...

allowing consumers to use FooEnum.allCases to iterate over all possible enum values in swift platform code

fixes flutter/flutter#186447

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@flutter-dashboard
Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates Pigeon to version 26.3.5 and adds CaseIterable conformance to generated Swift enums. Feedback indicates that the change lacks necessary tests or golden file updates to verify the generated code, as required by the style guide.

);

indent.write('enum ${anEnum.name}: Int ');
indent.write('enum ${anEnum.name}: Int, CaseIterable ');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The addition of CaseIterable to generated Swift enums is a useful improvement. However, I noticed that no new tests or updates to existing golden files were included in this pull request to verify this change. Please ensure that the generated output is covered by tests to prevent regressions and verify the correct syntax is produced.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

it is now included in test

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.

probably good to add a native unit test, probably in the enum file, that tests the actual functionality of CaseIterable as well. Maybe add something in the swift_generator_test.dart file as well.

@tarrinneal
Copy link
Copy Markdown
Contributor

please run the formatting tool (should run automatically after the generate tool) and re-upload so I can see the actual changes.

@HannesGitH HannesGitH force-pushed the 186447-pigeon-swift-enum-caseiterable branch from 6a9cd77 to 4bd17b4 Compare May 19, 2026 22:21
@HannesGitH HannesGitH force-pushed the 186447-pigeon-swift-enum-caseiterable branch from 4bd17b4 to 88e87c9 Compare May 19, 2026 22:26
@HannesGitH
Copy link
Copy Markdown
Author

HannesGitH commented May 19, 2026

@tarrinneal

➜  pigeon git:(186447-pigeon-swift-enum-caseiterable) ✗ dart run tool/generate.dart
Generating platform_test/ output...
Generation complete!
Generating example/ output...
Generation complete!
Formatting generated output...

and we have still a bunch of formatting changes in swift and header files, should I run something else?

Dart SDK version: 3.11.4 (stable) (Tue Mar 24 01:02:20 2026 -0700) on "macos_arm64"

@tarrinneal
Copy link
Copy Markdown
Contributor

tarrinneal commented May 20, 2026

@tarrinneal

and we have still a bunch of formatting changes in swift and header files, should I run something else?

I've pulled down, regenerated, and formatted the code for this PR. You can merge those changes from this branch

@HannesGitH HannesGitH force-pushed the 186447-pigeon-swift-enum-caseiterable branch from 88e87c9 to 42d3775 Compare May 20, 2026 10:44
@HannesGitH HannesGitH force-pushed the 186447-pigeon-swift-enum-caseiterable branch 3 times, most recently from 6c92f58 to 9f70958 Compare May 20, 2026 11:10
@HannesGitH
Copy link
Copy Markdown
Author

I would have preferred to know what I did wrong, but you format commit is now included :)

Thank you :)

@tarrinneal
Copy link
Copy Markdown
Contributor

I would have preferred to know what I did wrong, but you format commit is now included :)

Thank you :)

That's fair :) It's hard to know without access to your environment. I would guess you are either missing tools (swift-format, clang), or the configurations for those tools are overriding our own somehow.

@tarrinneal tarrinneal added the CICD Run CI/CD label May 20, 2026
@flutter-dashboard
Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

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.

[pigeon][swift] make generated enums CaseIterable

2 participants