Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use source_gen #163

Open
ncuillery opened this issue Sep 22, 2023 · 2 comments
Open

Use source_gen #163

ncuillery opened this issue Sep 22, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@ncuillery
Copy link

In the Dart package ecosystem, most of the packages are using source_gen which formats the output code. This process has 2 main benefits:

  • The generator can just produce valid code and not care about indentation, carriage returns, etc. since the output is formatted at the end anyway
  • The developer can run dart format . and there is no change in the generated code since it has already been formatted that way.

I have started using slang and everytime I run dart run slang, I have to run dart format . and commit the changes otherwise my CI build is broken.

There is no way to exclude file in Dart formatter (yet) dart-lang/dart_style#864 so having generated code properly formatted like code gen packages do would be great.

To repro:

  • Clone the slang repo
  • Run cd slang/example
  • Run flutter pub get
  • Run dart format .
  • Run git diff 👉 There are some changes that shouldn't be here.
@ncuillery ncuillery added the bug Something isn't working label Sep 22, 2023
@Tienisto
Copy link
Member

A temporary workaround is to remove the generated file inside the CI before running dart format .. This essentially ignores the file as it doesn't exist anymore.

Integrating source_gen requires a lot of effort so it is unlikely in the near future.

@Tienisto Tienisto added enhancement New feature or request and removed bug Something isn't working labels Sep 27, 2023
@Tienisto Tienisto changed the title Generated code is not properly formatted Use source_gen Sep 27, 2023
@ngoc-quoc-huynh
Copy link

Having the same problem. Would wish this feature to be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants