Skip to content

Commit ca42c81

Browse files
kevmoovkorencik
authored andcommitted
Support latest packages, bump min SDK to 3.6 (google#1465)
1 parent e2ae356 commit ca42c81

28 files changed

+106
-72
lines changed

.github/workflows/dart.yml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ jobs:
4040
- name: mono_repo self validate
4141
run: dart pub global run mono_repo generate --validate
4242
job_002:
43-
name: "analyzer_and_format; Dart 3.5.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`"
43+
name: "analyzer_and_format; Dart 3.6.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`"
4444
runs-on: ubuntu-latest
4545
steps:
4646
- name: Cache Pub hosted dependencies
4747
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
4848
with:
4949
path: "~/.pub-cache/hosted"
50-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1"
50+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1"
5151
restore-keys: |
52-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable
53-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
52+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable
53+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
5454
os:ubuntu-latest;pub-cache-hosted
5555
os:ubuntu-latest
5656
- name: Setup Dart SDK
5757
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
5858
with:
59-
sdk: "3.5.0"
59+
sdk: "3.6.0"
6060
- id: checkout
6161
name: Checkout repository
6262
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -192,23 +192,23 @@ jobs:
192192
if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'"
193193
working-directory: json_serializable
194194
job_004:
195-
name: "unit_test; Dart 3.5.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`"
195+
name: "unit_test; Dart 3.6.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`"
196196
runs-on: ubuntu-latest
197197
steps:
198198
- name: Cache Pub hosted dependencies
199199
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
200200
with:
201201
path: "~/.pub-cache/hosted"
202-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0"
202+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0"
203203
restore-keys: |
204-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_serializable
205-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
204+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_serializable
205+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
206206
os:ubuntu-latest;pub-cache-hosted
207207
os:ubuntu-latest
208208
- name: Setup Dart SDK
209209
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
210210
with:
211-
sdk: "3.5.0"
211+
sdk: "3.6.0"
212212
- id: checkout
213213
name: Checkout repository
214214
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -253,23 +253,23 @@ jobs:
253253
- job_002
254254
- job_003
255255
job_005:
256-
name: "unit_test; Dart 3.5.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`"
256+
name: "unit_test; Dart 3.6.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`"
257257
runs-on: ubuntu-latest
258258
steps:
259259
- name: Cache Pub hosted dependencies
260260
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
261261
with:
262262
path: "~/.pub-cache/hosted"
263-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_3"
263+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable;commands:test_3"
264264
restore-keys: |
265-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable
266-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
265+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable
266+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
267267
os:ubuntu-latest;pub-cache-hosted
268268
os:ubuntu-latest
269269
- name: Setup Dart SDK
270270
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
271271
with:
272-
sdk: "3.5.0"
272+
sdk: "3.6.0"
273273
- id: checkout
274274
name: Checkout repository
275275
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -287,23 +287,23 @@ jobs:
287287
- job_002
288288
- job_003
289289
job_006:
290-
name: "unit_test; Dart 3.5.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
290+
name: "unit_test; Dart 3.6.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
291291
runs-on: ubuntu-latest
292292
steps:
293293
- name: Cache Pub hosted dependencies
294294
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
295295
with:
296296
path: "~/.pub-cache/hosted"
297-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_1"
297+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable;commands:test_1"
298298
restore-keys: |
299-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable
300-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
299+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable
300+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
301301
os:ubuntu-latest;pub-cache-hosted
302302
os:ubuntu-latest
303303
- name: Setup Dart SDK
304304
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
305305
with:
306-
sdk: "3.5.0"
306+
sdk: "3.6.0"
307307
- id: checkout
308308
name: Checkout repository
309309
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -321,23 +321,23 @@ jobs:
321321
- job_002
322322
- job_003
323323
job_007:
324-
name: "unit_test; Dart 3.5.0; PKG: json_serializable; `dart test -p chrome`"
324+
name: "unit_test; Dart 3.6.0; PKG: json_serializable; `dart test -p chrome`"
325325
runs-on: ubuntu-latest
326326
steps:
327327
- name: Cache Pub hosted dependencies
328328
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
329329
with:
330330
path: "~/.pub-cache/hosted"
331-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_2"
331+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable;commands:test_2"
332332
restore-keys: |
333-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable
334-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
333+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable
334+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
335335
os:ubuntu-latest;pub-cache-hosted
336336
os:ubuntu-latest
337337
- name: Setup Dart SDK
338338
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
339339
with:
340-
sdk: "3.5.0"
340+
sdk: "3.6.0"
341341
- id: checkout
342342
name: Checkout repository
343343
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -518,23 +518,23 @@ jobs:
518518
- job_002
519519
- job_003
520520
job_012:
521-
name: "ensure_build; Dart 3.5.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
521+
name: "ensure_build; Dart 3.6.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
522522
runs-on: ubuntu-latest
523523
steps:
524524
- name: Cache Pub hosted dependencies
525525
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
526526
with:
527527
path: "~/.pub-cache/hosted"
528-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example;commands:test_1"
528+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example;commands:test_1"
529529
restore-keys: |
530-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example
531-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
530+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example
531+
os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0
532532
os:ubuntu-latest;pub-cache-hosted
533533
os:ubuntu-latest
534534
- name: Setup Dart SDK
535535
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
536536
with:
537-
sdk: "3.5.0"
537+
sdk: "3.6.0"
538538
- id: checkout
539539
name: Checkout repository
540540
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

checked_yaml/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 2.0.4-wip
22

3-
- Require Dart 3.5
3+
- Require Dart 3.6
44

55
## 2.0.3
66

json_annotation/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 4.9.1-wip
22

3-
- Require Dart 3.5
3+
- Require Dart 3.6
44

55
## 4.9.0
66

json_serializable/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 6.9.1
2+
3+
- Support the latest `package:analyzer` and `package:source_gen`.
4+
- Require Dart 3.6
5+
16
## 6.9.0
27

38
- Use conditional map syntax to clean up `null` handling in `toJson` functions.

json_serializable/lib/builder.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ Builder jsonSerializable(BuilderOptions options) {
3939
lines.add(e.innerError.toString());
4040
}
4141

42-
throw StateError(
43-
lines
44-
.join('\n')
45-
// TODO(kevmoo) remove when dart-lang/sdk#50756 is fixed!
46-
.replaceAll(" of ' in type cast'", ' in type cast'),
47-
);
42+
throw StateError(lines.join('\n'));
4843
}
4944
}

