Skip to content

Commit 52c25cc

Browse files
authored
Support latest packages, bump min SDK to 3.6 (#1465)
1 parent d3cee99 commit 52c25cc

33 files changed

+112
-80
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

_test_yaml/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: _test_yaml
22
publish_to: none
33

44
environment:
5-
sdk: ^3.5.0
5+
sdk: ^3.6.0
66

77
resolution: workspace
88

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

checked_yaml/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ topics:
1313
- codegen
1414

1515
environment:
16-
sdk: ^3.5.0
16+
sdk: ^3.6.0
1717

1818
resolution: workspace
1919

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: example
22
publish_to: none
33

44
environment:
5-
sdk: ^3.5.0
5+
sdk: ^3.6.0
66

77
resolution: workspace
88

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_annotation/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ topics:
1111
- codegen
1212

1313
environment:
14-
sdk: ^3.5.0
14+
sdk: ^3.6.0
1515

1616
resolution: workspace
1717

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: 6 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
@@ -41,21 +37,21 @@ class _FieldSet implements Comparable<_FieldSet> {
4137

4238
static int _sortByLocation(FieldElement a, FieldElement b) {
4339
final checkerA = TypeChecker.fromStatic(
44-
(a.enclosingElement as InterfaceElement).thisType,
40+
(a.enclosingElement3 as InterfaceElement).thisType,
4541
);
4642

47-
if (!checkerA.isExactly(b.enclosingElement)) {
43+
if (!checkerA.isExactly(b.enclosingElement3)) {
4844
// in this case, you want to prioritize the enclosingElement that is more
4945
// "super".
5046

51-
if (checkerA.isAssignableFrom(b.enclosingElement)) {
47+
if (checkerA.isAssignableFrom(b.enclosingElement3)) {
5248
return -1;
5349
}
5450

5551
final checkerB = TypeChecker.fromStatic(
56-
(b.enclosingElement as InterfaceElement).thisType);
52+
(b.enclosingElement3 as InterfaceElement).thisType);
5753

58-
if (checkerB.isAssignableFrom(a.enclosingElement)) {
54+
if (checkerB.isAssignableFrom(a.enclosingElement3)) {
5955
return 1;
6056
}
6157
}
@@ -87,7 +83,7 @@ List<FieldElement> createSortedFieldSet(ClassElement element) {
8783

8884
for (final v in manager.getInheritedConcreteMap2(element).values) {
8985
assert(v is! FieldElement);
90-
if (_dartCoreObjectChecker.isExactly(v.enclosingElement)) {
86+
if (_dartCoreObjectChecker.isExactly(v.enclosingElement3)) {
9187
continue;
9288
}
9389

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';
@@ -267,15 +263,15 @@ extension ExecutableElementExtension on ExecutableElement {
267263
}
268264

269265
if (this is MethodElement) {
270-
return '${enclosingElement.name}.$name';
266+
return '${enclosingElement3.name}.$name';
271267
}
272268

273269
if (this is ConstructorElement) {
274270
// Ignore the default constructor.
275271
if (name.isEmpty) {
276-
return '${enclosingElement.name}';
272+
return '${enclosingElement3.name}';
277273
}
278-
return '${enclosingElement.name}.$name';
274+
return '${enclosingElement3.name}.$name';
279275
}
280276

281277
throw UnsupportedError(

0 commit comments

Comments
 (0)