Skip to content

eng(build): upgrade analyzer, build and source_gen dependencies#650

Merged
tshedor merged 23 commits intoGetDutchie:mainfrom
JaseElder:main
Nov 1, 2025
Merged

eng(build): upgrade analyzer, build and source_gen dependencies#650
tshedor merged 23 commits intoGetDutchie:mainfrom
JaseElder:main

Conversation

@JaseElder
Copy link
Contributor

Hi,

This PR should address the issues with out of date dependencies for analyzer, source_gen and build.
There were a few breaking changes since the last compatible analyzer version, so there were quite a few API deprecations and deletions.

Almost all tests are passing, but for the tests that deal with nullability type mismatches in Constructors, e.g.
in packages/brick_offline_first_build/test/offline_first_generator_test.dart the test CustomOfflineFirstSerdes
These are failing - I couldn't track down where the type needed to be modified.
But that affects ~3 tests, and I'd imagine you'll be able to track it down instantly.

@bookshiyi
Copy link

great!

required SupabaseProvider provider,
OfflineFirstWithSupabaseRepository? repository,
}) async {
return Customer();
Copy link
Collaborator

Choose a reason for hiding this comment

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

data should still populate the Customer instance fields

required SqliteProvider provider,
OfflineFirstWithSupabaseRepository? repository,
}) async {
return Customer()..primaryKey = data['_brick_id'] as int;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

required SupabaseProvider provider,
OfflineFirstWithSupabaseRepository? repository,
}) async {
return Pizza();
Copy link
Collaborator

Choose a reason for hiding this comment

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

@JaseElder did you generate these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tshedor I didn't knowingly regenerate them. I tried to stay away from the example folders. They may have been generated during rework - I'll try to explicitly gen.

required SqliteProvider provider,
OfflineFirstWithSupabaseRepository? repository,
}) async {
return Pizza()..primaryKey = data['_brick_id'] as int;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here too

if (!checkerA.isExactly(b.enclosingElement)) {
// in this case, you want to prioritize the enclosingElement that is more "super".
if (checkerA.isAssignableFrom(b.enclosingElement3)) {
if (checkerA.isAssignableFrom(b.enclosingElement)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Non-actionable feedback here. The analyzer team is so inconsistent. When I first wrote this code there were no numbers. Now they're going back to numbers. But it's all the same property and same value. I wish they would stop publishing these breaking changes. Thank you again for taking the effort to update these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also it's really hard to find documentation on migration and deprecation for analyzer. And quite a few of the methods/properties were deprecated in intermediate analyzer versions, and then completely removed in the latest, so working out what the replacement path is was frustrating.


dependencies:
analyzer: ">=6.11.0 <8.0.0"
analyzer: ">=6.11.0 <9.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this minimum version still valid?

Suggested change
analyzer: ">=6.11.0 <9.0.0"
analyzer: ">=8.0.0 <9.0.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upgraded minimum

analyzer: ">=6.11.0 <9.0.0"
brick_core: ">=2.0.0 <3.0.0"
build: ">=2.4.2 <2.5.0"
build: ">=2.4.2 <5.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly. It's OK to keep this restricted

Suggested change
build: ">=2.4.2 <5.0.0"
build: ">=4.0.0 <5.0.0"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upgraded minimum

repository: https://github.com/GetDutchie/brick

version: 3.0.0
version: 3.0.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
version: 3.0.1
version: 3.1.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upgraded minimum


dependencies:
analyzer: ">=6.11.0 <8.0.0"
analyzer: ">=6.11.0 <9.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I won't go through every pubspec, but they can all be updated to one major version less than the highest band

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upgraded minimums

}

/// Extract filename from library identifier path
static String _extractFilename(String libraryPath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels...off. But I also know that source gen doesn't really want you to know the path of the file you're generating. This is the best solution given the new properties available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this was messy - I've made it more aligned with the new properties now, I think.

… dependencies

- reverted generated file changes in example_supabase
- simplified allMigrationsByFilePath() file path fetching
# Conflicts:
#	packages/brick_json_generators/pubspec.yaml
#	packages/brick_offline_first_build/pubspec.yaml
#	packages/brick_offline_first_with_supabase_build/pubspec.yaml
#	packages/brick_rest_generators/pubspec.yaml
#	packages/brick_sqlite_generators/pubspec.yaml
#	packages/brick_supabase_generators/pubspec.yaml
… dependencies

- reverted generated file changes in example_supabase
- simplified allMigrationsByFilePath() file path fetching
@JaseElder
Copy link
Contributor Author

@tshedor

Those are the tests I was talking about above.
They are all related to a mismatch where the constructor has a nullable field, but the corresponding instance variable isn't nullable, as in the test example:

@SupabaseSerializable()
class SupabaseConstructorMemberFieldMismatch extends SupabaseModel {
  final String nullableConstructor;
  final String nonNullableConstructor;

  final List<Assoc> someField;

  SupabaseConstructorMemberFieldMismatch({
    String? nullableConstructor,
    required this.nonNullableConstructor,
    List<Assoc>? someField,
  })  : nullableConstructor = nullableConstructor ?? 'default',
        someField = someField ?? <Assoc>[];
} 

In this case, nullableConstructor is the culprit.

If you could point me in the direction of where to look to modify the generator to make the test past, I could amend the code. Otherwise, it might be faster for you to have a look.

final defaultConstructor = _firstWhereOrNull<ConstructorElement>(
element.constructors,
(e) => !e.isFactory && e.name.isEmpty,
(e) => !e.isFactory && ((e.name?.isEmpty ?? true) || e.name == 'new'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

@JaseElder this was the missing logic that was breaking tests. The default (unnamed) constructor is no longer unnamed in the analyzer, it's now 'new'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tshedor Nice one!
Thanks for the help and the repo update

@tshedor tshedor changed the title Upgraded analyzer, build and source_gen dependencies eng(build): upgrade analyzer, build and source_gen dependencies Nov 1, 2025
tshedor
tshedor previously approved these changes Nov 1, 2025
@tshedor tshedor merged commit 4395194 into GetDutchie:main Nov 1, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants