riverpod icon indicating copy to clipboard operation
riverpod copied to clipboard

riverpod_generator always runs even though we added runs_before (after version 2.3.3)

Open chaturadilan opened this issue 1 year ago • 2 comments

I have created a package that automatically generates providers based on the repository. It works if the riverpod_generator: 2.3.3 and below in pubspec.yaml. it does not work for riverpod_generator: 2.3.5 and above

Seems

global_options:
  riverpod_repo:
    runs_before:
      - riverpod_generator

does not work after version 2.3.3

To Reproduce

  1. Checkout https://github.com/chaturadilan/riverpod_repo_generator
  2. Change riverpod_generator version to 2.3.5 or higher in https://github.com/chaturadilan/riverpod_repo_generator/blob/main/pubspec.yaml
  3. Generate the code using fvm flutter pub run build_runner build --delete-conflicting-outputs

Expected behavior It should generate the providers like with riverpod_generator: 2.3.3 in pubspec.yaml in example.g.dart

chaturadilan avatar Dec 24 '23 12:12 chaturadilan

That's most likely a source_gen/build issue.

rrousselGit avatar Dec 24 '23 16:12 rrousselGit

It's low priority for me. I won't spend much time investigating this.

So if it matters for you, feel free to look into it yourself and raise a PR if you found a solution.

rrousselGit avatar Dec 24 '23 16:12 rrousselGit

I have no plan to work on this, especially with metaprogramming around the corner.

So closing :)

rrousselGit avatar Mar 01 '24 11:03 rrousselGit

Hi Remi,

When I investigated the issue, I found out it was occurring because of.

https://github.com/rrousselGit/riverpod/commit/06aeaf0b71ca1fe59facf9258e6a33d31c91ae4e#diff-394be403b9b3b307ca0400be48de286400f6abb846b3834065d6ea31c844991e

Any idea why the following code was added? It prevents my .repo.g.dart from executing before .g.dart.

const generatedExtensions = {'.freezed.dart', '.g.dart'};
        final shortName = unit.declaredElement?.source.shortName ?? '';
        if (generatedExtensions.any(shortName.endsWith)) {
          continue;
        }

chaturadilan avatar Mar 13 '24 10:03 chaturadilan

There's no order change with this. It just excludes generated files.

rrousselGit avatar Mar 13 '24 11:03 rrousselGit