json_serializable/lib/src/field_helpers.dart

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// TODO: Waiting until Dart 3.6 so we can pin a stable Dart SDK compatible w/ latest
6-
// analyzer
7-
// ignore_for_file: deprecated_member_use
8-
95
import 'package:analyzer/dart/element/element.dart';
106
import 'package:analyzer/src/dart/element/inheritance_manager3.dart' // ignore: implementation_imports
117
show
@@ -39,20 +35,21 @@ class _FieldSet implements Comparable<_FieldSet> {
3935

4036
static int _sortByLocation(FieldElement a, FieldElement b) {
4137
final checkerA = TypeChecker.fromStatic(
42-
(a.enclosingElement as InterfaceElement).thisType,
38+
(a.enclosingElement3 as InterfaceElement).thisType,
4339
);
4440

45-
if (!checkerA.isExactly(b.enclosingElement)) {
41+
if (!checkerA.isExactly(b.enclosingElement3)) {
4642
// in this case, you want to prioritize the enclosingElement that is more
4743
// "super".
4844

49-
if (checkerA.isAssignableFrom(b.enclosingElement)) {
45+
if (checkerA.isAssignableFrom(b.enclosingElement3)) {
5046
return -1;
5147
}
5248

53-
final checkerB = TypeChecker.fromStatic((b.enclosingElement as InterfaceElement).thisType);
49+
final checkerB = TypeChecker.fromStatic(
50+
(b.enclosingElement3 as InterfaceElement).thisType);
5451

55-
if (checkerB.isAssignableFrom(a.enclosingElement)) {
52+
if (checkerB.isAssignableFrom(a.enclosingElement3)) {
5653
return 1;
5754
}
5855
}
@@ -84,7 +81,7 @@ List<FieldElement> createSortedFieldSet(ClassElement element) {
8481

8582
for (final v in manager.getInheritedConcreteMap2(element).values) {
8683
assert(v is! FieldElement);
87-
if (_dartCoreObjectChecker.isExactly(v.enclosingElement)) {
84+
if (_dartCoreObjectChecker.isExactly(v.enclosingElement3)) {
8885
continue;
8986
}
9087

json_serializable/lib/src/json_part_builder.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:build/build.dart';
6+
import 'package:dart_style/dart_style.dart';
67
import 'package:json_annotation/json_annotation.dart';
8+
import 'package:pub_semver/pub_semver.dart';
79
import 'package:source_gen/source_gen.dart';
810

911
import 'check_dependencies.dart';
@@ -18,7 +20,7 @@ import 'settings.dart';
1820
/// [formatOutput] is called to format the generated code. If not provided,
1921
/// the default Dart code formatter is used.
2022
Builder jsonPartBuilder({
21-
String Function(String code)? formatOutput,
23+
String Function(String code, Version languageVersion)? formatOutput,
2224
JsonSerializable? config,
2325
}) {
2426
final settings = Settings(config: config);
@@ -32,7 +34,7 @@ Builder jsonPartBuilder({
3234
const JsonLiteralGenerator(),
3335
],
3436
'json_serializable',
35-
formatOutput: formatOutput,
37+
formatOutput: formatOutput ?? defaultFormatOutput,
3638
);
3739
}
3840

@@ -99,3 +101,6 @@ Iterable<String> _normalizeGeneratorOutput(Object? value) {
99101
ArgumentError _argError(Object value) => ArgumentError(
100102
'Must be a String or be an Iterable containing String values. '
101103
'Found `${Error.safeToString(value)}` (${value.runtimeType}).');
104+
105+
String defaultFormatOutput(String code, Version languageVersion) =>
106+
DartFormatter(languageVersion: languageVersion).format(code);

json_serializable/lib/src/type_helpers/json_converter_helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ _JsonConvertData? _typeConverterFrom(
215215
final annotationElement = match.elementAnnotation?.element;
216216
if (annotationElement is PropertyAccessorElement) {
217217
// ignore: deprecated_member_use
218-
final enclosing = annotationElement.enclosingElement;
218+
final enclosing = annotationElement.enclosingElement3;
219219

220220
var accessString = annotationElement.name;
221221

json_serializable/lib/src/utils.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// TODO: Waiting until Dart 3.6 so we can pin a stable Dart SDK compatible w/ latest
6-
// analyzer
7-
// ignore_for_file: deprecated_member_use
8-
95
import 'package:analyzer/dart/constant/value.dart';
106
import 'package:analyzer/dart/element/element.dart';
117
import 'package:analyzer/dart/element/type.dart';
@@ -251,15 +247,15 @@ extension ExecutableElementExtension on ExecutableElement {
251247
}
252248

253249
if (this is MethodElement) {
254-
return '${enclosingElement.name}.$name';
250+
return '${enclosingElement3.name}.$name';
255251
}
256252

257253
if (this is ConstructorElement) {
258254
// Ignore the default constructor.
259255
if (name.isEmpty) {
260-
return '${enclosingElement.name}';
256+
return '${enclosingElement3.name}';
261257
}
262-
return '${enclosingElement.name}.$name';
258+
return '${enclosingElement3.name}.$name';
263259
}
264260

265261
throw UnsupportedError(

json_serializable/pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: json_serializable
2-
version: 6.9.0
2+
version: 6.9.1
33
description: >-
44
Automatically generate code for converting to and from JSON by annotating
55
Dart classes.
@@ -15,11 +15,12 @@ topics:
1515
resolution: workspace
1616

1717
dependencies:
18-
analyzer: ^8.1.1
18+
analyzer: ">=6.5.0 <7.0.0"
1919
async: ^2.10.0
2020
build: ^3.0.0
2121
build_config: ^1.1.0
2222
collection: ^1.17.0
23+
dart_style: ">=2.3.7 <4.0.0"
2324

2425
# Use a tight version constraint to ensure that a constraint on
2526
# `json_annotation` properly constrains all features it provides.

0 commit comments

Comments
 (0)