diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index eddf9ec4..ac10f084 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -40,23 +40,23 @@ jobs: - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyzer_and_format; Dart 3.5.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`" + name: "analyzer_and_format; Dart 3.6.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: - sdk: "3.5.0" + sdk: "3.6.0" - id: checkout name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -192,23 +192,23 @@ jobs: if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" working-directory: json_serializable job_004: - name: "unit_test; Dart 3.5.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" + name: "unit_test; Dart 3.6.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: - sdk: "3.5.0" + sdk: "3.6.0" - id: checkout name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -253,23 +253,23 @@ jobs: - job_002 - job_003 job_005: - name: "unit_test; Dart 3.5.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" + name: "unit_test; Dart 3.6.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_3" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable;commands:test_3" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: - sdk: "3.5.0" + sdk: "3.6.0" - id: checkout name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -287,23 +287,23 @@ jobs: - job_002 - job_003 job_006: - name: "unit_test; Dart 3.5.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "unit_test; Dart 3.6.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: - sdk: "3.5.0" + sdk: "3.6.0" - id: checkout name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -321,23 +321,23 @@ jobs: - job_002 - job_003 job_007: - name: "unit_test; Dart 3.5.0; PKG: json_serializable; `dart test -p chrome`" + name: "unit_test; Dart 3.6.0; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable;commands:test_2" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: - sdk: "3.5.0" + sdk: "3.6.0" - id: checkout name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -518,23 +518,23 @@ jobs: - job_002 - job_003 job_012: - 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`" + 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`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0;packages:_test_yaml-checked_yaml-example + os:ubuntu-latest;pub-cache-hosted;sdk:3.6.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: - sdk: "3.5.0" + sdk: "3.6.0" - id: checkout name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index f5450368..5fa5ac1a 100644 --- a/_test_yaml/pubspec.yaml +++ b/_test_yaml/pubspec.yaml @@ -2,7 +2,7 @@ name: _test_yaml publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.6.0 resolution: workspace diff --git a/checked_yaml/CHANGELOG.md b/checked_yaml/CHANGELOG.md index 292ecc01..6099e85b 100644 --- a/checked_yaml/CHANGELOG.md +++ b/checked_yaml/CHANGELOG.md @@ -1,6 +1,6 @@ ## 2.0.4-wip -- Require Dart 3.5 +- Require Dart 3.6 ## 2.0.3 diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index bb765cb1..7e7fbc9d 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -13,7 +13,7 @@ topics: - codegen environment: - sdk: ^3.5.0 + sdk: ^3.6.0 resolution: workspace diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0875abdd..3926249e 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,7 +2,7 @@ name: example publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.6.0 resolution: workspace diff --git a/json_annotation/CHANGELOG.md b/json_annotation/CHANGELOG.md index 0c341a22..810c9d3d 100644 --- a/json_annotation/CHANGELOG.md +++ b/json_annotation/CHANGELOG.md @@ -1,6 +1,6 @@ ## 4.9.1-wip -- Require Dart 3.5 +- Require Dart 3.6 ## 4.9.0 diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index cf334679..4c3da5f3 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -11,7 +11,7 @@ topics: - codegen environment: - sdk: ^3.5.0 + sdk: ^3.6.0 resolution: workspace diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index cd0ff76f..8ebbd107 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,3 +1,8 @@ +## 6.9.1 + +- Support the latest `package:analyzer` and `package:source_gen`. +- Require Dart 3.6 + ## 6.9.0 - Use conditional map syntax to clean up `null` handling in `toJson` functions. diff --git a/json_serializable/lib/builder.dart b/json_serializable/lib/builder.dart index 833efcec..b68eb758 100644 --- a/json_serializable/lib/builder.dart +++ b/json_serializable/lib/builder.dart @@ -39,11 +39,6 @@ Builder jsonSerializable(BuilderOptions options) { lines.add(e.innerError.toString()); } - throw StateError( - lines - .join('\n') - // TODO(kevmoo) remove when dart-lang/sdk#50756 is fixed! - .replaceAll(" of ' in type cast'", ' in type cast'), - ); + throw StateError(lines.join('\n')); } } diff --git a/json_serializable/lib/src/field_helpers.dart b/json_serializable/lib/src/field_helpers.dart index b315a140..c14d0d4b 100644 --- a/json_serializable/lib/src/field_helpers.dart +++ b/json_serializable/lib/src/field_helpers.dart @@ -2,10 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// TODO: Waiting until Dart 3.6 so we can pin a stable Dart SDK compatible w/ latest -// analyzer -// ignore_for_file: deprecated_member_use - import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/src/dart/element/inheritance_manager3.dart' // ignore: implementation_imports show @@ -41,21 +37,21 @@ class _FieldSet implements Comparable<_FieldSet> { static int _sortByLocation(FieldElement a, FieldElement b) { final checkerA = TypeChecker.fromStatic( - (a.enclosingElement as InterfaceElement).thisType, + (a.enclosingElement3 as InterfaceElement).thisType, ); - if (!checkerA.isExactly(b.enclosingElement)) { + if (!checkerA.isExactly(b.enclosingElement3)) { // in this case, you want to prioritize the enclosingElement that is more // "super". - if (checkerA.isAssignableFrom(b.enclosingElement)) { + if (checkerA.isAssignableFrom(b.enclosingElement3)) { return -1; } final checkerB = TypeChecker.fromStatic( - (b.enclosingElement as InterfaceElement).thisType); + (b.enclosingElement3 as InterfaceElement).thisType); - if (checkerB.isAssignableFrom(a.enclosingElement)) { + if (checkerB.isAssignableFrom(a.enclosingElement3)) { return 1; } } @@ -87,7 +83,7 @@ List createSortedFieldSet(ClassElement element) { for (final v in manager.getInheritedConcreteMap2(element).values) { assert(v is! FieldElement); - if (_dartCoreObjectChecker.isExactly(v.enclosingElement)) { + if (_dartCoreObjectChecker.isExactly(v.enclosingElement3)) { continue; } diff --git a/json_serializable/lib/src/json_part_builder.dart b/json_serializable/lib/src/json_part_builder.dart index 17e2c7fb..a5013f8d 100644 --- a/json_serializable/lib/src/json_part_builder.dart +++ b/json_serializable/lib/src/json_part_builder.dart @@ -3,7 +3,9 @@ // BSD-style license that can be found in the LICENSE file. import 'package:build/build.dart'; +import 'package:dart_style/dart_style.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:pub_semver/pub_semver.dart'; import 'package:source_gen/source_gen.dart'; import 'check_dependencies.dart'; @@ -18,7 +20,7 @@ import 'settings.dart'; /// [formatOutput] is called to format the generated code. If not provided, /// the default Dart code formatter is used. Builder jsonPartBuilder({ - String Function(String code)? formatOutput, + String Function(String code, Version languageVersion)? formatOutput, JsonSerializable? config, }) { final settings = Settings(config: config); @@ -32,7 +34,7 @@ Builder jsonPartBuilder({ const JsonLiteralGenerator(), ], 'json_serializable', - formatOutput: formatOutput, + formatOutput: formatOutput ?? defaultFormatOutput, ); } @@ -99,3 +101,6 @@ Iterable _normalizeGeneratorOutput(Object? value) { ArgumentError _argError(Object value) => ArgumentError( 'Must be a String or be an Iterable containing String values. ' 'Found `${Error.safeToString(value)}` (${value.runtimeType}).'); + +String defaultFormatOutput(String code, Version languageVersion) => + DartFormatter(languageVersion: languageVersion).format(code); diff --git a/json_serializable/lib/src/type_helpers/json_converter_helper.dart b/json_serializable/lib/src/type_helpers/json_converter_helper.dart index 4f119270..2722b4bc 100644 --- a/json_serializable/lib/src/type_helpers/json_converter_helper.dart +++ b/json_serializable/lib/src/type_helpers/json_converter_helper.dart @@ -215,7 +215,7 @@ _JsonConvertData? _typeConverterFrom( final annotationElement = match.elementAnnotation?.element; if (annotationElement is PropertyAccessorElement) { // ignore: deprecated_member_use - final enclosing = annotationElement.enclosingElement; + final enclosing = annotationElement.enclosingElement3; var accessString = annotationElement.name; diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index 84ef4695..d2f5f334 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -2,10 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// TODO: Waiting until Dart 3.6 so we can pin a stable Dart SDK compatible w/ latest -// analyzer -// ignore_for_file: deprecated_member_use - import 'package:analyzer/dart/constant/value.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; @@ -267,15 +263,15 @@ extension ExecutableElementExtension on ExecutableElement { } if (this is MethodElement) { - return '${enclosingElement.name}.$name'; + return '${enclosingElement3.name}.$name'; } if (this is ConstructorElement) { // Ignore the default constructor. if (name.isEmpty) { - return '${enclosingElement.name}'; + return '${enclosingElement3.name}'; } - return '${enclosingElement.name}.$name'; + return '${enclosingElement3.name}.$name'; } throw UnsupportedError( diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 3a31df77..9df24fd0 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -1,11 +1,11 @@ name: json_serializable -version: 6.9.0 +version: 6.9.1 description: >- Automatically generate code for converting to and from JSON by annotating Dart classes. repository: https://github.com/google/json_serializable.dart/tree/master/json_serializable environment: - sdk: ^3.5.0 + sdk: ^3.6.0 topics: - json - build-runner @@ -15,11 +15,12 @@ topics: resolution: workspace dependencies: - analyzer: ^6.5.0 + analyzer: '>=6.5.0 <7.0.0' async: ^2.10.0 build: ^2.4.1 build_config: ^1.1.0 collection: ^1.17.0 + dart_style: '>=2.3.7 <4.0.0' # Use a tight version constraint to ensure that a constraint on # `json_annotation` properly constrains all features it provides. @@ -28,7 +29,7 @@ dependencies: path: ^1.9.0 pub_semver: ^2.1.4 pubspec_parse: ^1.0.0 - source_gen: ^1.4.0 + source_gen: ^2.0.0 source_helper: ^1.3.4 dev_dependencies: @@ -36,7 +37,6 @@ dev_dependencies: path: ../shared_test build_runner: ^2.4.6 build_verify: ^3.0.0 - dart_style: ^2.3.2 logging: ^1.0.0 source_gen_test: ^1.0.6 test: ^1.24.4 diff --git a/json_serializable/test/custom_configuration_test.dart b/json_serializable/test/custom_configuration_test.dart index 4ac5d02c..1c96f092 100644 --- a/json_serializable/test/custom_configuration_test.dart +++ b/json_serializable/test/custom_configuration_test.dart @@ -142,11 +142,11 @@ void _registerTests(JsonSerializable generator) { const expected = r''' Map _$TrivialNestedNullableToJson( - TrivialNestedNullable instance) => - { - 'child': instance.child?.toJson(), - 'otherField': instance.otherField, - }; + TrivialNestedNullable instance, +) => { + 'child': instance.child?.toJson(), + 'otherField': instance.otherField, +}; '''; expect(output, expected); @@ -157,11 +157,11 @@ Map _$TrivialNestedNullableToJson( const expected = r''' Map _$TrivialNestedNonNullableToJson( - TrivialNestedNonNullable instance) => - { - 'child': instance.child.toJson(), - 'otherField': instance.otherField, - }; + TrivialNestedNonNullable instance, +) => { + 'child': instance.child.toJson(), + 'otherField': instance.otherField, +}; '''; expect(output, expected); diff --git a/json_serializable/test/src/_json_serializable_test_input.dart b/json_serializable/test/src/_json_serializable_test_input.dart index f8537f34..0f792b49 100644 --- a/json_serializable/test/src/_json_serializable_test_input.dart +++ b/json_serializable/test/src/_json_serializable_test_input.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.6 + import 'dart:collection'; import 'package:json_annotation/json_annotation.dart'; diff --git a/json_serializable/test/src/checked_test_input.dart b/json_serializable/test/src/checked_test_input.dart index bfbc6245..167b7039 100644 --- a/json_serializable/test/src/checked_test_input.dart +++ b/json_serializable/test/src/checked_test_input.dart @@ -1,3 +1,5 @@ +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldGenerate(r''' diff --git a/json_serializable/test/src/constants_copy.dart b/json_serializable/test/src/constants_copy.dart index a4b0f108..fa1c485b 100644 --- a/json_serializable/test/src/constants_copy.dart +++ b/json_serializable/test/src/constants_copy.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.6 + part of '_json_serializable_test_input.dart'; // TODO: remove this and return link to lib/src/constants.dart once this diff --git a/json_serializable/test/src/core_subclass_type_input.dart b/json_serializable/test/src/core_subclass_type_input.dart index 4165a452..b764b9fe 100644 --- a/json_serializable/test/src/core_subclass_type_input.dart +++ b/json_serializable/test/src/core_subclass_type_input.dart @@ -1,3 +1,5 @@ +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldThrow( diff --git a/json_serializable/test/src/default_value_input.dart b/json_serializable/test/src/default_value_input.dart index 7bdd1a35..6636f085 100644 --- a/json_serializable/test/src/default_value_input.dart +++ b/json_serializable/test/src/default_value_input.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldThrow( diff --git a/json_serializable/test/src/field_namer_input.dart b/json_serializable/test/src/field_namer_input.dart index 98cbadd8..ac9e1363 100644 --- a/json_serializable/test/src/field_namer_input.dart +++ b/json_serializable/test/src/field_namer_input.dart @@ -1,3 +1,5 @@ +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldGenerate(r''' diff --git a/json_serializable/test/src/generic_test_input.dart b/json_serializable/test/src/generic_test_input.dart index 8baaa433..f7b4ec45 100644 --- a/json_serializable/test/src/generic_test_input.dart +++ b/json_serializable/test/src/generic_test_input.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldThrow( diff --git a/json_serializable/test/src/inheritance_test_input.dart b/json_serializable/test/src/inheritance_test_input.dart index 921e442e..86c43c42 100644 --- a/json_serializable/test/src/inheritance_test_input.dart +++ b/json_serializable/test/src/inheritance_test_input.dart @@ -1,3 +1,5 @@ +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldGenerate(r''' diff --git a/json_serializable/test/src/json_converter_test_input.dart b/json_serializable/test/src/json_converter_test_input.dart index 5f4075b8..6e40125f 100644 --- a/json_serializable/test/src/json_converter_test_input.dart +++ b/json_serializable/test/src/json_converter_test_input.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.6 + // ignore_for_file: inference_failure_on_instance_creation part of '_json_serializable_test_input.dart'; diff --git a/json_serializable/test/src/map_key_variety_test_input.dart b/json_serializable/test/src/map_key_variety_test_input.dart index 2f07cf70..9d55e3bc 100644 --- a/json_serializable/test/src/map_key_variety_test_input.dart +++ b/json_serializable/test/src/map_key_variety_test_input.dart @@ -1,3 +1,5 @@ +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldGenerate(r''' diff --git a/json_serializable/test/src/setter_test_input.dart b/json_serializable/test/src/setter_test_input.dart index f9dddf4b..81db156b 100644 --- a/json_serializable/test/src/setter_test_input.dart +++ b/json_serializable/test/src/setter_test_input.dart @@ -1,3 +1,5 @@ +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldGenerate( diff --git a/json_serializable/test/src/to_from_json_test_input.dart b/json_serializable/test/src/to_from_json_test_input.dart index abeb24be..21bb81bd 100644 --- a/json_serializable/test/src/to_from_json_test_input.dart +++ b/json_serializable/test/src/to_from_json_test_input.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// @dart=3.6 + part of '_json_serializable_test_input.dart'; int _toInt(bool input) => 42; diff --git a/json_serializable/test/src/unknown_enum_value_test_input.dart b/json_serializable/test/src/unknown_enum_value_test_input.dart index c2f74589..7dec6fea 100644 --- a/json_serializable/test/src/unknown_enum_value_test_input.dart +++ b/json_serializable/test/src/unknown_enum_value_test_input.dart @@ -1,3 +1,5 @@ +// @dart=3.6 + part of '_json_serializable_test_input.dart'; @ShouldGenerate( diff --git a/json_serializable/tool/field_matrix_builder.dart b/json_serializable/tool/field_matrix_builder.dart index 4288bd78..885357c1 100644 --- a/json_serializable/tool/field_matrix_builder.dart +++ b/json_serializable/tool/field_matrix_builder.dart @@ -15,6 +15,8 @@ Builder builder([_]) => _FieldMatrixBuilder(); class _FieldMatrixBuilder extends Builder { @override FutureOr build(BuildStep buildStep) async { + final formatter = await buildStep.formatter(); + final inputBaseName = p.basenameWithoutExtension(buildStep.inputId.path); final output = buildStep.allowedOutputs.single; diff --git a/json_serializable/tool/shared.dart b/json_serializable/tool/shared.dart index 6565baf9..265031a2 100644 --- a/json_serializable/tool/shared.dart +++ b/json_serializable/tool/shared.dart @@ -8,8 +8,6 @@ import 'package:build/build.dart'; import 'package:dart_style/dart_style.dart'; import 'package:yaml/yaml.dart'; -final formatter = DartFormatter(); - // Until we have verification in pkg:build and friends // https://github.com/dart-lang/build/issues/590 Builder validate(String builderName, Builder builder) { @@ -72,3 +70,8 @@ class Replacement { return outputContent.replaceAll(',)', ',\n)'); } } + +extension BuildStepExtension on BuildStep { + Future formatter() async => DartFormatter( + languageVersion: (await inputLibrary).languageVersion.effective); +} diff --git a/json_serializable/tool/test_builder.dart b/json_serializable/tool/test_builder.dart index c2e5379b..de50e3dac 100644 --- a/json_serializable/tool/test_builder.dart +++ b/json_serializable/tool/test_builder.dart @@ -17,6 +17,8 @@ class _TestBuilder implements Builder { @override FutureOr build(BuildStep buildStep) async { + final formatter = await buildStep.formatter(); + final baseName = p.basenameWithoutExtension(buildStep.inputId.path); final sourceContent = await buildStep.readAsString(buildStep.inputId); diff --git a/json_serializable/tool/test_type_builder.dart b/json_serializable/tool/test_type_builder.dart index 05023104..8b25a081 100644 --- a/json_serializable/tool/test_type_builder.dart +++ b/json_serializable/tool/test_type_builder.dart @@ -125,6 +125,8 @@ class _TypeBuilder implements Builder { @override FutureOr build(BuildStep buildStep) async { + final formatter = await buildStep.formatter(); + final inputId = buildStep.inputId; final sourceContent = await buildStep.readAsString(inputId); diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index 09b960f6..23aed093 100644 --- a/shared_test/pubspec.yaml +++ b/shared_test/pubspec.yaml @@ -1,7 +1,7 @@ name: _json_serial_shared_test publish_to: none environment: - sdk: ^3.5.0 + sdk: ^3.6.0 resolution: workspace