Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 52c25cc

Browse files
authoredDec 17, 2024··
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(

‎json_serializable/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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.
66
repository: https://github.com/google/json_serializable.dart/tree/master/json_serializable
77
environment:
8-
sdk: ^3.5.0
8+
sdk: ^3.6.0
99
topics:
1010
- json
1111
- build-runner
@@ -15,11 +15,12 @@ topics:
1515
resolution: workspace
1616

1717
dependencies:
18-
analyzer: ^6.5.0
18+
analyzer: '>=6.5.0 <7.0.0'
1919
async: ^2.10.0
2020
build: ^2.4.1
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.
@@ -28,15 +29,14 @@ dependencies:
2829
path: ^1.9.0
2930
pub_semver: ^2.1.4
3031
pubspec_parse: ^1.0.0
31-
source_gen: ^1.4.0
32+
source_gen: ^2.0.0
3233
source_helper: ^1.3.4
3334

3435
dev_dependencies:
3536
_json_serial_shared_test:
3637
path: ../shared_test
3738
build_runner: ^2.4.6
3839
build_verify: ^3.0.0
39-
dart_style: ^2.3.2
4040
logging: ^1.0.0
4141
source_gen_test: ^1.0.6
4242
test: ^1.24.4

‎json_serializable/test/custom_configuration_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ void _registerTests(JsonSerializable generator) {
142142

143143
const expected = r'''
144144
Map<String, dynamic> _$TrivialNestedNullableToJson(
145-
TrivialNestedNullable instance) =>
146-
<String, dynamic>{
147-
'child': instance.child?.toJson(),
148-
'otherField': instance.otherField,
149-
};
145+
TrivialNestedNullable instance,
146+
) => <String, dynamic>{
147+
'child': instance.child?.toJson(),
148+
'otherField': instance.otherField,
149+
};
150150
''';
151151

152152
expect(output, expected);
@@ -157,11 +157,11 @@ Map<String, dynamic> _$TrivialNestedNullableToJson(
157157

158158
const expected = r'''
159159
Map<String, dynamic> _$TrivialNestedNonNullableToJson(
160-
TrivialNestedNonNullable instance) =>
161-
<String, dynamic>{
162-
'child': instance.child.toJson(),
163-
'otherField': instance.otherField,
164-
};
160+
TrivialNestedNonNullable instance,
161+
) => <String, dynamic>{
162+
'child': instance.child.toJson(),
163+
'otherField': instance.otherField,
164+
};
165165
''';
166166

167167
expect(output, expected);

‎json_serializable/test/src/_json_serializable_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
// @dart=3.6
6+
57
import 'dart:collection';
68

79
import 'package:json_annotation/json_annotation.dart';

‎json_serializable/test/src/checked_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @dart=3.6
2+
13
part of '_json_serializable_test_input.dart';
24

35
@ShouldGenerate(r'''

‎json_serializable/test/src/constants_copy.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
// @dart=3.6
6+
57
part of '_json_serializable_test_input.dart';
68

79
// TODO: remove this and return link to lib/src/constants.dart once this

‎json_serializable/test/src/core_subclass_type_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @dart=3.6
2+
13
part of '_json_serializable_test_input.dart';
24

35
@ShouldThrow(

‎json_serializable/test/src/default_value_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
// @dart=3.6
6+
57
part of '_json_serializable_test_input.dart';
68

79
@ShouldThrow(

‎json_serializable/test/src/field_namer_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @dart=3.6
2+
13
part of '_json_serializable_test_input.dart';
24

35
@ShouldGenerate(r'''

‎json_serializable/test/src/generic_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
// @dart=3.6
6+
57
part of '_json_serializable_test_input.dart';
68

79
@ShouldThrow(

‎json_serializable/test/src/inheritance_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @dart=3.6
2+
13
part of '_json_serializable_test_input.dart';
24

35
@ShouldGenerate(r'''

‎json_serializable/test/src/json_converter_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
// @dart=3.6
6+
57
// ignore_for_file: inference_failure_on_instance_creation
68

79
part of '_json_serializable_test_input.dart';

‎json_serializable/test/src/map_key_variety_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @dart=3.6
2+
13
part of '_json_serializable_test_input.dart';
24

35
@ShouldGenerate(r'''

‎json_serializable/test/src/setter_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @dart=3.6
2+
13
part of '_json_serializable_test_input.dart';
24

35
@ShouldGenerate(

‎json_serializable/test/src/to_from_json_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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+
// @dart=3.6
6+
57
part of '_json_serializable_test_input.dart';
68

79
int _toInt(bool input) => 42;

‎json_serializable/test/src/unknown_enum_value_test_input.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @dart=3.6
2+
13
part of '_json_serializable_test_input.dart';
24

35
@ShouldGenerate(

‎json_serializable/tool/field_matrix_builder.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Builder builder([_]) => _FieldMatrixBuilder();
1515
class _FieldMatrixBuilder extends Builder {
1616
@override
1717
FutureOr<void> build(BuildStep buildStep) async {
18+
final formatter = await buildStep.formatter();
19+
1820
final inputBaseName = p.basenameWithoutExtension(buildStep.inputId.path);
1921

2022
final output = buildStep.allowedOutputs.single;

‎json_serializable/tool/shared.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import 'package:build/build.dart';
88
import 'package:dart_style/dart_style.dart';
99
import 'package:yaml/yaml.dart';
1010

11-
final formatter = DartFormatter();
12-
1311
// Until we have verification in pkg:build and friends
1412
// https://github.com/dart-lang/build/issues/590
1513
Builder validate(String builderName, Builder builder) {
@@ -72,3 +70,8 @@ class Replacement {
7270
return outputContent.replaceAll(',)', ',\n)');
7371
}
7472
}
73+
74+
extension BuildStepExtension on BuildStep {
75+
Future<DartFormatter> formatter() async => DartFormatter(
76+
languageVersion: (await inputLibrary).languageVersion.effective);
77+
}

‎json_serializable/tool/test_builder.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class _TestBuilder implements Builder {
1717

1818
@override
1919
FutureOr<void> build(BuildStep buildStep) async {
20+
final formatter = await buildStep.formatter();
21+
2022
final baseName = p.basenameWithoutExtension(buildStep.inputId.path);
2123

2224
final sourceContent = await buildStep.readAsString(buildStep.inputId);

‎json_serializable/tool/test_type_builder.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class _TypeBuilder implements Builder {
125125

126126
@override
127127
FutureOr<void> build(BuildStep buildStep) async {
128+
final formatter = await buildStep.formatter();
129+
128130
final inputId = buildStep.inputId;
129131

130132
final sourceContent = await buildStep.readAsString(inputId);

‎shared_test/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: _json_serial_shared_test
22
publish_to: none
33
environment:
4-
sdk: ^3.5.0
4+
sdk: ^3.6.0
55

66
resolution: workspace
77

0 commit comments

Comments
 (0)
Please sign in to comment.