From 288dbdb915481555c8dc7a73d3820d992a5b8ab8 Mon Sep 17 00:00:00 2001 From: Jaap Aarts Date: Wed, 14 Jun 2023 22:45:23 +0200 Subject: [PATCH 01/42] Unify dart and flutter generation instructions (#1329) Unify dart and flutter generation instructions --- json_serializable/README.md | 5 +---- json_serializable/tool/readme/readme_template.md | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/json_serializable/README.md b/json_serializable/README.md index 5e7498540..cb1eec619 100644 --- a/json_serializable/README.md +++ b/json_serializable/README.md @@ -75,10 +75,7 @@ Map _$PersonToJson(Person instance) => { Once you have added the annotations to your code you then need to run the code generator to generate the missing `.g.dart` generated dart files. -With a Dart package, run `dart run build_runner build` in the package directory. - -With a Flutter package, run `flutter pub run build_runner build` in your package -directory. +Run `dart run build_runner build` in the package directory. # Annotation values diff --git a/json_serializable/tool/readme/readme_template.md b/json_serializable/tool/readme/readme_template.md index d8de00352..79ac1c7dd 100644 --- a/json_serializable/tool/readme/readme_template.md +++ b/json_serializable/tool/readme/readme_template.md @@ -35,10 +35,7 @@ Building creates the corresponding part `example.g.dart`: Once you have added the annotations to your code you then need to run the code generator to generate the missing `.g.dart` generated dart files. -With a Dart package, run `dart run build_runner build` in the package directory. - -With a Flutter package, run `flutter pub run build_runner build` in your package -directory. +Run `dart run build_runner build` in the package directory. # Annotation values From facdb5e5bd26e92d516017092cee49a213d05ecc Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 30 Jun 2023 15:07:27 -0700 Subject: [PATCH 02/42] Support latest pkg:analyzer, release v6.7.1 (#1333) --- json_serializable/CHANGELOG.md | 4 ++++ json_serializable/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 0effefc60..49a067ba7 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.7.1 + +- Support the latest `package:analyzer`. + ## 6.7.0 - Support `Record` types. diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index d64039063..cfb3dd8a8 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -1,5 +1,5 @@ name: json_serializable -version: 6.7.0 +version: 6.7.1 description: >- Automatically generate code for converting to and from JSON by annotating Dart classes. @@ -13,7 +13,7 @@ topics: - codegen dependencies: - analyzer: ^5.12.0 + analyzer: '>=5.12.0 <7.0.0' async: ^2.8.0 build: ^2.0.0 build_config: '>=0.4.4 <2.0.0' From 2185e8b80d8d0c12e2adbf897d920b6f5725cded Mon Sep 17 00:00:00 2001 From: CicadaCinema <52425971+CicadaCinema@users.noreply.github.com> Date: Tue, 11 Jul 2023 03:28:03 +0100 Subject: [PATCH 03/42] add Example.property field to docstring in example (#1337) --- json_annotation/lib/src/json_converter.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/json_annotation/lib/src/json_converter.dart b/json_annotation/lib/src/json_converter.dart index fefe88ece..bd0738e80 100644 --- a/json_annotation/lib/src/json_converter.dart +++ b/json_annotation/lib/src/json_converter.dart @@ -19,7 +19,9 @@ /// /// @JsonSerializable() /// @MyJsonConverter() -/// class Example {} +/// class Example { +/// final Value property; +/// } /// ``` /// /// or on a property: @@ -36,7 +38,9 @@ /// /// ```dart /// @JsonSerializable(converters: [MyJsonConverter()]) -/// class Example {} +/// class Example { +/// final Value property; +/// } /// ``` abstract class JsonConverter { const JsonConverter(); From 4e8e9ac2b14824787f08cfab94c44d9671e10ab0 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 8 Aug 2023 09:10:23 -0700 Subject: [PATCH 04/42] Require Dart 3 across the board, use switch expressions (#1344) --- .github/workflows/dart.yml | 258 ++++++------------ checked_yaml/CHANGELOG.md | 4 + checked_yaml/pubspec.yaml | 4 +- json_annotation/CHANGELOG.md | 4 + json_annotation/pubspec.yaml | 4 +- json_serializable/lib/src/utils.dart | 22 +- .../test/integration/json_test_common.dart | 15 +- shared_test/pubspec.yaml | 2 +- 8 files changed, 107 insertions(+), 206 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index c43b128da..6c8269f52 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -40,80 +40,16 @@ jobs: - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyzer_and_format; Dart 2.19.0; PKG: checked_yaml; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`" + name: "analyzer_and_format; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:checked_yaml;commands:format-analyze_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:format-analyze_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:checked_yaml - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - with: - sdk: "2.19.0" - - id: checkout - name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - id: checked_yaml_pub_upgrade - name: checked_yaml; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: checked_yaml - - name: "checked_yaml; dart format --output=none --set-exit-if-changed ." - run: "dart format --output=none --set-exit-if-changed ." - if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" - working-directory: checked_yaml - - name: "checked_yaml; dart analyze --fatal-infos ." - run: dart analyze --fatal-infos . - if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" - working-directory: checked_yaml - job_003: - name: "analyzer_and_format; Dart 2.19.0; PKG: json_annotation; `dart analyze`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:json_annotation;commands:analyze_1" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:json_annotation - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - with: - sdk: "2.19.0" - - id: checkout - name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - id: json_annotation_pub_upgrade - name: json_annotation; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: json_annotation - - name: json_annotation; dart analyze - run: dart analyze - if: "always() && steps.json_annotation_pub_upgrade.conclusion == 'success'" - working-directory: json_annotation - job_004: - name: "analyzer_and_format; Dart 3.0.0; PKGS: _test_yaml, example, json_serializable; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-example-json_serializable;commands:format-analyze_0" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-example-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -137,6 +73,19 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps._test_yaml_pub_upgrade.conclusion == 'success'" working-directory: _test_yaml + - id: checked_yaml_pub_upgrade + name: checked_yaml; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: checked_yaml + - name: "checked_yaml; dart format --output=none --set-exit-if-changed ." + run: "dart format --output=none --set-exit-if-changed ." + if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" + working-directory: checked_yaml + - name: "checked_yaml; dart analyze --fatal-infos ." + run: dart analyze --fatal-infos . + if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" + working-directory: checked_yaml - id: example_pub_upgrade name: example; dart pub upgrade run: dart pub upgrade @@ -163,7 +112,37 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" working-directory: json_serializable - job_005: + job_003: + name: "analyzer_and_format; Dart 3.0.0; PKG: json_annotation; `dart analyze`" + runs-on: ubuntu-latest + steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_annotation;commands:analyze_1" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_annotation + os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest + - name: Setup Dart SDK + uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + with: + sdk: "3.0.0" + - id: checkout + name: Checkout repository + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - id: json_annotation_pub_upgrade + name: json_annotation; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: json_annotation + - name: json_annotation; dart analyze + run: dart analyze + if: "always() && steps.json_annotation_pub_upgrade.conclusion == 'success'" + working-directory: json_annotation + job_004: name: "analyzer_and_format; Dart dev; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`" runs-on: ubuntu-latest steps: @@ -249,53 +228,17 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" working-directory: json_serializable - job_006: - name: "unit_test; Dart 2.19.0; PKG: checked_yaml; `dart test`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:checked_yaml;commands:test_0" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:checked_yaml - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - with: - sdk: "2.19.0" - - id: checkout - name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - id: checked_yaml_pub_upgrade - name: checked_yaml; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: checked_yaml - - name: checked_yaml; dart test - run: dart test - if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" - working-directory: checked_yaml - needs: - - job_001 - - job_002 - - job_003 - - job_004 - - job_005 - job_007: - name: "unit_test; Dart 3.0.0; PKGS: _test_yaml, example, json_serializable; `dart test`" + job_005: + name: "unit_test; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-example-json_serializable;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-example-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -315,6 +258,15 @@ jobs: run: dart test if: "always() && steps._test_yaml_pub_upgrade.conclusion == 'success'" working-directory: _test_yaml + - id: checked_yaml_pub_upgrade + name: checked_yaml; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: checked_yaml + - name: checked_yaml; dart test + run: dart test + if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" + working-directory: checked_yaml - id: example_pub_upgrade name: example; dart pub upgrade run: dart pub upgrade @@ -338,8 +290,7 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_008: + job_006: name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" runs-on: ubuntu-latest steps: @@ -374,8 +325,7 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_009: + job_007: name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: @@ -410,8 +360,7 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_010: + job_008: name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: @@ -446,8 +395,7 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_011: + job_009: name: "unit_test; Dart dev; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: @@ -509,8 +457,7 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_012: + job_010: name: "unit_test; Dart dev; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" runs-on: ubuntu-latest steps: @@ -545,8 +492,7 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_013: + job_011: name: "unit_test; Dart dev; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: @@ -581,8 +527,7 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_014: + job_012: name: "unit_test; Dart dev; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: @@ -617,63 +562,17 @@ jobs: - job_002 - job_003 - job_004 - - job_005 - job_015: - name: "ensure_build; Dart 2.19.0; PKG: checked_yaml; `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@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:checked_yaml;commands:test_1" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:checked_yaml - os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0 - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - with: - sdk: "2.19.0" - - id: checkout - name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - - id: checked_yaml_pub_upgrade - name: checked_yaml; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: checked_yaml - - name: "checked_yaml; dart test --run-skipped -t presubmit-only test/ensure_build_test.dart" - run: dart test --run-skipped -t presubmit-only test/ensure_build_test.dart - if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" - working-directory: checked_yaml - needs: - - job_001 - - job_002 - - job_003 - - job_004 - - job_005 - - job_006 - - job_007 - - job_008 - - job_009 - - job_010 - - job_011 - - job_012 - - job_013 - - job_014 - job_016: - name: "ensure_build; Dart 3.0.0; PKGS: _test_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + job_013: + name: "ensure_build; Dart 3.0.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@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-example;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-example + os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -693,6 +592,15 @@ jobs: run: dart test --run-skipped -t presubmit-only test/ensure_build_test.dart if: "always() && steps._test_yaml_pub_upgrade.conclusion == 'success'" working-directory: _test_yaml + - id: checked_yaml_pub_upgrade + name: checked_yaml; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: checked_yaml + - name: "checked_yaml; dart test --run-skipped -t presubmit-only test/ensure_build_test.dart" + run: dart test --run-skipped -t presubmit-only test/ensure_build_test.dart + if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" + working-directory: checked_yaml - id: example_pub_upgrade name: example; dart pub upgrade run: dart pub upgrade @@ -715,9 +623,7 @@ jobs: - job_010 - job_011 - job_012 - - job_013 - - job_014 - job_017: + job_014: name: "ensure_build; Dart dev; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: @@ -778,5 +684,3 @@ jobs: - job_010 - job_011 - job_012 - - job_013 - - job_014 diff --git a/checked_yaml/CHANGELOG.md b/checked_yaml/CHANGELOG.md index bcecf04d6..18603be88 100644 --- a/checked_yaml/CHANGELOG.md +++ b/checked_yaml/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.4-wip + +- Require Dart 3.0 + ## 2.0.3 - Require Dart 2.19 diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index 1b2e74eec..c164cab1a 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -1,5 +1,5 @@ name: checked_yaml -version: 2.0.3 +version: 2.0.4-wip description: >- Generate more helpful exceptions when decoding YAML documents using @@ -13,7 +13,7 @@ topics: - codegen environment: - sdk: '>=2.19.0 <3.0.0' + sdk: ^3.0.0 dependencies: json_annotation: ^4.3.0 diff --git a/json_annotation/CHANGELOG.md b/json_annotation/CHANGELOG.md index ee6b48c33..5929a6840 100644 --- a/json_annotation/CHANGELOG.md +++ b/json_annotation/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.8.2-wip + +- Require Dart 3.0 + ## 4.8.1 - Require Dart 2.19 diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index 64bc29b2a..ce60661f9 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -1,5 +1,5 @@ name: json_annotation -version: 4.8.1 +version: 4.8.2-wip description: >- Classes and helper functions that support JSON code generation via the `json_serializable` package. @@ -11,7 +11,7 @@ topics: - codegen environment: - sdk: '>=2.19.0 <3.0.0' + sdk: ^3.0.0 dependencies: meta: ^1.4.0 diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index 8163247c1..941b7492a 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -182,20 +182,14 @@ String ifNullOrElse(String test, String ifNull, String ifNotNull) => String encodedFieldName( FieldRename fieldRename, String declaredName, -) { - switch (fieldRename) { - case FieldRename.none: - return declaredName; - case FieldRename.snake: - return declaredName.snake; - case FieldRename.screamingSnake: - return declaredName.snake.toUpperCase(); - case FieldRename.kebab: - return declaredName.kebab; - case FieldRename.pascal: - return declaredName.pascal; - } -} +) => + switch (fieldRename) { + FieldRename.none => declaredName, + FieldRename.snake => declaredName.snake, + FieldRename.screamingSnake => declaredName.snake.toUpperCase(), + FieldRename.kebab => declaredName.kebab, + FieldRename.pascal => declaredName.pascal + }; /// Return the Dart code presentation for the given [type]. /// diff --git a/json_serializable/test/integration/json_test_common.dart b/json_serializable/test/integration/json_test_common.dart index fb7c4d212..d16c3b954 100644 --- a/json_serializable/test/integration/json_test_common.dart +++ b/json_serializable/test/integration/json_test_common.dart @@ -51,16 +51,11 @@ class Platform { const Platform._(this.description); - factory Platform.fromJson(String value) { - switch (value) { - case 'foo': - return foo; - case 'undefined': - return undefined; - default: - throw ArgumentError.value(value, 'value', 'Not a supported value.'); - } - } + factory Platform.fromJson(String value) => switch (value) { + 'foo' => foo, + 'undefined' => undefined, + _ => throw ArgumentError.value(value, 'value', 'Not a supported value.') + }; String toJson() => description; } diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index ab560ef00..c52b9527e 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: '>=2.19.0 <3.0.0' + sdk: ^3.0.0 dependencies: stack_trace: ^1.10.0 From ff0e0fd84a955a7ccd41d0478268f5764794a93c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 9 Aug 2023 08:49:56 -0700 Subject: [PATCH 05/42] Standardize analyze across packages (#1345) - analyze fatal infos + format on dev - just analyze on "pubspec" --- .github/workflows/dart.yml | 105 +++++++++----------------------- _test_yaml/mono_pkg.yaml | 4 ++ checked_yaml/mono_pkg.yaml | 5 +- example/mono_pkg.yaml | 4 ++ json_serializable/mono_pkg.yaml | 4 ++ 5 files changed, 45 insertions(+), 77 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 6c8269f52..65680329f 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -40,16 +40,16 @@ jobs: - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyzer_and_format; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`" + name: "analyzer_and_format; Dart 3.0.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@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:format-analyze_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -65,12 +65,8 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: _test_yaml - - name: "_test_yaml; dart format --output=none --set-exit-if-changed ." - run: "dart format --output=none --set-exit-if-changed ." - if: "always() && steps._test_yaml_pub_upgrade.conclusion == 'success'" - working-directory: _test_yaml - - name: "_test_yaml; dart analyze --fatal-infos ." - run: dart analyze --fatal-infos . + - name: _test_yaml; dart analyze + run: dart analyze if: "always() && steps._test_yaml_pub_upgrade.conclusion == 'success'" working-directory: _test_yaml - id: checked_yaml_pub_upgrade @@ -78,12 +74,8 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: checked_yaml - - name: "checked_yaml; dart format --output=none --set-exit-if-changed ." - run: "dart format --output=none --set-exit-if-changed ." - if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" - working-directory: checked_yaml - - name: "checked_yaml; dart analyze --fatal-infos ." - run: dart analyze --fatal-infos . + - name: checked_yaml; dart analyze + run: dart analyze if: "always() && steps.checked_yaml_pub_upgrade.conclusion == 'success'" working-directory: checked_yaml - id: example_pub_upgrade @@ -91,48 +83,10 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: example - - name: "example; dart format --output=none --set-exit-if-changed ." - run: "dart format --output=none --set-exit-if-changed ." - if: "always() && steps.example_pub_upgrade.conclusion == 'success'" - working-directory: example - - name: "example; dart analyze --fatal-infos ." - run: dart analyze --fatal-infos . + - name: example; dart analyze + run: dart analyze if: "always() && steps.example_pub_upgrade.conclusion == 'success'" working-directory: example - - id: json_serializable_pub_upgrade - name: json_serializable; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: json_serializable - - name: "json_serializable; dart format --output=none --set-exit-if-changed ." - run: "dart format --output=none --set-exit-if-changed ." - if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" - working-directory: json_serializable - - name: "json_serializable; dart analyze --fatal-infos ." - run: dart analyze --fatal-infos . - if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" - working-directory: json_serializable - job_003: - name: "analyzer_and_format; Dart 3.0.0; PKG: json_annotation; `dart analyze`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_annotation;commands:analyze_1" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_annotation - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - with: - sdk: "3.0.0" - - id: checkout - name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - id: json_annotation_pub_upgrade name: json_annotation; dart pub upgrade run: dart pub upgrade @@ -142,7 +96,16 @@ jobs: run: dart analyze if: "always() && steps.json_annotation_pub_upgrade.conclusion == 'success'" working-directory: json_annotation - job_004: + - id: json_serializable_pub_upgrade + name: json_serializable; dart pub upgrade + run: dart pub upgrade + if: "always() && steps.checkout.conclusion == 'success'" + working-directory: json_serializable + - name: json_serializable; dart analyze + run: dart analyze + if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" + working-directory: json_serializable + job_003: name: "analyzer_and_format; Dart dev; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`" runs-on: ubuntu-latest steps: @@ -228,7 +191,7 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" working-directory: json_serializable - job_005: + job_004: name: "unit_test; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: @@ -289,8 +252,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_006: + job_005: name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" runs-on: ubuntu-latest steps: @@ -324,8 +286,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_007: + job_006: name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: @@ -359,8 +320,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_008: + job_007: name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: @@ -394,8 +354,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_009: + job_008: name: "unit_test; Dart dev; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: @@ -456,8 +415,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_010: + job_009: name: "unit_test; Dart dev; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" runs-on: ubuntu-latest steps: @@ -491,8 +449,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_011: + job_010: name: "unit_test; Dart dev; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: @@ -526,8 +483,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_012: + job_011: name: "unit_test; Dart dev; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: @@ -561,8 +517,7 @@ jobs: - job_001 - job_002 - job_003 - - job_004 - job_013: + job_012: name: "ensure_build; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: @@ -622,8 +577,7 @@ jobs: - job_009 - job_010 - job_011 - - job_012 - job_014: + job_013: name: "ensure_build; Dart dev; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: @@ -683,4 +637,3 @@ jobs: - job_009 - job_010 - job_011 - - job_012 diff --git a/_test_yaml/mono_pkg.yaml b/_test_yaml/mono_pkg.yaml index 497ed5d8c..840b0b117 100644 --- a/_test_yaml/mono_pkg.yaml +++ b/_test_yaml/mono_pkg.yaml @@ -8,6 +8,10 @@ stages: - group: - format - analyze: --fatal-infos . + sdk: dev + - group: + - analyze + sdk: pubspec - unit_test: - test - ensure_build: diff --git a/checked_yaml/mono_pkg.yaml b/checked_yaml/mono_pkg.yaml index 667b27cd5..e31657400 100644 --- a/checked_yaml/mono_pkg.yaml +++ b/checked_yaml/mono_pkg.yaml @@ -8,7 +8,10 @@ stages: - group: - format - analyze: --fatal-infos . - + sdk: dev + - group: + - analyze + sdk: pubspec - unit_test: - test - ensure_build: diff --git a/example/mono_pkg.yaml b/example/mono_pkg.yaml index 158b67b19..8ab9954ed 100644 --- a/example/mono_pkg.yaml +++ b/example/mono_pkg.yaml @@ -8,6 +8,10 @@ stages: - group: - format - analyze: --fatal-infos . + sdk: dev + - group: + - analyze + sdk: pubspec - unit_test: - test - ensure_build: diff --git a/json_serializable/mono_pkg.yaml b/json_serializable/mono_pkg.yaml index 6da59e995..aed7819e8 100644 --- a/json_serializable/mono_pkg.yaml +++ b/json_serializable/mono_pkg.yaml @@ -8,6 +8,10 @@ stages: - group: - format - analyze: --fatal-infos . + sdk: dev + - group: + - analyze + sdk: pubspec - unit_test: - test: - test: -p chrome From aee214d96c68447d4c9fff9ab455e0014e20fca3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 12:07:05 -0700 Subject: [PATCH 06/42] Bump actions/setup-node from 3.6.0 to 3.8.1 (#1352) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.6.0 to 3.8.1. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c...5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/markdown_linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 5186f95cb..1658a0086 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c + uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: node-version: ${{ matrix.node-version }} - name: Install dependencies From b1b0998cf003f03d588397532bfedf595a5687f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 12:07:26 -0700 Subject: [PATCH 07/42] Bump actions/checkout from 3.5.2 to 3.6.0 (#1351) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.6.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8e5e7e5ab8b370d6c329ec480221332ada57f0ab...f43a0e5ff2bd294095638e18286ca9a3d1956744) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- .github/workflows/markdown_linter.yml | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 65680329f..83b7651e9 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -34,7 +34,7 @@ jobs: sdk: stable - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - name: mono_repo self validate run: dart pub global activate mono_repo 6.5.7 - name: mono_repo self validate @@ -59,7 +59,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -125,7 +125,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -211,7 +211,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -272,7 +272,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -306,7 +306,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -340,7 +340,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -374,7 +374,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -435,7 +435,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -469,7 +469,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -503,7 +503,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -537,7 +537,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -597,7 +597,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 1658a0086..f4261362c 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -11,7 +11,7 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: gaurav-nelson/github-action-markdown-link-check@v1 markdown_lint: runs-on: ubuntu-latest @@ -19,7 +19,7 @@ jobs: matrix: node-version: [ 14.x ] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: From 85e83641befab6a30526c24950ecfd3fe3f9ce62 Mon Sep 17 00:00:00 2001 From: Tatsuya Fujisaki <1838962+tatsuyafujisaki@users.noreply.github.com> Date: Thu, 14 Sep 2023 00:34:37 +0900 Subject: [PATCH 08/42] Replace deprecated "dart pub run" with "dart run" (#1353) --- example/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/README.md b/example/README.md index 20b58a5c7..65fc28f59 100644 --- a/example/README.md +++ b/example/README.md @@ -23,7 +23,7 @@ Annotate your code with classes defined in Run `dart run build_runner build` to generate files into your source directory. ```console -> dart pub run build_runner build +> dart run build_runner build [INFO] ensureBuildScript: Generating build script completed, took 368ms [INFO] BuildDefinition: Reading cached asset graph completed, took 54ms [INFO] BuildDefinition: Checking for updates since last build completed, took 663ms From d055d4951e5e7755776413d3eda435113103801e Mon Sep 17 00:00:00 2001 From: Serena867 <104524200+Serena867@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:25:00 -0700 Subject: [PATCH 09/42] Typo fix in utils.dart (#1363) Found and fixed a minor typo in utils.dart --- json_serializable/lib/src/utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index 941b7492a..c8c727f7d 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -48,7 +48,7 @@ T enumValueForDartObject( ) => items[source.getField('index')!.toIntValue()!]; -/// Return an instance of [JsonSerializable] corresponding to a the provided +/// Return an instance of [JsonSerializable] corresponding to the provided /// [reader]. // #CHANGE WHEN UPDATING json_annotation JsonSerializable _valueForAnnotation(ConstantReader reader) => JsonSerializable( From df42558da71dbe31f88b3435b4cfc04937e3327a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:23:57 -0700 Subject: [PATCH 10/42] Bump actions/cache from 3.3.1 to 3.3.2 (#1359) Bumps [actions/cache](https://github.com/actions/cache) from 3.3.1 to 3.3.2. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8...704facf57e6136b1bc63b828d79edcd491f0ee84) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 83b7651e9..f1031f039 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable" @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" @@ -110,7 +110,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:format-analyze_0" @@ -196,7 +196,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -257,7 +257,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_3" @@ -291,7 +291,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_1" @@ -325,7 +325,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_2" @@ -359,7 +359,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -420,7 +420,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_3" @@ -454,7 +454,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_1" @@ -488,7 +488,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_2" @@ -522,7 +522,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" @@ -582,7 +582,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example;commands:test_1" From fe636b10a55819859b1d807a24579df9481c84ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:24:22 -0700 Subject: [PATCH 11/42] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#1358) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/d6a63dab3335f427404425de0fbfed4686d93c4f...8a4b97ea2017cc079571daec46542f76189836b1) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index f1031f039..f7b0140eb 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -29,7 +29,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: stable - id: checkout @@ -54,7 +54,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: "3.0.0" - id: checkout @@ -120,7 +120,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: dev - id: checkout @@ -206,7 +206,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: "3.0.0" - id: checkout @@ -267,7 +267,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: "3.0.0" - id: checkout @@ -301,7 +301,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: "3.0.0" - id: checkout @@ -335,7 +335,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: "3.0.0" - id: checkout @@ -369,7 +369,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: dev - id: checkout @@ -430,7 +430,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: dev - id: checkout @@ -464,7 +464,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: dev - id: checkout @@ -498,7 +498,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: dev - id: checkout @@ -532,7 +532,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: "3.0.0" - id: checkout @@ -592,7 +592,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: dev - id: checkout From e2c8badaee4e36893e13c4073375a8ea035f2403 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:24:32 -0700 Subject: [PATCH 12/42] Bump actions/checkout from 3.6.0 to 4.1.0 (#1357) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/f43a0e5ff2bd294095638e18286ca9a3d1956744...8ade135a41bc03ea155e62e844d188df1ea18608) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- .github/workflows/markdown_linter.yml | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index f7b0140eb..8311a9857 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -34,7 +34,7 @@ jobs: sdk: stable - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: mono_repo self validate run: dart pub global activate mono_repo 6.5.7 - name: mono_repo self validate @@ -59,7 +59,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -125,7 +125,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -211,7 +211,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -272,7 +272,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -306,7 +306,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -340,7 +340,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -374,7 +374,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -435,7 +435,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -469,7 +469,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -503,7 +503,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -537,7 +537,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -597,7 +597,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index f4261362c..b6243be61 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -11,7 +11,7 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: gaurav-nelson/github-action-markdown-link-check@v1 markdown_lint: runs-on: ubuntu-latest @@ -19,7 +19,7 @@ jobs: matrix: node-version: [ 14.x ] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d with: From f8e57b52d9db0b66bab9f8cee86396f49d0a44e3 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 26 Oct 2023 10:50:43 -0700 Subject: [PATCH 13/42] Update to latest lints (#1361) --- _test_yaml/pubspec.yaml | 2 +- analysis_options.yaml | 6 - checked_yaml/pubspec.yaml | 2 +- checked_yaml/test/example_test.dart | 2 +- example/lib/json_converter_example.dart | 2 + example/pubspec.yaml | 2 +- example/test/json_convert_example_test.dart | 4 +- json_annotation/pubspec.yaml | 2 +- json_serializable/CHANGELOG.md | 4 + json_serializable/build.yaml | 4 + json_serializable/example/example.g.dart | 2 +- .../lib/src/type_helpers/record_helper.dart | 2 +- json_serializable/pubspec.yaml | 4 +- .../test/default_value/default_value.g.dart | 2 +- .../default_value.g_any_map__checked.g.dart | 2 +- .../default_value/default_value_test.dart | 4 +- .../implicit_default_value.g.dart | 2 +- .../field_matrix_test.field_matrix.g.dart | 2 +- .../generic_argument_factories.g.dart | 2 +- ...generic_argument_factories_nullable.g.dart | 2 +- .../test/generic_files/generic_class.dart | 2 + .../test/generic_files/generic_class.g.dart | 2 +- .../test/generic_files/generic_test.dart | 1 + .../integration/converter_examples.g.dart | 2 +- .../create_per_field_to_json_example.g.dart | 2 +- .../test/integration/field_map_example.g.dart | 2 +- .../test/integration/integration_test.dart | 2 +- .../test/integration/json_enum_example.g.dart | 2 +- .../test/integration/json_test_example.g.dart | 2 +- .../json_test_example.g_any_map.g.dart | 2 +- .../test/kitchen_sink/kitchen_sink.dart | 1 + .../test/kitchen_sink/kitchen_sink.g.dart | 4 +- .../kitchen_sink/kitchen_sink.g_any_map.dart | 1 + .../kitchen_sink.g_any_map.g.dart | 4 +- .../kitchen_sink.g_any_map__checked.dart | 1 + .../kitchen_sink.g_any_map__checked.g.dart | 4 +- .../kitchen_sink.g_exclude_null.dart | 1 + .../kitchen_sink.g_exclude_null.g.dart | 4 +- .../kitchen_sink.g_explicit_to_json.dart | 1 + .../kitchen_sink.g_explicit_to_json.g.dart | 4 +- .../test/kitchen_sink/kitchen_sink_test.dart | 12 +- .../kitchen_sink/kitchen_sink_yaml_test.dart | 4 +- .../test/kitchen_sink/simple_object.g.dart | 2 +- .../kitchen_sink/strict_keys_object.g.dart | 2 +- .../test/literal/json_literal.g.dart | 2 +- .../src/_json_serializable_test_input.dart | 2 +- .../test/src/json_converter_test_input.dart | 2 + .../test/supported_types/input.g.dart | 2 +- .../supported_types/input.type_bigint.g.dart | 2 +- .../supported_types/input.type_bool.g.dart | 2 +- .../input.type_datetime.g.dart | 2 +- .../supported_types/input.type_double.g.dart | 2 +- .../input.type_duration.g.dart | 2 +- .../input.type_enumtype.g.dart | 2 +- .../supported_types/input.type_int.g.dart | 2 +- .../input.type_iterable.g.dart | 6 +- .../supported_types/input.type_list.g.dart | 6 +- .../supported_types/input.type_map.g.dart | 124 ++++++++++-------- .../supported_types/input.type_num.g.dart | 2 +- .../supported_types/input.type_object.g.dart | 2 +- .../supported_types/input.type_record.g.dart | 122 ++++++++--------- .../supported_types/input.type_set.g.dart | 6 +- .../supported_types/input.type_string.g.dart | 2 +- .../supported_types/input.type_uri.g.dart | 2 +- .../tool/readme/readme_examples.g.dart | 2 +- json_serializable/tool/test_builder.dart | 3 +- shared_test/pubspec.yaml | 2 +- 67 files changed, 221 insertions(+), 198 deletions(-) diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index 4bcc26f14..f682e6e88 100644 --- a/_test_yaml/pubspec.yaml +++ b/_test_yaml/pubspec.yaml @@ -10,7 +10,7 @@ dev_dependencies: build_runner: ^2.0.0 build_verify: ^3.0.0 checked_yaml: any - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 json_annotation: ^4.7.0 json_serializable: any path: ^1.8.2 diff --git a/analysis_options.yaml b/analysis_options.yaml index 375e7720b..4786eef5b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -14,23 +14,17 @@ linter: - avoid_void_async - cancel_subscriptions - cascade_invocations - - comment_references - invalid_case_patterns - join_return_with_assignment - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_runtimeType_toString - package_api_docs - - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - - prefer_relative_imports - sort_child_properties_last - - test_types_in_equals - - type_literal_in_constant_pattern - unnecessary_breaks - unsafe_html - use_full_hex_values_for_flutter_colors - use_string_buffers - - use_super_parameters diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index c164cab1a..821c9de5e 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -23,7 +23,7 @@ dependencies: dev_dependencies: build_runner: ^2.0.0 build_verify: ^3.0.0 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 json_serializable: ^6.0.0 path: ^1.0.0 test: ^1.16.0 diff --git a/checked_yaml/test/example_test.dart b/checked_yaml/test/example_test.dart index a5d55786d..08ff6f358 100644 --- a/checked_yaml/test/example_test.dart +++ b/checked_yaml/test/example_test.dart @@ -114,7 +114,7 @@ line 1, column 10: Unsupported value for "name". Cannot be empty. }); } -void _expectThrows(String yamlContent, matcher) => expect( +void _expectThrows(String yamlContent, String matcher) => expect( () => _run(yamlContent), throwsA( isA().having( diff --git a/example/lib/json_converter_example.dart b/example/lib/json_converter_example.dart index d408223c3..3ca92c6f1 100644 --- a/example/lib/json_converter_example.dart +++ b/example/lib/json_converter_example.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. +// ignore_for_file: inference_failure_on_instance_creation + import 'package:json_annotation/json_annotation.dart'; part 'json_converter_example.g.dart'; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9eeb261d5..6191089bd 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -19,7 +19,7 @@ dev_dependencies: build_verify: ^3.0.0 # Not required to use `json_serializable`. - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 # REQUIRED! json_serializable: ^6.6.0 diff --git a/example/test/json_convert_example_test.dart b/example/test/json_convert_example_test.dart index 1801b21cc..5751b72de 100644 --- a/example/test/json_convert_example_test.dart +++ b/example/test/json_convert_example_test.dart @@ -83,8 +83,8 @@ void main() { throwsTypeError, ); - final collection2 = - GenericCollection.fromJson(jsonDecode(encoded) as Map); + final collection2 = GenericCollection.fromJson( + jsonDecode(encoded) as Map); expect(collection2.results, [ 1, diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index ce60661f9..a6b97a231 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: meta: ^1.4.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 # When changing JsonSerializable class. # build_runner: ^2.0.0 # json_serializable: any diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 49a067ba7..0d36ca8af 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.7.2-wip + +- Add type arguments to `Map` literals used for `Record` serialization. + ## 6.7.1 - Support the latest `package:analyzer`. diff --git a/json_serializable/build.yaml b/json_serializable/build.yaml index fb0052e74..e52d7d814 100644 --- a/json_serializable/build.yaml +++ b/json_serializable/build.yaml @@ -8,6 +8,10 @@ targets: - lines_longer_than_80_chars # Only for the JSON literal output file - text_direction_code_point_in_literal + # Too much work in generated code + - inference_failure_on_function_invocation + # Need to update sourcegen_helper to generate List/Map with the right type params + - inference_failure_on_collection_literal json_serializable: generate_for: diff --git a/json_serializable/example/example.g.dart b/json_serializable/example/example.g.dart index 21820874c..0ed069cae 100644 --- a/json_serializable/example/example.g.dart +++ b/json_serializable/example/example.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'example.dart'; diff --git a/json_serializable/lib/src/type_helpers/record_helper.dart b/json_serializable/lib/src/type_helpers/record_helper.dart index f086948bf..42b13025e 100644 --- a/json_serializable/lib/src/type_helpers/record_helper.dart +++ b/json_serializable/lib/src/type_helpers/record_helper.dart @@ -90,7 +90,7 @@ $helperName( ); } - final mapValue = '{${items.map((e) => '$e,').join()}}'; + final mapValue = '{${items.map((e) => '$e,').join()}}'; return targetType.isNullableType ? ifNullOrElse( diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index cfb3dd8a8..8f55a01f0 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -1,5 +1,5 @@ name: json_serializable -version: 6.7.1 +version: 6.7.2-wip description: >- Automatically generate code for converting to and from JSON by annotating Dart classes. @@ -34,7 +34,7 @@ dev_dependencies: path: ../shared_test build_runner: ^2.0.0 build_verify: ^3.0.0 - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 dart_style: ^2.0.0 logging: ^1.0.0 source_gen_test: ^1.0.0 diff --git a/json_serializable/test/default_value/default_value.g.dart b/json_serializable/test/default_value/default_value.g.dart index 4cf5cda7d..0614284e6 100644 --- a/json_serializable/test/default_value/default_value.g.dart +++ b/json_serializable/test/default_value/default_value.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'default_value.dart'; diff --git a/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart b/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart index b3a0669c9..24be86d8a 100644 --- a/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart +++ b/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'default_value.g_any_map__checked.dart'; diff --git a/json_serializable/test/default_value/default_value_test.dart b/json_serializable/test/default_value/default_value_test.dart index 59b82fc3c..d2d057c28 100644 --- a/json_serializable/test/default_value/default_value_test.dart +++ b/json_serializable/test/default_value/default_value_test.dart @@ -15,8 +15,8 @@ const _defaultInstance = { 'fieldString': 'string', 'fieldInt': 42, 'fieldDouble': 3.14, - 'fieldListEmpty': [], - 'fieldSetEmpty': [], + 'fieldListEmpty': [], + 'fieldSetEmpty': [], 'fieldMapEmpty': {}, 'fieldListSimple': [1, 2, 3], 'fieldSetSimple': ['entry1', 'entry2'], diff --git a/json_serializable/test/default_value/implicit_default_value.g.dart b/json_serializable/test/default_value/implicit_default_value.g.dart index 1a3973134..9bd1f19e0 100644 --- a/json_serializable/test/default_value/implicit_default_value.g.dart +++ b/json_serializable/test/default_value/implicit_default_value.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'implicit_default_value.dart'; diff --git a/json_serializable/test/field_matrix_test.field_matrix.g.dart b/json_serializable/test/field_matrix_test.field_matrix.g.dart index cdb054b03..84891ef9a 100644 --- a/json_serializable/test/field_matrix_test.field_matrix.g.dart +++ b/json_serializable/test/field_matrix_test.field_matrix.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'field_matrix_test.field_matrix.dart'; diff --git a/json_serializable/test/generic_files/generic_argument_factories.g.dart b/json_serializable/test/generic_files/generic_argument_factories.g.dart index 87755ac37..188ac7116 100644 --- a/json_serializable/test/generic_files/generic_argument_factories.g.dart +++ b/json_serializable/test/generic_files/generic_argument_factories.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'generic_argument_factories.dart'; diff --git a/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart b/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart index 5527d2fed..17b278eed 100644 --- a/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart +++ b/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'generic_argument_factories_nullable.dart'; diff --git a/json_serializable/test/generic_files/generic_class.dart b/json_serializable/test/generic_files/generic_class.dart index 6149d8dba..0870c956f 100644 --- a/json_serializable/test/generic_files/generic_class.dart +++ b/json_serializable/test/generic_files/generic_class.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. +// ignore_for_file: inference_failure_on_instance_creation + import 'package:collection/collection.dart'; import 'package:json_annotation/json_annotation.dart'; diff --git a/json_serializable/test/generic_files/generic_class.g.dart b/json_serializable/test/generic_files/generic_class.g.dart index c2f216483..c5809241c 100644 --- a/json_serializable/test/generic_files/generic_class.g.dart +++ b/json_serializable/test/generic_files/generic_class.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'generic_class.dart'; diff --git a/json_serializable/test/generic_files/generic_test.dart b/json_serializable/test/generic_files/generic_test.dart index 7de5f80d5..e4f82d6f3 100644 --- a/json_serializable/test/generic_files/generic_test.dart +++ b/json_serializable/test/generic_files/generic_test.dart @@ -24,6 +24,7 @@ void main() { } test('no type args', () { + // ignore: inference_failure_on_instance_creation roundTripGenericClass(GenericClass() ..fieldDynamic = 1 ..fieldInt = 2 diff --git a/json_serializable/test/integration/converter_examples.g.dart b/json_serializable/test/integration/converter_examples.g.dart index de339009e..26da277f0 100644 --- a/json_serializable/test/integration/converter_examples.g.dart +++ b/json_serializable/test/integration/converter_examples.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'converter_examples.dart'; diff --git a/json_serializable/test/integration/create_per_field_to_json_example.g.dart b/json_serializable/test/integration/create_per_field_to_json_example.g.dart index 29c4baa7b..0587c26ba 100644 --- a/json_serializable/test/integration/create_per_field_to_json_example.g.dart +++ b/json_serializable/test/integration/create_per_field_to_json_example.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'create_per_field_to_json_example.dart'; diff --git a/json_serializable/test/integration/field_map_example.g.dart b/json_serializable/test/integration/field_map_example.g.dart index 5c50eadc3..d47e01793 100644 --- a/json_serializable/test/integration/field_map_example.g.dart +++ b/json_serializable/test/integration/field_map_example.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'field_map_example.dart'; diff --git a/json_serializable/test/integration/integration_test.dart b/json_serializable/test/integration/integration_test.dart index 76b01f8fa..9305b4f9b 100644 --- a/json_serializable/test/integration/integration_test.dart +++ b/json_serializable/test/integration/integration_test.dart @@ -13,7 +13,7 @@ import 'json_enum_example.dart'; import 'json_test_common.dart' show Category, Platform, StatusCode; import 'json_test_example.dart'; -Matcher _throwsArgumentError(matcher) => +Matcher _throwsArgumentError(Object matcher) => throwsA(isArgumentError.having((e) => e.message, 'message', matcher)); void main() { diff --git a/json_serializable/test/integration/json_enum_example.g.dart b/json_serializable/test/integration/json_enum_example.g.dart index 818e057ae..6408e9e1d 100644 --- a/json_serializable/test/integration/json_enum_example.g.dart +++ b/json_serializable/test/integration/json_enum_example.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'json_enum_example.dart'; diff --git a/json_serializable/test/integration/json_test_example.g.dart b/json_serializable/test/integration/json_test_example.g.dart index 4681280b8..b6a5330d4 100644 --- a/json_serializable/test/integration/json_test_example.g.dart +++ b/json_serializable/test/integration/json_test_example.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'json_test_example.dart'; diff --git a/json_serializable/test/integration/json_test_example.g_any_map.g.dart b/json_serializable/test/integration/json_test_example.g_any_map.g.dart index 1e86e1fbc..b8ba1f9f4 100644 --- a/json_serializable/test/integration/json_test_example.g_any_map.g.dart +++ b/json_serializable/test/integration/json_test_example.g_any_map.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'json_test_example.g_any_map.dart'; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.dart b/json_serializable/test/kitchen_sink/kitchen_sink.dart index b0ff20f00..86525d9c8 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.dart @@ -249,6 +249,7 @@ class JsonConverterTestClass implements k.JsonConverterTestClass { } @JsonSerializable() +// ignore: inference_failure_on_instance_creation @GenericConverter() class JsonConverterGeneric { S item; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g.dart index 1396ff044..d9230fbc5 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'kitchen_sink.dart'; @@ -142,7 +142,7 @@ Map _$KitchenSinkToJson(KitchenSink instance) => 'validatedPropertyNo42': instance.validatedPropertyNo42, 'recordField': instance.recordField == null ? null - : { + : { r'$1': instance.recordField!.$1, r'$2': instance.recordField!.$2, 'truth': instance.recordField!.truth, diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.dart index 6f8b5c69f..f00f38ebc 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.dart @@ -251,6 +251,7 @@ class JsonConverterTestClass implements k.JsonConverterTestClass { @JsonSerializable( anyMap: true, ) +// ignore: inference_failure_on_instance_creation @GenericConverter() class JsonConverterGeneric { S item; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart index 6cfb749ea..74a348f5e 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'kitchen_sink.g_any_map.dart'; @@ -134,7 +134,7 @@ Map _$KitchenSinkToJson(KitchenSink instance) => 'validatedPropertyNo42': instance.validatedPropertyNo42, 'recordField': instance.recordField == null ? null - : { + : { r'$1': instance.recordField!.$1, r'$2': instance.recordField!.$2, 'truth': instance.recordField!.truth, diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.dart index fe5bcbba7..0d9dc1144 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.dart @@ -253,6 +253,7 @@ class JsonConverterTestClass implements k.JsonConverterTestClass { checked: true, anyMap: true, ) +// ignore: inference_failure_on_instance_creation @GenericConverter() class JsonConverterGeneric { S item; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart index 02fc36586..d08da32c5 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'kitchen_sink.g_any_map__checked.dart'; @@ -187,7 +187,7 @@ Map _$KitchenSinkToJson(KitchenSink instance) => 'validatedPropertyNo42': instance.validatedPropertyNo42, 'recordField': instance.recordField == null ? null - : { + : { r'$1': instance.recordField!.$1, r'$2': instance.recordField!.$2, 'truth': instance.recordField!.truth, diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.dart index 9476908a6..5dda14726 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.dart @@ -253,6 +253,7 @@ class JsonConverterTestClass implements k.JsonConverterTestClass { @JsonSerializable( includeIfNull: false, ) +// ignore: inference_failure_on_instance_creation @GenericConverter() class JsonConverterGeneric { S item; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart index e9f8662ad..76504317c 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'kitchen_sink.g_exclude_null.dart'; @@ -151,7 +151,7 @@ Map _$KitchenSinkToJson(KitchenSink instance) { 'recordField', instance.recordField == null ? null - : { + : { r'$1': instance.recordField!.$1, r'$2': instance.recordField!.$2, 'truth': instance.recordField!.truth, diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.dart index 48afb79fc..efccc8f08 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.dart @@ -253,6 +253,7 @@ class JsonConverterTestClass implements k.JsonConverterTestClass { @JsonSerializable( explicitToJson: true, ) +// ignore: inference_failure_on_instance_creation @GenericConverter() class JsonConverterGeneric { S item; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart index 24101a1b6..ff092269c 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'kitchen_sink.g_explicit_to_json.dart'; @@ -144,7 +144,7 @@ Map _$KitchenSinkToJson(KitchenSink instance) => 'validatedPropertyNo42': instance.validatedPropertyNo42, 'recordField': instance.recordField == null ? null - : { + : { r'$1': instance.recordField!.$1, r'$2': instance.recordField!.$2, 'truth': instance.recordField!.truth, diff --git a/json_serializable/test/kitchen_sink/kitchen_sink_test.dart b/json_serializable/test/kitchen_sink/kitchen_sink_test.dart index f3519050b..3cd0c399f 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink_test.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink_test.dart @@ -12,7 +12,7 @@ import 'kitchen_sink_interface.dart'; import 'kitchen_sink_test_shared.dart'; import 'strict_keys_object.dart'; -Matcher _isMissingKeyException(expectedMessage) => +Matcher _isMissingKeyException(String expectedMessage) => isA() .having((e) => e.message, 'message', expectedMessage); @@ -99,17 +99,17 @@ void _nullableTests(KitchenSinkFactory factory) { expect(json, const { 'duration': 0, - 'durationList': [], + 'durationList': [], 'bigInt': '0', - 'bigIntMap': {}, + 'bigIntMap': {}, 'nullableBigInt': '0', - 'nullableBigIntMap': {}, + 'nullableBigIntMap': {}, 'numberSilly': 0, - 'numberSillySet': [], + 'numberSillySet': [], 'dateTime': 0, 'trivialString': '', 'nullableNumberSilly': 0, - 'nullableNumberSillySet': [], + 'nullableNumberSillySet': [], }); expect(json.keys, unorderedEquals(_jsonConverterValidValues.keys)); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink_yaml_test.dart b/json_serializable/test/kitchen_sink/kitchen_sink_yaml_test.dart index e1fcb1039..951a90df7 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink_yaml_test.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink_yaml_test.dart @@ -42,7 +42,7 @@ void _testBadValue(String key, Object? badValue, KitchenSinkFactory factory, for (final isJson in [true, false]) { test('`$key` fails with value `$badValue`- ${isJson ? 'json' : 'yaml'}', () { - var copy = Map.from(validValues); + var copy = Map.of(validValues); copy[key] = badValue; if (!isJson) { @@ -88,7 +88,7 @@ Matcher _getMatcher(bool checked, String? expectedKey, bool checkedAssignment) { return throwsA(innerMatcher); } -Matcher _isAUnrecognizedKeysException(expectedMessage) => +Matcher _isAUnrecognizedKeysException(String expectedMessage) => isA() .having((e) => e.message, 'message', expectedMessage); diff --git a/json_serializable/test/kitchen_sink/simple_object.g.dart b/json_serializable/test/kitchen_sink/simple_object.g.dart index c18d4558c..b0bbfbef0 100644 --- a/json_serializable/test/kitchen_sink/simple_object.g.dart +++ b/json_serializable/test/kitchen_sink/simple_object.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'simple_object.dart'; diff --git a/json_serializable/test/kitchen_sink/strict_keys_object.g.dart b/json_serializable/test/kitchen_sink/strict_keys_object.g.dart index b8dc65ec6..b6b00cce3 100644 --- a/json_serializable/test/kitchen_sink/strict_keys_object.g.dart +++ b/json_serializable/test/kitchen_sink/strict_keys_object.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'strict_keys_object.dart'; diff --git a/json_serializable/test/literal/json_literal.g.dart b/json_serializable/test/literal/json_literal.g.dart index 02294b603..9e0993dde 100644 --- a/json_serializable/test/literal/json_literal.g.dart +++ b/json_serializable/test/literal/json_literal.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'json_literal.dart'; diff --git a/json_serializable/test/src/_json_serializable_test_input.dart b/json_serializable/test/src/_json_serializable_test_input.dart index f77864668..af82c8440 100644 --- a/json_serializable/test/src/_json_serializable_test_input.dart +++ b/json_serializable/test/src/_json_serializable_test_input.dart @@ -81,7 +81,7 @@ class GeneralTestClass1 { late DateTime dateOfBirth; dynamic dynamicType; - //ignore: prefer_typing_uninitialized_variables,type_annotate_public_apis + //ignore: prefer_typing_uninitialized_variables,type_annotate_public_apis,inference_failure_on_uninitialized_variable var varType; late List listOfInts; } diff --git a/json_serializable/test/src/json_converter_test_input.dart b/json_serializable/test/src/json_converter_test_input.dart index ac7852f61..865ee06a6 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. +// ignore_for_file: inference_failure_on_instance_creation + part of '_json_serializable_test_input.dart'; @ShouldGenerate(r''' diff --git a/json_serializable/test/supported_types/input.g.dart b/json_serializable/test/supported_types/input.g.dart index a07530cb6..4c7e8053d 100644 --- a/json_serializable/test/supported_types/input.g.dart +++ b/json_serializable/test/supported_types/input.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.dart'; diff --git a/json_serializable/test/supported_types/input.type_bigint.g.dart b/json_serializable/test/supported_types/input.type_bigint.g.dart index 39f10c238..379bdbd50 100644 --- a/json_serializable/test/supported_types/input.type_bigint.g.dart +++ b/json_serializable/test/supported_types/input.type_bigint.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_bigint.dart'; diff --git a/json_serializable/test/supported_types/input.type_bool.g.dart b/json_serializable/test/supported_types/input.type_bool.g.dart index 7964a3a21..4077ce108 100644 --- a/json_serializable/test/supported_types/input.type_bool.g.dart +++ b/json_serializable/test/supported_types/input.type_bool.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_bool.dart'; diff --git a/json_serializable/test/supported_types/input.type_datetime.g.dart b/json_serializable/test/supported_types/input.type_datetime.g.dart index 043bce089..461e30ebb 100644 --- a/json_serializable/test/supported_types/input.type_datetime.g.dart +++ b/json_serializable/test/supported_types/input.type_datetime.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_datetime.dart'; diff --git a/json_serializable/test/supported_types/input.type_double.g.dart b/json_serializable/test/supported_types/input.type_double.g.dart index 921716796..163485d5a 100644 --- a/json_serializable/test/supported_types/input.type_double.g.dart +++ b/json_serializable/test/supported_types/input.type_double.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_double.dart'; diff --git a/json_serializable/test/supported_types/input.type_duration.g.dart b/json_serializable/test/supported_types/input.type_duration.g.dart index cee2811f2..7ea4c7da6 100644 --- a/json_serializable/test/supported_types/input.type_duration.g.dart +++ b/json_serializable/test/supported_types/input.type_duration.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_duration.dart'; diff --git a/json_serializable/test/supported_types/input.type_enumtype.g.dart b/json_serializable/test/supported_types/input.type_enumtype.g.dart index b8f1901fc..77d67e064 100644 --- a/json_serializable/test/supported_types/input.type_enumtype.g.dart +++ b/json_serializable/test/supported_types/input.type_enumtype.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_enumtype.dart'; diff --git a/json_serializable/test/supported_types/input.type_int.g.dart b/json_serializable/test/supported_types/input.type_int.g.dart index 848d81cf1..ddb06ed57 100644 --- a/json_serializable/test/supported_types/input.type_int.g.dart +++ b/json_serializable/test/supported_types/input.type_int.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_int.dart'; diff --git a/json_serializable/test/supported_types/input.type_iterable.g.dart b/json_serializable/test/supported_types/input.type_iterable.g.dart index 885d166a8..95c3e0557 100644 --- a/json_serializable/test/supported_types/input.type_iterable.g.dart +++ b/json_serializable/test/supported_types/input.type_iterable.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_iterable.dart'; @@ -599,7 +599,7 @@ Map _$SimpleClassOfRecordToJson( SimpleClassOfRecord instance) => { 'value': instance.value - .map((e) => { + .map((e) => { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -630,7 +630,7 @@ Map _$SimpleClassNullableOfRecordToJson( SimpleClassNullableOfRecord instance) => { 'value': instance.value - ?.map((e) => { + ?.map((e) => { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, diff --git a/json_serializable/test/supported_types/input.type_list.g.dart b/json_serializable/test/supported_types/input.type_list.g.dart index b21a959b6..2f4497581 100644 --- a/json_serializable/test/supported_types/input.type_list.g.dart +++ b/json_serializable/test/supported_types/input.type_list.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_list.dart'; @@ -635,7 +635,7 @@ Map _$SimpleClassOfRecordToJson( SimpleClassOfRecord instance) => { 'value': instance.value - .map((e) => { + .map((e) => { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -668,7 +668,7 @@ Map _$SimpleClassNullableOfRecordToJson( SimpleClassNullableOfRecord instance) => { 'value': instance.value - ?.map((e) => { + ?.map((e) => { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, diff --git a/json_serializable/test/supported_types/input.type_map.g.dart b/json_serializable/test/supported_types/input.type_map.g.dart index dc17f2907..5f29d60ab 100644 --- a/json_serializable/test/supported_types/input.type_map.g.dart +++ b/json_serializable/test/supported_types/input.type_map.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_map.dart'; @@ -5301,11 +5301,12 @@ SimpleClassOfBigIntToRecord _$SimpleClassOfBigIntToRecordFromJson( Map _$SimpleClassOfBigIntToRecordToJson( SimpleClassOfBigIntToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(k.toString(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': + instance.value.map((k, e) => MapEntry(k.toString(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; $Rec _$recordConvert<$Rec>( @@ -5334,11 +5335,12 @@ SimpleClassNullableOfBigIntToRecord Map _$SimpleClassNullableOfBigIntToRecordToJson( SimpleClassNullableOfBigIntToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(k.toString(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': instance.value + ?.map((k, e) => MapEntry(k.toString(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassOfDateTimeToRecord _$SimpleClassOfDateTimeToRecordFromJson( @@ -5361,11 +5363,12 @@ SimpleClassOfDateTimeToRecord _$SimpleClassOfDateTimeToRecordFromJson( Map _$SimpleClassOfDateTimeToRecordToJson( SimpleClassOfDateTimeToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(k.toIso8601String(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': instance.value + .map((k, e) => MapEntry(k.toIso8601String(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassNullableOfDateTimeToRecord @@ -5389,11 +5392,12 @@ SimpleClassNullableOfDateTimeToRecord Map _$SimpleClassNullableOfDateTimeToRecordToJson( SimpleClassNullableOfDateTimeToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(k.toIso8601String(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': instance.value + ?.map((k, e) => MapEntry(k.toIso8601String(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassOfDynamicToRecord _$SimpleClassOfDynamicToRecordFromJson( @@ -5416,7 +5420,7 @@ SimpleClassOfDynamicToRecord _$SimpleClassOfDynamicToRecordFromJson( Map _$SimpleClassOfDynamicToRecordToJson( SimpleClassOfDynamicToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(k, { + 'value': instance.value.map((k, e) => MapEntry(k, { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -5443,7 +5447,7 @@ SimpleClassNullableOfDynamicToRecord Map _$SimpleClassNullableOfDynamicToRecordToJson( SimpleClassNullableOfDynamicToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(k, { + 'value': instance.value?.map((k, e) => MapEntry(k, { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -5470,11 +5474,12 @@ SimpleClassOfEnumTypeToRecord _$SimpleClassOfEnumTypeToRecordFromJson( Map _$SimpleClassOfEnumTypeToRecordToJson( SimpleClassOfEnumTypeToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(_$EnumTypeEnumMap[k]!, { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': instance.value + .map((k, e) => MapEntry(_$EnumTypeEnumMap[k]!, { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassNullableOfEnumTypeToRecord @@ -5498,11 +5503,12 @@ SimpleClassNullableOfEnumTypeToRecord Map _$SimpleClassNullableOfEnumTypeToRecordToJson( SimpleClassNullableOfEnumTypeToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(_$EnumTypeEnumMap[k]!, { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': instance.value + ?.map((k, e) => MapEntry(_$EnumTypeEnumMap[k]!, { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassOfIntToRecord _$SimpleClassOfIntToRecordFromJson( @@ -5525,11 +5531,12 @@ SimpleClassOfIntToRecord _$SimpleClassOfIntToRecordFromJson( Map _$SimpleClassOfIntToRecordToJson( SimpleClassOfIntToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(k.toString(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': + instance.value.map((k, e) => MapEntry(k.toString(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassNullableOfIntToRecord _$SimpleClassNullableOfIntToRecordFromJson( @@ -5552,11 +5559,12 @@ SimpleClassNullableOfIntToRecord _$SimpleClassNullableOfIntToRecordFromJson( Map _$SimpleClassNullableOfIntToRecordToJson( SimpleClassNullableOfIntToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(k.toString(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': instance.value + ?.map((k, e) => MapEntry(k.toString(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassOfObjectToRecord _$SimpleClassOfObjectToRecordFromJson( @@ -5579,7 +5587,7 @@ SimpleClassOfObjectToRecord _$SimpleClassOfObjectToRecordFromJson( Map _$SimpleClassOfObjectToRecordToJson( SimpleClassOfObjectToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(k, { + 'value': instance.value.map((k, e) => MapEntry(k, { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -5606,7 +5614,7 @@ SimpleClassNullableOfObjectToRecord Map _$SimpleClassNullableOfObjectToRecordToJson( SimpleClassNullableOfObjectToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(k, { + 'value': instance.value?.map((k, e) => MapEntry(k, { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -5633,7 +5641,7 @@ SimpleClassOfStringToRecord _$SimpleClassOfStringToRecordFromJson( Map _$SimpleClassOfStringToRecordToJson( SimpleClassOfStringToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(k, { + 'value': instance.value.map((k, e) => MapEntry(k, { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -5660,7 +5668,7 @@ SimpleClassNullableOfStringToRecord Map _$SimpleClassNullableOfStringToRecordToJson( SimpleClassNullableOfStringToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(k, { + 'value': instance.value?.map((k, e) => MapEntry(k, { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -5687,11 +5695,12 @@ SimpleClassOfUriToRecord _$SimpleClassOfUriToRecordFromJson( Map _$SimpleClassOfUriToRecordToJson( SimpleClassOfUriToRecord instance) => { - 'value': instance.value.map((k, e) => MapEntry(k.toString(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': + instance.value.map((k, e) => MapEntry(k.toString(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassNullableOfUriToRecord _$SimpleClassNullableOfUriToRecordFromJson( @@ -5714,11 +5723,12 @@ SimpleClassNullableOfUriToRecord _$SimpleClassNullableOfUriToRecordFromJson( Map _$SimpleClassNullableOfUriToRecordToJson( SimpleClassNullableOfUriToRecord instance) => { - 'value': instance.value?.map((k, e) => MapEntry(k.toString(), { - r'$1': e.$1, - r'$2': e.$2, - 'truth': e.truth, - })), + 'value': instance.value + ?.map((k, e) => MapEntry(k.toString(), { + r'$1': e.$1, + r'$2': e.$2, + 'truth': e.truth, + })), }; SimpleClassOfBigIntToString _$SimpleClassOfBigIntToStringFromJson( diff --git a/json_serializable/test/supported_types/input.type_num.g.dart b/json_serializable/test/supported_types/input.type_num.g.dart index fbd27bbba..f25274d8f 100644 --- a/json_serializable/test/supported_types/input.type_num.g.dart +++ b/json_serializable/test/supported_types/input.type_num.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_num.dart'; diff --git a/json_serializable/test/supported_types/input.type_object.g.dart b/json_serializable/test/supported_types/input.type_object.g.dart index 7959daa78..b35be59b6 100644 --- a/json_serializable/test/supported_types/input.type_object.g.dart +++ b/json_serializable/test/supported_types/input.type_object.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_object.dart'; diff --git a/json_serializable/test/supported_types/input.type_record.g.dart b/json_serializable/test/supported_types/input.type_record.g.dart index 19f2da859..5c96d58c8 100644 --- a/json_serializable/test/supported_types/input.type_record.g.dart +++ b/json_serializable/test/supported_types/input.type_record.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_record.dart'; @@ -14,7 +14,7 @@ SimpleClass _$SimpleClassFromJson(Map json) => SimpleClass( Map _$SimpleClassToJson(SimpleClass instance) => { - 'value': {}, + 'value': {}, }; SimpleClassNullable _$SimpleClassNullableFromJson(Map json) => @@ -25,7 +25,7 @@ SimpleClassNullable _$SimpleClassNullableFromJson(Map json) => Map _$SimpleClassNullableToJson( SimpleClassNullable instance) => { - 'value': instance.value == null ? null : {}, + 'value': instance.value == null ? null : {}, }; SimpleClassOfBigInt _$SimpleClassOfBigIntFromJson(Map json) => @@ -42,7 +42,7 @@ SimpleClassOfBigInt _$SimpleClassOfBigIntFromJson(Map json) => Map _$SimpleClassOfBigIntToJson( SimpleClassOfBigInt instance) => { - 'value': { + 'value': { r'$1': instance.value.$1.toString(), 'named': instance.value.named.toString(), }, @@ -71,7 +71,7 @@ Map _$SimpleClassNullableOfBigIntToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1.toString(), 'named': instance.value!.named.toString(), }, @@ -102,7 +102,7 @@ SimpleClassOfBigIntNullable _$SimpleClassOfBigIntNullableFromJson( Map _$SimpleClassOfBigIntNullableToJson( SimpleClassOfBigIntNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1?.toString(), 'named': instance.value.named?.toString(), }, @@ -129,7 +129,7 @@ Map _$SimpleClassNullableOfBigIntNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1?.toString(), 'named': instance.value!.named?.toString(), }, @@ -148,7 +148,7 @@ SimpleClassOfBool _$SimpleClassOfBoolFromJson(Map json) => Map _$SimpleClassOfBoolToJson(SimpleClassOfBool instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -171,7 +171,7 @@ Map _$SimpleClassNullableOfBoolToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -192,7 +192,7 @@ SimpleClassOfBoolNullable _$SimpleClassOfBoolNullableFromJson( Map _$SimpleClassOfBoolNullableToJson( SimpleClassOfBoolNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -215,7 +215,7 @@ Map _$SimpleClassNullableOfBoolNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -236,7 +236,7 @@ SimpleClassOfDateTime _$SimpleClassOfDateTimeFromJson( Map _$SimpleClassOfDateTimeToJson( SimpleClassOfDateTime instance) => { - 'value': { + 'value': { r'$1': instance.value.$1.toIso8601String(), 'named': instance.value.named.toIso8601String(), }, @@ -259,7 +259,7 @@ Map _$SimpleClassNullableOfDateTimeToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1.toIso8601String(), 'named': instance.value!.named.toIso8601String(), }, @@ -284,7 +284,7 @@ SimpleClassOfDateTimeNullable _$SimpleClassOfDateTimeNullableFromJson( Map _$SimpleClassOfDateTimeNullableToJson( SimpleClassOfDateTimeNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1?.toIso8601String(), 'named': instance.value.named?.toIso8601String(), }, @@ -312,7 +312,7 @@ Map _$SimpleClassNullableOfDateTimeNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1?.toIso8601String(), 'named': instance.value!.named?.toIso8601String(), }, @@ -332,7 +332,7 @@ SimpleClassOfDouble _$SimpleClassOfDoubleFromJson(Map json) => Map _$SimpleClassOfDoubleToJson( SimpleClassOfDouble instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -355,7 +355,7 @@ Map _$SimpleClassNullableOfDoubleToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -376,7 +376,7 @@ SimpleClassOfDoubleNullable _$SimpleClassOfDoubleNullableFromJson( Map _$SimpleClassOfDoubleNullableToJson( SimpleClassOfDoubleNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -399,7 +399,7 @@ Map _$SimpleClassNullableOfDoubleNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -420,7 +420,7 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( Map _$SimpleClassOfDurationToJson( SimpleClassOfDuration instance) => { - 'value': { + 'value': { r'$1': instance.value.$1.inMicroseconds, 'named': instance.value.named.inMicroseconds, }, @@ -443,7 +443,7 @@ Map _$SimpleClassNullableOfDurationToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1.inMicroseconds, 'named': instance.value!.named.inMicroseconds, }, @@ -468,7 +468,7 @@ SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( Map _$SimpleClassOfDurationNullableToJson( SimpleClassOfDurationNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1?.inMicroseconds, 'named': instance.value.named?.inMicroseconds, }, @@ -496,7 +496,7 @@ Map _$SimpleClassNullableOfDurationNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1?.inMicroseconds, 'named': instance.value!.named?.inMicroseconds, }, @@ -517,7 +517,7 @@ SimpleClassOfDynamic _$SimpleClassOfDynamicFromJson( Map _$SimpleClassOfDynamicToJson( SimpleClassOfDynamic instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -540,7 +540,7 @@ Map _$SimpleClassNullableOfDynamicToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -561,7 +561,7 @@ SimpleClassOfEnumType _$SimpleClassOfEnumTypeFromJson( Map _$SimpleClassOfEnumTypeToJson( SimpleClassOfEnumType instance) => { - 'value': { + 'value': { r'$1': _$EnumTypeEnumMap[instance.value.$1]!, 'named': _$EnumTypeEnumMap[instance.value.named]!, }, @@ -591,7 +591,7 @@ Map _$SimpleClassNullableOfEnumTypeToJson( { 'value': instance.value == null ? null - : { + : { r'$1': _$EnumTypeEnumMap[instance.value!.$1]!, 'named': _$EnumTypeEnumMap[instance.value!.named]!, }, @@ -612,7 +612,7 @@ SimpleClassOfEnumTypeNullable _$SimpleClassOfEnumTypeNullableFromJson( Map _$SimpleClassOfEnumTypeNullableToJson( SimpleClassOfEnumTypeNullable instance) => { - 'value': { + 'value': { r'$1': _$EnumTypeEnumMap[instance.value.$1], 'named': _$EnumTypeEnumMap[instance.value.named], }, @@ -637,7 +637,7 @@ Map _$SimpleClassNullableOfEnumTypeNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': _$EnumTypeEnumMap[instance.value!.$1], 'named': _$EnumTypeEnumMap[instance.value!.named], }, @@ -658,7 +658,7 @@ SimpleClassOfFromJsonDynamicParam _$SimpleClassOfFromJsonDynamicParamFromJson( Map _$SimpleClassOfFromJsonDynamicParamToJson( SimpleClassOfFromJsonDynamicParam instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -682,7 +682,7 @@ Map _$SimpleClassNullableOfFromJsonDynamicParamToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -704,7 +704,7 @@ SimpleClassOfFromJsonNullableObjectParam Map _$SimpleClassOfFromJsonNullableObjectParamToJson( SimpleClassOfFromJsonNullableObjectParam instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -728,7 +728,7 @@ Map _$SimpleClassNullableOfFromJsonNullableObjectParamToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -749,7 +749,7 @@ SimpleClassOfFromJsonObjectParam _$SimpleClassOfFromJsonObjectParamFromJson( Map _$SimpleClassOfFromJsonObjectParamToJson( SimpleClassOfFromJsonObjectParam instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -774,7 +774,7 @@ Map _$SimpleClassNullableOfFromJsonObjectParamToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -793,7 +793,7 @@ SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -816,7 +816,7 @@ Map _$SimpleClassNullableOfIntToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -837,7 +837,7 @@ SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( Map _$SimpleClassOfIntNullableToJson( SimpleClassOfIntNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -860,7 +860,7 @@ Map _$SimpleClassNullableOfIntNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -879,7 +879,7 @@ SimpleClassOfNum _$SimpleClassOfNumFromJson(Map json) => Map _$SimpleClassOfNumToJson(SimpleClassOfNum instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -902,7 +902,7 @@ Map _$SimpleClassNullableOfNumToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -923,7 +923,7 @@ SimpleClassOfNumNullable _$SimpleClassOfNumNullableFromJson( Map _$SimpleClassOfNumNullableToJson( SimpleClassOfNumNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -946,7 +946,7 @@ Map _$SimpleClassNullableOfNumNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -966,7 +966,7 @@ SimpleClassOfObject _$SimpleClassOfObjectFromJson(Map json) => Map _$SimpleClassOfObjectToJson( SimpleClassOfObject instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -989,7 +989,7 @@ Map _$SimpleClassNullableOfObjectToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -1010,7 +1010,7 @@ SimpleClassOfObjectNullable _$SimpleClassOfObjectNullableFromJson( Map _$SimpleClassOfObjectNullableToJson( SimpleClassOfObjectNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -1033,7 +1033,7 @@ Map _$SimpleClassNullableOfObjectNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -1067,13 +1067,13 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => Map _$SimpleClassOfRecordToJson( SimpleClassOfRecord instance) => { - 'value': { - r'$1': { + 'value': { + r'$1': { r'$1': instance.value.$1.$1, r'$2': instance.value.$1.$2, 'truth': instance.value.$1.truth, }, - 'named': { + 'named': { r'$1': instance.value.named.$1, r'$2': instance.value.named.$2, 'truth': instance.value.named.truth, @@ -1112,13 +1112,13 @@ Map _$SimpleClassNullableOfRecordToJson( { 'value': instance.value == null ? null - : { - r'$1': { + : { + r'$1': { r'$1': instance.value!.$1.$1, r'$2': instance.value!.$1.$2, 'truth': instance.value!.$1.truth, }, - 'named': { + 'named': { r'$1': instance.value!.named.$1, r'$2': instance.value!.named.$2, 'truth': instance.value!.named.truth, @@ -1140,7 +1140,7 @@ SimpleClassOfString _$SimpleClassOfStringFromJson(Map json) => Map _$SimpleClassOfStringToJson( SimpleClassOfString instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -1163,7 +1163,7 @@ Map _$SimpleClassNullableOfStringToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -1184,7 +1184,7 @@ SimpleClassOfStringNullable _$SimpleClassOfStringNullableFromJson( Map _$SimpleClassOfStringNullableToJson( SimpleClassOfStringNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1, 'named': instance.value.named, }, @@ -1207,7 +1207,7 @@ Map _$SimpleClassNullableOfStringNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1, 'named': instance.value!.named, }, @@ -1226,7 +1226,7 @@ SimpleClassOfUri _$SimpleClassOfUriFromJson(Map json) => Map _$SimpleClassOfUriToJson(SimpleClassOfUri instance) => { - 'value': { + 'value': { r'$1': instance.value.$1.toString(), 'named': instance.value.named.toString(), }, @@ -1249,7 +1249,7 @@ Map _$SimpleClassNullableOfUriToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1.toString(), 'named': instance.value!.named.toString(), }, @@ -1274,7 +1274,7 @@ SimpleClassOfUriNullable _$SimpleClassOfUriNullableFromJson( Map _$SimpleClassOfUriNullableToJson( SimpleClassOfUriNullable instance) => { - 'value': { + 'value': { r'$1': instance.value.$1?.toString(), 'named': instance.value.named?.toString(), }, @@ -1301,7 +1301,7 @@ Map _$SimpleClassNullableOfUriNullableToJson( { 'value': instance.value == null ? null - : { + : { r'$1': instance.value!.$1?.toString(), 'named': instance.value!.named?.toString(), }, diff --git a/json_serializable/test/supported_types/input.type_set.g.dart b/json_serializable/test/supported_types/input.type_set.g.dart index 861b0c4fe..73866adf9 100644 --- a/json_serializable/test/supported_types/input.type_set.g.dart +++ b/json_serializable/test/supported_types/input.type_set.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_set.dart'; @@ -637,7 +637,7 @@ Map _$SimpleClassOfRecordToJson( SimpleClassOfRecord instance) => { 'value': instance.value - .map((e) => { + .map((e) => { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, @@ -670,7 +670,7 @@ Map _$SimpleClassNullableOfRecordToJson( SimpleClassNullableOfRecord instance) => { 'value': instance.value - ?.map((e) => { + ?.map((e) => { r'$1': e.$1, r'$2': e.$2, 'truth': e.truth, diff --git a/json_serializable/test/supported_types/input.type_string.g.dart b/json_serializable/test/supported_types/input.type_string.g.dart index 4b1c64a20..6db4a402d 100644 --- a/json_serializable/test/supported_types/input.type_string.g.dart +++ b/json_serializable/test/supported_types/input.type_string.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_string.dart'; diff --git a/json_serializable/test/supported_types/input.type_uri.g.dart b/json_serializable/test/supported_types/input.type_uri.g.dart index e224f7036..b13890e87 100644 --- a/json_serializable/test/supported_types/input.type_uri.g.dart +++ b/json_serializable/test/supported_types/input.type_uri.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'input.type_uri.dart'; diff --git a/json_serializable/tool/readme/readme_examples.g.dart b/json_serializable/tool/readme/readme_examples.g.dart index be265dd6d..c22e9025b 100644 --- a/json_serializable/tool/readme/readme_examples.g.dart +++ b/json_serializable/tool/readme/readme_examples.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal part of 'readme_examples.dart'; diff --git a/json_serializable/tool/test_builder.dart b/json_serializable/tool/test_builder.dart index a0926b098..c2e5379b0 100644 --- a/json_serializable/tool/test_builder.dart +++ b/json_serializable/tool/test_builder.dart @@ -21,8 +21,7 @@ class _TestBuilder implements Builder { final sourceContent = await buildStep.readAsString(buildStep.inputId); - final factories = - SplayTreeMap.from({'$_kitchenSinkBaseName.dart': 'normal'}); + final factories = SplayTreeMap.of({'$_kitchenSinkBaseName.dart': 'normal'}); for (var config in _fileConfigurationMap[baseName]!) { final extension = _configToExtension(config); diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index c52b9527e..6cb35af92 100644 --- a/shared_test/pubspec.yaml +++ b/shared_test/pubspec.yaml @@ -8,4 +8,4 @@ dependencies: test: ^1.6.0 dev_dependencies: - dart_flutter_team_lints: ^1.0.0 + dart_flutter_team_lints: ^2.0.0 From f7cb51662b21d11b3fdb6c5e0fdd46431cec59d4 Mon Sep 17 00:00:00 2001 From: Lasindu Weerasinghe Date: Sun, 29 Oct 2023 03:13:06 +0530 Subject: [PATCH 14/42] flutter pub run notice removed (#1364) --- example/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/example/README.md b/example/README.md index 65fc28f59..bb6cf3c79 100644 --- a/example/README.md +++ b/example/README.md @@ -32,9 +32,6 @@ Run `dart run build_runner build` to generate files into your source directory. [INFO] Build: Succeeded after 4687ms with 1 outputs ``` -_NOTE_: If you're using Flutter, replace `dart run` with -`flutter pub run`. - [example]: lib/example.dart [example_g]: lib/example.g.dart [json_annotation]: https://pub.dev/packages/json_annotation From a072c014ae7bd652926d4ee73fa1fb4cabd8a4b4 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 20 Dec 2023 10:03:58 -0800 Subject: [PATCH 15/42] blast_repo fixes (#1383) no-response --- .github/workflows/no-response.yml | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index 599c7c209..d60d9fa7f 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -1,12 +1,10 @@ # A workflow to close issues where the author hasn't responded to a request for -# more information; see https://github.com/godofredoc/no-response for docs. +# more information; see https://github.com/actions/stale. name: No Response -# Both `issue_comment` and `scheduled` event types are required. +# Run as a daily cron. on: - issue_comment: - types: [created] schedule: # Every day at 8am - cron: '0 8 * * *' @@ -14,20 +12,26 @@ on: # All permissions not specified are set to 'none'. permissions: issues: write + pull-requests: write jobs: - noResponse: + no-response: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'google' }} steps: - - uses: godofredoc/no-response@0ce2dc0e63e1c7d2b87752ceed091f6d32c9df09 - with: - responseRequiredLabel: "State: needs info" - daysUntilClose: 14 - # Comment to post when closing an Issue for lack of response. - closeComment: > - Without additional information we're not able to resolve this - issue, so it will be closed at this time. You're still free to add - more info and respond to any questions above, though. We'll reopen - the case if you do. Thanks for your contribution! - token: ${{ github.token }} + - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 + with: + # Don't automatically mark inactive issues+PRs as stale. + days-before-stale: -1 + # Close needs-info issues and PRs after 14 days of inactivity. + days-before-close: 14 + stale-issue-label: "needs-info" + close-issue-message: > + Without additional information we're not able to resolve this issue. + Feel free to add more info or respond to any questions above and we + can reopen the case. Thanks for your contribution! + stale-pr-label: "needs-info" + close-pr-message: > + Without additional information we're not able to resolve this PR. + Feel free to add more info or respond to any questions above. + Thanks for your contribution! From ce2de93a1749088ebbb97e5550fdb91e2b510715 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:16:59 -0800 Subject: [PATCH 16/42] Bump actions/stale from 8.0.0 to 9.0.0 (#1387) Bumps [actions/stale](https://github.com/actions/stale) from 8.0.0 to 9.0.0. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/1160a2240286f5da8ec72b1c0816ce2481aabf84...28ca1036281a5e5922ead5184a1bbf96e5fc984e) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/no-response.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/no-response.yml b/.github/workflows/no-response.yml index d60d9fa7f..9cd84a5d2 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/no-response.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'google' }} steps: - - uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 + - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e with: # Don't automatically mark inactive issues+PRs as stale. days-before-stale: -1 From ac8b94176468416a3fe00e5a1e24fba05823137e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:17:20 -0800 Subject: [PATCH 17/42] Bump actions/setup-node from 3.8.1 to 4.0.1 (#1386) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.8.1 to 4.0.1. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d...b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/markdown_linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index b6243be61..0b313ee1f 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d + uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 with: node-version: ${{ matrix.node-version }} - name: Install dependencies From 71621345d687fb879539e0af86a4fdfad6c81980 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:27:59 -0800 Subject: [PATCH 18/42] Bump actions/checkout from 4.1.0 to 4.1.1 (#1366) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8ade135a41bc03ea155e62e844d188df1ea18608...b4ffde65f46336ab88eb53be808477a3936bae11) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- .github/workflows/markdown_linter.yml | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 8311a9857..fcfcc05f1 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -34,7 +34,7 @@ jobs: sdk: stable - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: mono_repo self validate run: dart pub global activate mono_repo 6.5.7 - name: mono_repo self validate @@ -59,7 +59,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -125,7 +125,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -211,7 +211,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -272,7 +272,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -306,7 +306,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -340,7 +340,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -374,7 +374,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -435,7 +435,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -469,7 +469,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -503,7 +503,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -537,7 +537,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -597,7 +597,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 0b313ee1f..0ab645c93 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -11,7 +11,7 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: gaurav-nelson/github-action-markdown-link-check@v1 markdown_lint: runs-on: ubuntu-latest @@ -19,7 +19,7 @@ jobs: matrix: node-version: [ 14.x ] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 with: From 7f1c19290e25321571d21e4001d3af0da1fbbd42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:28:23 -0800 Subject: [PATCH 19/42] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#1367) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/8a4b97ea2017cc079571daec46542f76189836b1...b64355ae6ca0b5d484f0106a033dd1388965d06d) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index fcfcc05f1..674fc83fc 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -29,7 +29,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: stable - id: checkout @@ -54,7 +54,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: "3.0.0" - id: checkout @@ -120,7 +120,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev - id: checkout @@ -206,7 +206,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: "3.0.0" - id: checkout @@ -267,7 +267,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: "3.0.0" - id: checkout @@ -301,7 +301,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: "3.0.0" - id: checkout @@ -335,7 +335,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: "3.0.0" - id: checkout @@ -369,7 +369,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev - id: checkout @@ -430,7 +430,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev - id: checkout @@ -464,7 +464,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev - id: checkout @@ -498,7 +498,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev - id: checkout @@ -532,7 +532,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: "3.0.0" - id: checkout @@ -592,7 +592,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: dev - id: checkout From 84e3c2ab25469d49a7c91f2ca427702b506117d9 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 15 Jan 2024 13:39:53 -0800 Subject: [PATCH 20/42] CI: fix markdown lint (#1389) --- .github/workflows/markdown_linter.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 0ab645c93..3d3431175 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -15,16 +15,6 @@ jobs: - uses: gaurav-nelson/github-action-markdown-link-check@v1 markdown_lint: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [ 14.x ] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 - with: - node-version: ${{ matrix.node-version }} - - name: Install dependencies - run: npm install --global markdownlint-cli2 - - name: Run lint check - run: markdownlint-cli2-fix "**/*.md" + - uses: DavidAnson/markdownlint-cli2-action@v9 From e9527ee1a984afdeeba79579efb983bfd84e6694 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 15 Jan 2024 15:06:47 -0800 Subject: [PATCH 21/42] blast_repo fixes (#1390) auto-publish, dependabot, github-actions, no-response --- .github/dependabot.yml | 8 +++-- .github/workflows/dart.yml | 52 +++++++++++++-------------- .github/workflows/markdown_linter.yml | 4 +-- .github/workflows/publish.yaml | 3 ++ 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2a0f49229..f4169fa24 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,7 +4,9 @@ version: 2 updates: -- package-ecosystem: "github-actions" - directory: "/" +- package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly + labels: + - autosubmit diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 674fc83fc..abfef05fa 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable" @@ -29,7 +29,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: stable - id: checkout @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" @@ -54,7 +54,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: "3.0.0" - id: checkout @@ -110,7 +110,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:format-analyze_0" @@ -120,7 +120,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: dev - id: checkout @@ -196,7 +196,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -206,7 +206,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: "3.0.0" - id: checkout @@ -257,7 +257,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_3" @@ -267,7 +267,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: "3.0.0" - id: checkout @@ -291,7 +291,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_1" @@ -301,7 +301,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: "3.0.0" - id: checkout @@ -325,7 +325,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_2" @@ -335,7 +335,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: "3.0.0" - id: checkout @@ -359,7 +359,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -369,7 +369,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: dev - id: checkout @@ -420,7 +420,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_3" @@ -430,7 +430,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: dev - id: checkout @@ -454,7 +454,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_1" @@ -464,7 +464,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: dev - id: checkout @@ -488,7 +488,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_2" @@ -498,7 +498,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: dev - id: checkout @@ -522,7 +522,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" @@ -532,7 +532,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: "3.0.0" - id: checkout @@ -582,7 +582,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example;commands:test_1" @@ -592,7 +592,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b with: sdk: dev - id: checkout diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 3d3431175..15f176ba1 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -12,9 +12,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: gaurav-nelson/github-action-markdown-link-check@v1 + - uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 markdown_lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: DavidAnson/markdownlint-cli2-action@v9 + - uses: DavidAnson/markdownlint-cli2-action@455b6612a7b7a80f28be9e019b70abdd11696e4e diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 8c8f07d14..afff618d2 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -12,3 +12,6 @@ jobs: publish: if: ${{ github.repository_owner == 'google' }} uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main + permissions: + id-token: write # Required for authentication using OIDC + pull-requests: write # Required for writing the pull request note From 28f7c9a6909934a8c225889432cd084cefc6c6cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:17:17 -0800 Subject: [PATCH 22/42] Bump actions/cache from 3.3.3 to 4.0.0 (#1397) Bumps [actions/cache](https://github.com/actions/cache) from 3.3.3 to 4.0.0. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/e12d46a63a90f2fae62d114769bbf2a179198b5c...13aacd865c20de90d75de3b17ebe84f7a17d57d2) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index abfef05fa..99da436cf 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable" @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" @@ -110,7 +110,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:format-analyze_0" @@ -196,7 +196,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -257,7 +257,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_3" @@ -291,7 +291,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_1" @@ -325,7 +325,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_2" @@ -359,7 +359,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -420,7 +420,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_3" @@ -454,7 +454,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_1" @@ -488,7 +488,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_2" @@ -522,7 +522,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" @@ -582,7 +582,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c + uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example;commands:test_1" From 3a833d983ab4e158ad435346bfaa8396c0f58e1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:27:44 -0800 Subject: [PATCH 23/42] Bump DavidAnson/markdownlint-cli2-action from 14.0.0 to 15.0.0 (#1395) Bumps [DavidAnson/markdownlint-cli2-action](https://github.com/davidanson/markdownlint-cli2-action) from 14.0.0 to 15.0.0. - [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases) - [Commits](https://github.com/davidanson/markdownlint-cli2-action/compare/455b6612a7b7a80f28be9e019b70abdd11696e4e...510b996878fc0d1a46c8a04ec86b06dbfba09de7) --- updated-dependencies: - dependency-name: DavidAnson/markdownlint-cli2-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/markdown_linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 15f176ba1..f7bab67dc 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -17,4 +17,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: DavidAnson/markdownlint-cli2-action@455b6612a7b7a80f28be9e019b70abdd11696e4e + - uses: DavidAnson/markdownlint-cli2-action@510b996878fc0d1a46c8a04ec86b06dbfba09de7 From 24a830c32f5a54c22f52bb207d70c4f6cbd9179c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:27:50 -0800 Subject: [PATCH 24/42] Bump dart-lang/setup-dart from 1.6.1 to 1.6.2 (#1396) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.1 to 1.6.2. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b...fedb1266e91cf51be2fdb382869461a434b920a3) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 99da436cf..ab3c13d9b 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -29,7 +29,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: stable - id: checkout @@ -54,7 +54,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: "3.0.0" - id: checkout @@ -120,7 +120,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: dev - id: checkout @@ -206,7 +206,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: "3.0.0" - id: checkout @@ -267,7 +267,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: "3.0.0" - id: checkout @@ -301,7 +301,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: "3.0.0" - id: checkout @@ -335,7 +335,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: "3.0.0" - id: checkout @@ -369,7 +369,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: dev - id: checkout @@ -430,7 +430,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: dev - id: checkout @@ -464,7 +464,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: dev - id: checkout @@ -498,7 +498,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: dev - id: checkout @@ -532,7 +532,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: "3.0.0" - id: checkout @@ -592,7 +592,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@ca7e6fee45ffbd82b555a7ebfc236d2c86439f5b + uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: dev - id: checkout From 324acee3c6a3cdfda9d1d797daf8cdc01793a862 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 11:42:41 -0800 Subject: [PATCH 25/42] Bump actions/cache from 4.0.0 to 4.0.1 (#1404) Bumps [actions/cache](https://github.com/actions/cache) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/13aacd865c20de90d75de3b17ebe84f7a17d57d2...ab5e6d0c87105b4c9c2047343972218f562e4319) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index ab3c13d9b..09c4122c2 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable" @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" @@ -110,7 +110,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:format-analyze_0" @@ -196,7 +196,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -257,7 +257,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_3" @@ -291,7 +291,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_1" @@ -325,7 +325,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_2" @@ -359,7 +359,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -420,7 +420,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_3" @@ -454,7 +454,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_1" @@ -488,7 +488,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_2" @@ -522,7 +522,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" @@ -582,7 +582,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 + uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example;commands:test_1" From 5b46ef9d17b94c64d002b00ddb2908a3714159af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sym=C3=A9on=20ROUGEVIN-B=C3=82VILLE?= <61052165+ChreSyr@users.noreply.github.com> Date: Sun, 3 Mar 2024 01:22:18 +0100 Subject: [PATCH 26/42] Added createJsonKeys (#1401) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/google/json_serializable.dart/issues/1400 Co-authored-by: Syméon ROUGEVIN Co-authored-by: Kevin Moore --- json_annotation/CHANGELOG.md | 4 ++- .../lib/src/json_serializable.dart | 16 ++++++++++ .../lib/src/json_serializable.g.dart | 5 +++ json_annotation/pubspec.yaml | 2 +- json_serializable/CHANGELOG.md | 4 ++- json_serializable/README.md | 19 +++++------ json_serializable/lib/src/encoder_helper.dart | 22 +++++++++++++ .../lib/src/generator_helper.dart | 4 +++ .../lib/src/type_helpers/config_types.dart | 6 ++++ json_serializable/lib/src/utils.dart | 2 ++ json_serializable/pubspec.yaml | 6 +++- json_serializable/test/config_test.dart | 1 + .../test/integration/integration_test.dart | 5 +++ .../test/integration/json_keys_example.dart | 32 +++++++++++++++++++ .../test/integration/json_keys_example.g.dart | 24 ++++++++++++++ json_serializable/test/shared_config.dart | 1 + .../test/test_sources/test_sources.dart | 1 + .../tool/readme/readme_template.md | 1 + 18 files changed, 142 insertions(+), 13 deletions(-) create mode 100644 json_serializable/test/integration/json_keys_example.dart create mode 100644 json_serializable/test/integration/json_keys_example.g.dart diff --git a/json_annotation/CHANGELOG.md b/json_annotation/CHANGELOG.md index 5929a6840..1b3d6be21 100644 --- a/json_annotation/CHANGELOG.md +++ b/json_annotation/CHANGELOG.md @@ -1,6 +1,8 @@ -## 4.8.2-wip +## 4.9.0-wip - Require Dart 3.0 +- Added `JsonSerializable(createJsonKeys: true)`. + ([#1401](https://github.com/google/json_serializable.dart/pull/1401)) ## 4.8.1 diff --git a/json_annotation/lib/src/json_serializable.dart b/json_annotation/lib/src/json_serializable.dart index 71a6e4550..fe9b5cc98 100644 --- a/json_annotation/lib/src/json_serializable.dart +++ b/json_annotation/lib/src/json_serializable.dart @@ -87,6 +87,21 @@ class JsonSerializable { /// such as [fieldRename]. final bool? createFieldMap; + /// If `true` (defaults to false), a private class `_$ExampleJsonKeys` + /// constant is created in the generated part file. + /// + /// This class will contain every property, with the json key as value, + /// exposing a secured way to access the json key from the property. + /// + /// ```dart + /// @JsonSerializable(createJsonKeys: true) + /// class Example { + /// // ... + /// static const jsonKeys = _$PublicationImplJsonKeys(); + /// } + /// ``` + final bool? createJsonKeys; + /// If `true` (defaults to false), a private, static `_$ExamplePerFieldToJson` /// abstract class will be generated in the part file. /// @@ -247,6 +262,7 @@ class JsonSerializable { this.checked, this.constructor, this.createFieldMap, + this.createJsonKeys, this.createFactory, this.createToJson, this.disallowUnrecognizedKeys, diff --git a/json_annotation/lib/src/json_serializable.g.dart b/json_annotation/lib/src/json_serializable.g.dart index 9d02a187c..80614717e 100644 --- a/json_annotation/lib/src/json_serializable.g.dart +++ b/json_annotation/lib/src/json_serializable.g.dart @@ -19,6 +19,7 @@ JsonSerializable _$JsonSerializableFromJson(Map json) => 'constructor', 'create_factory', 'create_field_map', + 'create_json_keys', 'create_per_field_to_json', 'create_to_json', 'disallow_unrecognized_keys', @@ -35,6 +36,8 @@ JsonSerializable _$JsonSerializableFromJson(Map json) => constructor: $checkedConvert('constructor', (v) => v as String?), createFieldMap: $checkedConvert('create_field_map', (v) => v as bool?), + createJsonKeys: + $checkedConvert('create_json_keys', (v) => v as bool?), createFactory: $checkedConvert('create_factory', (v) => v as bool?), createToJson: $checkedConvert('create_to_json', (v) => v as bool?), disallowUnrecognizedKeys: @@ -56,6 +59,7 @@ JsonSerializable _$JsonSerializableFromJson(Map json) => fieldKeyMap: const { 'anyMap': 'any_map', 'createFieldMap': 'create_field_map', + 'createJsonKeys': 'create_json_keys', 'createFactory': 'create_factory', 'createToJson': 'create_to_json', 'disallowUnrecognizedKeys': 'disallow_unrecognized_keys', @@ -75,6 +79,7 @@ Map _$JsonSerializableToJson(JsonSerializable instance) => 'constructor': instance.constructor, 'create_factory': instance.createFactory, 'create_field_map': instance.createFieldMap, + 'create_json_keys': instance.createJsonKeys, 'create_per_field_to_json': instance.createPerFieldToJson, 'create_to_json': instance.createToJson, 'disallow_unrecognized_keys': instance.disallowUnrecognizedKeys, diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index a6b97a231..aabbd9681 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -1,5 +1,5 @@ name: json_annotation -version: 4.8.2-wip +version: 4.9.0-wip description: >- Classes and helper functions that support JSON code generation via the `json_serializable` package. diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 0d36ca8af..845d563b2 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,6 +1,8 @@ -## 6.7.2-wip +## 6.8.0-wip - Add type arguments to `Map` literals used for `Record` serialization. +- Added support for generating `ExampleJsonKeys`, exposing a secured way to access the json keys from the properties. + ([#1164](https://github.com/google/json_serializable.dart/pull/1164)) ## 6.7.1 diff --git a/json_serializable/README.md b/json_serializable/README.md index cb1eec619..5d30efd16 100644 --- a/json_serializable/README.md +++ b/json_serializable/README.md @@ -276,6 +276,7 @@ targets: constructor: "" create_factory: true create_field_map: false + create_json_keys: false create_per_field_to_json: false create_to_json: true disallow_unrecognized_keys: false @@ -297,15 +298,15 @@ targets: [`Enum`]: https://api.dart.dev/stable/dart-core/Enum-class.html [`int`]: https://api.dart.dev/stable/dart-core/int-class.html [`Iterable`]: https://api.dart.dev/stable/dart-core/Iterable-class.html -[`JsonConverter`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonConverter-class.html -[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonEnum/valueField.html -[`JsonEnum`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonEnum-class.html -[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonKey/fromJson.html -[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonKey/toJson.html -[`JsonKey`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonKey-class.html -[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonLiteral-class.html -[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonSerializable-class.html -[`JsonValue`]: https://pub.dev/documentation/json_annotation/4.8.1/json_annotation/JsonValue-class.html +[`JsonConverter`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html +[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum/valueField.html +[`JsonEnum`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum-class.html +[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html +[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html +[`JsonKey`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey-class.html +[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonLiteral-class.html +[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonSerializable-class.html +[`JsonValue`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonValue-class.html [`List`]: https://api.dart.dev/stable/dart-core/List-class.html [`Map`]: https://api.dart.dev/stable/dart-core/Map-class.html [`num`]: https://api.dart.dev/stable/dart-core/num-class.html diff --git a/json_serializable/lib/src/encoder_helper.dart b/json_serializable/lib/src/encoder_helper.dart index cfc70b3af..05d4c714d 100644 --- a/json_serializable/lib/src/encoder_helper.dart +++ b/json_serializable/lib/src/encoder_helper.dart @@ -63,6 +63,28 @@ mixin EncodeHelper implements HelperCore { return buffer.toString(); } + /// Generates an object containing metadatas related to the encoding, + /// destined to be used by other code-generators. + String createJsonKeys(Set accessibleFieldSet) { + assert(config.createJsonKeys); + + final buffer = StringBuffer( + 'abstract final class _\$${element.name.nonPrivate}JsonKeys {', + ); + // ..write('static const _\$${element.name.nonPrivate}JsonKeys();'); + + for (final field in accessibleFieldSet) { + buffer.writeln( + 'static const String ${field.name} = ' + '${escapeDartString(nameAccess(field))};', + ); + } + + buffer.write('}'); + + return buffer.toString(); + } + Iterable createToJson(Set accessibleFields) sync* { assert(config.createToJson); diff --git a/json_serializable/lib/src/generator_helper.dart b/json_serializable/lib/src/generator_helper.dart index 501df9469..8c0e13b4a 100644 --- a/json_serializable/lib/src/generator_helper.dart +++ b/json_serializable/lib/src/generator_helper.dart @@ -132,6 +132,10 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper { yield createFieldMap(accessibleFieldSet); } + if (config.createJsonKeys) { + yield createJsonKeys(accessibleFieldSet); + } + if (config.createPerFieldToJson) { yield createPerFieldToJson(accessibleFieldSet); } diff --git a/json_serializable/lib/src/type_helpers/config_types.dart b/json_serializable/lib/src/type_helpers/config_types.dart index c4bdc260a..227f1890b 100644 --- a/json_serializable/lib/src/type_helpers/config_types.dart +++ b/json_serializable/lib/src/type_helpers/config_types.dart @@ -49,6 +49,7 @@ class ClassConfig { final bool createFactory; final bool createToJson; final bool createFieldMap; + final bool createJsonKeys; final bool createPerFieldToJson; final bool disallowUnrecognizedKeys; final bool explicitToJson; @@ -66,6 +67,7 @@ class ClassConfig { required this.createFactory, required this.createToJson, required this.createFieldMap, + required this.createJsonKeys, required this.createPerFieldToJson, required this.disallowUnrecognizedKeys, required this.explicitToJson, @@ -85,6 +87,8 @@ class ClassConfig { constructor: config.constructor ?? ClassConfig.defaults.constructor, createFieldMap: config.createFieldMap ?? ClassConfig.defaults.createFieldMap, + createJsonKeys: + config.createJsonKeys ?? ClassConfig.defaults.createJsonKeys, createPerFieldToJson: config.createPerFieldToJson ?? ClassConfig.defaults.createPerFieldToJson, createFactory: @@ -113,6 +117,7 @@ class ClassConfig { createFactory: true, createToJson: true, createFieldMap: false, + createJsonKeys: false, createPerFieldToJson: false, disallowUnrecognizedKeys: false, explicitToJson: false, @@ -129,6 +134,7 @@ class ClassConfig { createFactory: createFactory, createToJson: createToJson, createFieldMap: createFieldMap, + createJsonKeys: createJsonKeys, createPerFieldToJson: createPerFieldToJson, ignoreUnannotated: ignoreUnannotated, explicitToJson: explicitToJson, diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index c8c727f7d..c74cda361 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -58,6 +58,7 @@ JsonSerializable _valueForAnnotation(ConstantReader reader) => JsonSerializable( createFactory: reader.read('createFactory').literalValue as bool?, createToJson: reader.read('createToJson').literalValue as bool?, createFieldMap: reader.read('createFieldMap').literalValue as bool?, + createJsonKeys: reader.read('createJsonKeys').literalValue as bool?, createPerFieldToJson: reader.read('createPerFieldToJson').literalValue as bool?, disallowUnrecognizedKeys: @@ -106,6 +107,7 @@ ClassConfig mergeConfig( createFactory: annotation.createFactory ?? config.createFactory, createToJson: annotation.createToJson ?? config.createToJson, createFieldMap: annotation.createFieldMap ?? config.createFieldMap, + createJsonKeys: annotation.createJsonKeys ?? config.createJsonKeys, createPerFieldToJson: annotation.createPerFieldToJson ?? config.createPerFieldToJson, disallowUnrecognizedKeys: diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 8f55a01f0..307e1f76c 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -1,5 +1,5 @@ name: json_serializable -version: 6.7.2-wip +version: 6.8.0-wip description: >- Automatically generate code for converting to and from JSON by annotating Dart classes. @@ -29,6 +29,10 @@ dependencies: source_gen: ^1.3.2 source_helper: ^1.3.0 +dependency_overrides: + json_annotation: + path: ../json_annotation + dev_dependencies: _json_serial_shared_test: path: ../shared_test diff --git a/json_serializable/test/config_test.dart b/json_serializable/test/config_test.dart index 15767a319..2bcaa242a 100644 --- a/json_serializable/test/config_test.dart +++ b/json_serializable/test/config_test.dart @@ -153,6 +153,7 @@ const _invalidConfig = { 'constructor': 42, 'create_factory': 42, 'create_field_map': 42, + 'create_json_keys': 42, 'create_per_field_to_json': 42, 'create_to_json': 42, 'disallow_unrecognized_keys': 42, diff --git a/json_serializable/test/integration/integration_test.dart b/json_serializable/test/integration/integration_test.dart index 9305b4f9b..8c5827ee8 100644 --- a/json_serializable/test/integration/integration_test.dart +++ b/json_serializable/test/integration/integration_test.dart @@ -10,6 +10,7 @@ import 'converter_examples.dart'; import 'create_per_field_to_json_example.dart'; import 'field_map_example.dart'; import 'json_enum_example.dart'; +import 'json_keys_example.dart' as js_keys; import 'json_test_common.dart' show Category, Platform, StatusCode; import 'json_test_example.dart'; @@ -471,4 +472,8 @@ void main() { test('value field index fun', () { expect(enumValueFieldIndexValues, [0, 701, 2]); }); + + test('ModelJsonKeys', () { + expect(js_keys.keys, {'first-name', 'LAST_NAME'}); + }); } diff --git a/json_serializable/test/integration/json_keys_example.dart b/json_serializable/test/integration/json_keys_example.dart new file mode 100644 index 000000000..e8a6895a2 --- /dev/null +++ b/json_serializable/test/integration/json_keys_example.dart @@ -0,0 +1,32 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'json_keys_example.g.dart'; + +@JsonSerializable(createJsonKeys: true, fieldRename: FieldRename.kebab) +class Model { + Model({ + required this.firstName, + required this.lastName, + this.ignoredName, + }); + + factory Model.fromJson(Map json) => _$ModelFromJson(json); + + final String firstName; + + @JsonKey(name: 'LAST_NAME') + final String lastName; + + @JsonKey(includeFromJson: false, includeToJson: false) + final String? ignoredName; + + String get fullName => '$firstName $lastName'; + + Map toJson() => _$ModelToJson(this); +} + +// TODO: use this once https://github.com/dart-lang/sdk/issues/54543 is fixed +typedef ModelJsonKeys = _$ModelJsonKeys; + +// Work-around until https://github.com/dart-lang/sdk/issues/54543 is fixed +Set get keys => {_$ModelJsonKeys.firstName, _$ModelJsonKeys.lastName}; diff --git a/json_serializable/test/integration/json_keys_example.g.dart b/json_serializable/test/integration/json_keys_example.g.dart new file mode 100644 index 000000000..f68ca8d09 --- /dev/null +++ b/json_serializable/test/integration/json_keys_example.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: lines_longer_than_80_chars, text_direction_code_point_in_literal, inference_failure_on_function_invocation, inference_failure_on_collection_literal + +part of 'json_keys_example.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Model _$ModelFromJson(Map json) => Model( + firstName: json['first-name'] as String, + lastName: json['LAST_NAME'] as String, + ); + +abstract final class _$ModelJsonKeys { + static const String firstName = 'first-name'; + static const String lastName = 'LAST_NAME'; +} + +Map _$ModelToJson(Model instance) => { + 'first-name': instance.firstName, + 'LAST_NAME': instance.lastName, + }; diff --git a/json_serializable/test/shared_config.dart b/json_serializable/test/shared_config.dart index 957728da3..fcae4282e 100644 --- a/json_serializable/test/shared_config.dart +++ b/json_serializable/test/shared_config.dart @@ -20,6 +20,7 @@ final generatorConfigNonDefaultJson = createFactory: false, createToJson: false, createFieldMap: true, + createJsonKeys: true, createPerFieldToJson: true, disallowUnrecognizedKeys: true, explicitToJson: true, diff --git a/json_serializable/test/test_sources/test_sources.dart b/json_serializable/test/test_sources/test_sources.dart index 06cc495f3..786931080 100644 --- a/json_serializable/test/test_sources/test_sources.dart +++ b/json_serializable/test/test_sources/test_sources.dart @@ -16,6 +16,7 @@ class ConfigurationImplicitDefaults { createFactory: true, createToJson: true, createFieldMap: false, + createJsonKeys: false, createPerFieldToJson: false, disallowUnrecognizedKeys: false, explicitToJson: false, diff --git a/json_serializable/tool/readme/readme_template.md b/json_serializable/tool/readme/readme_template.md index 79ac1c7dd..c3d6815ab 100644 --- a/json_serializable/tool/readme/readme_template.md +++ b/json_serializable/tool/readme/readme_template.md @@ -141,6 +141,7 @@ targets: constructor: "" create_factory: true create_field_map: false + create_json_keys: false create_per_field_to_json: false create_to_json: true disallow_unrecognized_keys: false From 1bfb616fe6878bae858792d9e03e6ee1085982ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:13:12 -0700 Subject: [PATCH 27/42] Bump actions/cache from 4.0.1 to 4.0.2 (#1411) Bumps [actions/cache](https://github.com/actions/cache) from 4.0.1 to 4.0.2. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/ab5e6d0c87105b4c9c2047343972218f562e4319...0c45773b623bea8c8e75f6c82b208c3cf94ea4f9) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 09c4122c2..4f8a75cf9 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable" @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" @@ -110,7 +110,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:format-analyze_0" @@ -196,7 +196,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -257,7 +257,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_3" @@ -291,7 +291,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_1" @@ -325,7 +325,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_2" @@ -359,7 +359,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" @@ -420,7 +420,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_3" @@ -454,7 +454,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_1" @@ -488,7 +488,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:json_serializable;commands:test_2" @@ -522,7 +522,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" @@ -582,7 +582,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies - uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test_yaml-checked_yaml-example;commands:test_1" From 1694d6f1e3b8e01ca621c9ffb35666389ecbab46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:13:33 -0700 Subject: [PATCH 28/42] Bump actions/checkout from 4.1.1 to 4.1.2 (#1410) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/b4ffde65f46336ab88eb53be808477a3936bae11...9bb56186c3b09b4f86b1c65136769dd318469633) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- .github/workflows/markdown_linter.yml | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 4f8a75cf9..0be82d568 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -34,7 +34,7 @@ jobs: sdk: stable - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: mono_repo self validate run: dart pub global activate mono_repo 6.5.7 - name: mono_repo self validate @@ -59,7 +59,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -125,7 +125,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -211,7 +211,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -272,7 +272,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -306,7 +306,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -340,7 +340,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -374,7 +374,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -435,7 +435,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -469,7 +469,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -503,7 +503,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -537,7 +537,7 @@ jobs: sdk: "3.0.0" - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -597,7 +597,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index f7bab67dc..6cf4457c5 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -11,10 +11,10 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 markdown_lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: DavidAnson/markdownlint-cli2-action@510b996878fc0d1a46c8a04ec86b06dbfba09de7 From dbe976a864c599774e64aaa478aef0f0d44cb8e0 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Wed, 24 Apr 2024 11:38:18 -0700 Subject: [PATCH 29/42] Make casts to int safe in dart2wasm. (#1416) Co-authored-by: Kevin Moore --- _test_yaml/pubspec.yaml | 2 +- _test_yaml/test/src/build_config.g.dart | 4 +- example/lib/example.g.dart | 13 +- .../lib/generic_response_class_example.g.dart | 8 +- example/lib/json_converter_example.g.dart | 10 +- example/lib/tuple_example.g.dart | 8 +- .../lib/src/json_serializable.dart | 2 +- json_serializable/CHANGELOG.md | 5 +- json_serializable/lib/src/lambda_result.dart | 35 ++-- .../lib/src/type_helpers/duration_helper.dart | 2 +- .../lib/src/type_helpers/value_helper.dart | 22 +-- json_serializable/lib/src/utils.dart | 28 +++ .../test/default_value/default_value.g.dart | 10 +- .../default_value.g_any_map__checked.g.dart | 15 +- .../implicit_default_value.g.dart | 10 +- .../field_matrix_test.field_matrix.g.dart | 90 ++++----- .../generic_argument_factories.g.dart | 2 +- ...generic_argument_factories_nullable.g.dart | 2 +- .../test/generic_files/generic_class.dart | 3 + .../test/generic_files/generic_class.g.dart | 6 +- .../test/generic_files/generic_test.dart | 6 +- .../integration/converter_examples.g.dart | 2 +- .../create_per_field_to_json_example.g.dart | 2 +- .../test/integration/integration_test.dart | 15 +- .../test/integration/json_test_common.dart | 5 + .../test/integration/json_test_example.dart | 3 + .../test/integration/json_test_example.g.dart | 35 ++-- .../json_test_example.g_any_map.dart | 3 + .../json_test_example.g_any_map.g.dart | 35 ++-- .../test/kitchen_sink/kitchen_sink.g.dart | 39 ++-- .../kitchen_sink.g_any_map.g.dart | 39 ++-- .../kitchen_sink.g_any_map__checked.g.dart | 51 ++--- .../kitchen_sink.g_exclude_null.g.dart | 39 ++-- .../kitchen_sink.g_explicit_to_json.g.dart | 39 ++-- .../test/kitchen_sink/simple_object.g.dart | 2 +- .../kitchen_sink/strict_keys_object.g.dart | 2 +- .../src/_json_serializable_test_input.dart | 21 ++- .../test/src/default_value_input.dart | 6 +- .../test/src/inheritance_test_input.dart | 8 +- .../test/src/json_converter_test_input.dart | 22 +-- .../test/src/map_key_variety_test_input.dart | 2 +- .../test/src/to_from_json_test_input.dart | 2 +- .../test/supported_types/enum_type.dart | 6 +- .../input.type_duration.g.dart | 4 +- .../supported_types/input.type_int.g.dart | 8 +- .../input.type_iterable.g.dart | 24 +-- .../supported_types/input.type_list.g.dart | 28 ++- .../supported_types/input.type_map.g.dart | 178 +++++++++--------- .../supported_types/input.type_record.g.dart | 41 ++-- .../supported_types/input.type_set.g.dart | 24 ++- .../tool/readme/readme_examples.g.dart | 6 +- 51 files changed, 551 insertions(+), 423 deletions(-) diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index f682e6e88..57f7a275b 100644 --- a/_test_yaml/pubspec.yaml +++ b/_test_yaml/pubspec.yaml @@ -11,7 +11,7 @@ dev_dependencies: build_verify: ^3.0.0 checked_yaml: any dart_flutter_team_lints: ^2.0.0 - json_annotation: ^4.7.0 + json_annotation: ^4.8.1 json_serializable: any path: ^1.8.2 test: ^1.6.0 diff --git a/_test_yaml/test/src/build_config.g.dart b/_test_yaml/test/src/build_config.g.dart index 332000dd1..61e578ec4 100644 --- a/_test_yaml/test/src/build_config.g.dart +++ b/_test_yaml/test/src/build_config.g.dart @@ -24,8 +24,8 @@ Config _$ConfigFromJson(Map json) => $checkedCreate( $checkedConvert( 'weights', (v) => val.weights = (v as Map?)?.map( - (k, e) => - MapEntry($enumDecode(_$AutoApplyEnumMap, k), e as int?), + (k, e) => MapEntry( + $enumDecode(_$AutoApplyEnumMap, k), (e as num?)?.toInt()), )); return val; }, diff --git a/example/lib/example.g.dart b/example/lib/example.g.dart index 40e7e4e9c..b4cf7de11 100644 --- a/example/lib/example.g.dart +++ b/example/lib/example.g.dart @@ -39,15 +39,16 @@ Map _$PersonToJson(Person instance) { } Order _$OrderFromJson(Map json) => Order( - Order._dateTimeFromEpochUs(json['date'] as int), + Order._dateTimeFromEpochUs((json['date'] as num).toInt()), ) - ..count = json['count'] as int? - ..itemNumber = json['itemNumber'] as int? + ..count = (json['count'] as num?)?.toInt() + ..itemNumber = (json['itemNumber'] as num?)?.toInt() ..isRushed = json['isRushed'] as bool? ..item = json['item'] == null ? null : Item.fromJson(json['item'] as Map) - ..prepTime = Order._durationFromMilliseconds(json['prep-time'] as int?); + ..prepTime = + Order._durationFromMilliseconds((json['prep-time'] as num?)?.toInt()); Map _$OrderToJson(Order instance) { final val = {}; @@ -68,8 +69,8 @@ Map _$OrderToJson(Order instance) { } Item _$ItemFromJson(Map json) => Item() - ..count = json['count'] as int? - ..itemNumber = json['itemNumber'] as int? + ..count = (json['count'] as num?)?.toInt() + ..itemNumber = (json['itemNumber'] as num?)?.toInt() ..isRushed = json['isRushed'] as bool?; Map _$ItemToJson(Item instance) => { diff --git a/example/lib/generic_response_class_example.g.dart b/example/lib/generic_response_class_example.g.dart index 6b2e9325a..e61f09efc 100644 --- a/example/lib/generic_response_class_example.g.dart +++ b/example/lib/generic_response_class_example.g.dart @@ -8,13 +8,13 @@ part of 'generic_response_class_example.dart'; BaseResponse _$BaseResponseFromJson(Map json) => BaseResponse( - status: json['status'] as int?, + status: (json['status'] as num?)?.toInt(), msg: json['msg'] as String?, data: BaseResponse._dataFromJson(json['data'] as Object), ); Article _$ArticleFromJson(Map json) => Article( - id: json['id'] as int, + id: (json['id'] as num).toInt(), title: json['title'] as String, author: json['author'] == null ? null @@ -25,11 +25,11 @@ Article _$ArticleFromJson(Map json) => Article( ); User _$UserFromJson(Map json) => User( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), email: json['email'] as String?, ); Comment _$CommentFromJson(Map json) => Comment( - id: json['id'] as int?, + id: (json['id'] as num?)?.toInt(), content: json['content'] as String?, ); diff --git a/example/lib/json_converter_example.g.dart b/example/lib/json_converter_example.g.dart index 526177be7..01b2e46f5 100644 --- a/example/lib/json_converter_example.g.dart +++ b/example/lib/json_converter_example.g.dart @@ -8,7 +8,7 @@ part of 'json_converter_example.dart'; DateTimeExample _$DateTimeExampleFromJson(Map json) => DateTimeExample( - const _DateTimeEpochConverter().fromJson(json['when'] as int), + const _DateTimeEpochConverter().fromJson((json['when'] as num).toInt()), ); Map _$DateTimeExampleToJson(DateTimeExample instance) => @@ -19,9 +19,9 @@ Map _$DateTimeExampleToJson(DateTimeExample instance) => GenericCollection _$GenericCollectionFromJson( Map json) => GenericCollection( - page: json['page'] as int?, - totalResults: json['total_results'] as int?, - totalPages: json['total_pages'] as int?, + page: (json['page'] as num?)?.toInt(), + totalResults: (json['total_results'] as num?)?.toInt(), + totalPages: (json['total_pages'] as num?)?.toInt(), results: (json['results'] as List?) ?.map(_Converter().fromJson) .toList(), @@ -38,7 +38,7 @@ Map _$GenericCollectionToJson( CustomResult _$CustomResultFromJson(Map json) => CustomResult( json['name'] as String, - json['size'] as int, + (json['size'] as num).toInt(), ); Map _$CustomResultToJson(CustomResult instance) => diff --git a/example/lib/tuple_example.g.dart b/example/lib/tuple_example.g.dart index e90d91a1d..f4a537901 100644 --- a/example/lib/tuple_example.g.dart +++ b/example/lib/tuple_example.g.dart @@ -28,11 +28,13 @@ Map _$TupleToJson( ConcreteClass _$ConcreteClassFromJson(Map json) => ConcreteClass( - Tuple.fromJson(json['tuple1'] as Map, - (value) => value as int, (value) => DateTime.parse(value as String)), + Tuple.fromJson( + json['tuple1'] as Map, + (value) => (value as num).toInt(), + (value) => DateTime.parse(value as String)), Tuple.fromJson( json['tuple2'] as Map, - (value) => Duration(microseconds: value as int), + (value) => Duration(microseconds: (value as num).toInt()), (value) => BigInt.parse(value as String)), ); diff --git a/json_annotation/lib/src/json_serializable.dart b/json_annotation/lib/src/json_serializable.dart index fe9b5cc98..91600f097 100644 --- a/json_annotation/lib/src/json_serializable.dart +++ b/json_annotation/lib/src/json_serializable.dart @@ -181,7 +181,7 @@ class JsonSerializable { /// T Function(Object json) fromJsonT, /// ) { /// return Response() - /// ..status = json['status'] as int + /// ..status = (json['status'] as num).toInt() /// ..value = fromJsonT(json['value']); /// } /// diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 845d563b2..9ae8f098d 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,8 +1,11 @@ ## 6.8.0-wip - Add type arguments to `Map` literals used for `Record` serialization. -- Added support for generating `ExampleJsonKeys`, exposing a secured way to access the json keys from the properties. +- Added support for generating `ExampleJsonKeys`, exposing a secured way to + access the json keys from the properties. ([#1164](https://github.com/google/json_serializable.dart/pull/1164)) +- Handle decoding an `int` value from a `double` literal. + This now matches the behavior of `double` values being encoded as `int`. ## 6.7.1 diff --git a/json_serializable/lib/src/lambda_result.dart b/json_serializable/lib/src/lambda_result.dart index 0531cc20f..c5aa510ff 100644 --- a/json_serializable/lib/src/lambda_result.dart +++ b/json_serializable/lib/src/lambda_result.dart @@ -20,9 +20,8 @@ class LambdaResult { final String lambda; final DartType? asContent; - String get _asContent => asContent == null ? '' : _asStatement(asContent!); - - String get _fullExpression => '$expression$_asContent'; + String get _fullExpression => + asContent != null ? _cast(expression, asContent!) : expression; LambdaResult(this.expression, this.lambda, {this.asContent}); @@ -35,29 +34,35 @@ class LambdaResult { : '($closureArg) => $subField'; } -String _asStatement(DartType type) { - if (type.isLikeDynamic) { - return ''; +String _cast(String expression, DartType targetType) { + if (targetType.isLikeDynamic) { + return expression; } - final nullableSuffix = type.isNullableType ? '?' : ''; + final nullableSuffix = targetType.isNullableType ? '?' : ''; - if (coreIterableTypeChecker.isAssignableFromType(type)) { - final itemType = coreIterableGenericType(type); + if (coreIterableTypeChecker.isAssignableFromType(targetType)) { + final itemType = coreIterableGenericType(targetType); if (itemType.isLikeDynamic) { - return ' as List$nullableSuffix'; + return '$expression as List$nullableSuffix'; } } - if (coreMapTypeChecker.isAssignableFromType(type)) { - final args = type.typeArgumentsOf(coreMapTypeChecker)!; + if (coreMapTypeChecker.isAssignableFromType(targetType)) { + final args = targetType.typeArgumentsOf(coreMapTypeChecker)!; assert(args.length == 2); if (args.every((e) => e.isLikeDynamic)) { - return ' as Map$nullableSuffix'; + return '$expression as Map$nullableSuffix'; } } - final typeCode = typeToCode(type); - return ' as $typeCode'; + final defaultDecodeValue = defaultDecodeLogic(targetType, expression); + + if (defaultDecodeValue != null) { + return defaultDecodeValue; + } + + final typeCode = typeToCode(targetType); + return '$expression as $typeCode'; } diff --git a/json_serializable/lib/src/type_helpers/duration_helper.dart b/json_serializable/lib/src/type_helpers/duration_helper.dart index d45cb4222..6cf4d6bdd 100644 --- a/json_serializable/lib/src/type_helpers/duration_helper.dart +++ b/json_serializable/lib/src/type_helpers/duration_helper.dart @@ -46,7 +46,7 @@ class DurationHelper extends TypeHelper { return DefaultContainer( expression, - 'Duration(microseconds: $expression as int)', + 'Duration(microseconds: ($expression as num).toInt())', ); } } diff --git a/json_serializable/lib/src/type_helpers/value_helper.dart b/json_serializable/lib/src/type_helpers/value_helper.dart index 49f7372f4..d9f8411db 100644 --- a/json_serializable/lib/src/type_helpers/value_helper.dart +++ b/json_serializable/lib/src/type_helpers/value_helper.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analyzer/dart/element/type.dart'; -import 'package:source_helper/source_helper.dart'; import '../shared_checkers.dart'; import '../type_helper.dart'; @@ -35,22 +34,7 @@ class ValueHelper extends TypeHelper { String expression, TypeHelperContext context, bool defaultProvided, - ) { - if (targetType.isDartCoreObject && !targetType.isNullableType) { - final question = defaultProvided ? '?' : ''; - return '$expression as Object$question'; - } else if (targetType.isDartCoreObject || targetType is DynamicType) { - // just return it as-is. We'll hope it's safe. - return expression; - } else if (targetType.isDartCoreDouble) { - final targetTypeNullable = defaultProvided || targetType.isNullableType; - final question = targetTypeNullable ? '?' : ''; - return '($expression as num$question)$question.toDouble()'; - } else if (simpleJsonTypeChecker.isAssignableFromType(targetType)) { - final typeCode = typeToCode(targetType, forceNullable: defaultProvided); - return '$expression as $typeCode'; - } - - return null; - } + ) => + defaultDecodeLogic(targetType, expression, + defaultProvided: defaultProvided); } diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index c74cda361..0bf6dba64 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -9,6 +9,7 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:source_gen/source_gen.dart'; import 'package:source_helper/source_helper.dart'; +import 'shared_checkers.dart'; import 'type_helpers/config_types.dart'; const _jsonKeyChecker = TypeChecker.fromRuntime(JsonKey); @@ -220,6 +221,33 @@ String typeToCode( throw UnimplementedError('(${type.runtimeType}) $type'); } +String? defaultDecodeLogic( + DartType targetType, + String expression, { + bool defaultProvided = false, +}) { + if (targetType.isDartCoreObject && !targetType.isNullableType) { + final question = defaultProvided ? '?' : ''; + return '$expression as Object$question'; + } else if (targetType.isDartCoreObject || targetType is DynamicType) { + // just return it as-is. We'll hope it's safe. + return expression; + } else if (targetType.isDartCoreDouble) { + final targetTypeNullable = defaultProvided || targetType.isNullableType; + final question = targetTypeNullable ? '?' : ''; + return '($expression as num$question)$question.toDouble()'; + } else if (targetType.isDartCoreInt) { + final targetTypeNullable = defaultProvided || targetType.isNullableType; + final question = targetTypeNullable ? '?' : ''; + return '($expression as num$question)$question.toInt()'; + } else if (simpleJsonTypeChecker.isAssignableFromType(targetType)) { + final typeCode = typeToCode(targetType, forceNullable: defaultProvided); + return '$expression as $typeCode'; + } + + return null; +} + extension ExecutableElementExtension on ExecutableElement { /// Returns the name of `this` qualified with the class name if it's a /// [MethodElement]. diff --git a/json_serializable/test/default_value/default_value.g.dart b/json_serializable/test/default_value/default_value.g.dart index 0614284e6..6bc4525d5 100644 --- a/json_serializable/test/default_value/default_value.g.dart +++ b/json_serializable/test/default_value/default_value.g.dart @@ -11,13 +11,13 @@ part of 'default_value.dart'; DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( json['fieldBool'] as bool? ?? true, json['fieldString'] as String? ?? 'string', - json['fieldInt'] as int? ?? 42, + (json['fieldInt'] as num?)?.toInt() ?? 42, (json['fieldDouble'] as num?)?.toDouble() ?? 3.14, json['fieldListEmpty'] as List? ?? [], (json['fieldSetEmpty'] as List?)?.toSet() ?? {}, json['fieldMapEmpty'] as Map? ?? {}, (json['fieldListSimple'] as List?) - ?.map((e) => e as int) + ?.map((e) => (e as num).toInt()) .toList() ?? [1, 2, 3], (json['fieldSetSimple'] as List?) @@ -25,7 +25,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( .toSet() ?? {'entry1', 'entry2'}, (json['fieldMapSimple'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ) ?? {'answer': 42}, (json['fieldMapListString'] as Map?)?.map( @@ -38,7 +38,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( $enumDecodeNullable(_$GreekEnumMap, json['fieldEnum']) ?? Greek.beta, durationField: json['durationField'] == null ? Duration.zero - : Duration(microseconds: json['durationField'] as int), + : Duration(microseconds: (json['durationField'] as num).toInt()), constClass: json['constClass'] == null ? const ConstClass('value') : ConstClass.fromJson(json['constClass'] as Map), @@ -50,7 +50,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => DefaultValue( ? const ConstClass('value') : constClassFromJson(json['valueFromFunction'] as String), intDefaultValueFromFunction: - json['intDefaultValueFromFunction'] as int? ?? + (json['intDefaultValueFromFunction'] as num?)?.toInt() ?? intDefaultValueFunction(), valueFromDefaultValueDefaultConstructor: json['valueFromDefaultValueDefaultConstructor'] == null diff --git a/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart b/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart index 24be86d8a..9ce12321f 100644 --- a/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart +++ b/json_serializable/test/default_value/default_value.g_any_map__checked.g.dart @@ -15,7 +15,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( final val = DefaultValue( $checkedConvert('fieldBool', (v) => v as bool? ?? true), $checkedConvert('fieldString', (v) => v as String? ?? 'string'), - $checkedConvert('fieldInt', (v) => v as int? ?? 42), + $checkedConvert('fieldInt', (v) => (v as num?)?.toInt() ?? 42), $checkedConvert( 'fieldDouble', (v) => (v as num?)?.toDouble() ?? 3.14), $checkedConvert('fieldListEmpty', (v) => v as List? ?? []), @@ -25,7 +25,9 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( $checkedConvert( 'fieldListSimple', (v) => - (v as List?)?.map((e) => e as int).toList() ?? + (v as List?) + ?.map((e) => (e as num).toInt()) + .toList() ?? [1, 2, 3]), $checkedConvert( 'fieldSetSimple', @@ -36,7 +38,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( 'fieldMapSimple', (v) => (v as Map?)?.map( - (k, e) => MapEntry(k as String, e as int), + (k, e) => MapEntry(k as String, (e as num).toInt()), ) ?? {'answer': 42}), $checkedConvert( @@ -53,8 +55,9 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( (v) => $enumDecodeNullable(_$GreekEnumMap, v) ?? Greek.beta), durationField: $checkedConvert( 'durationField', - (v) => - v == null ? Duration.zero : Duration(microseconds: v as int)), + (v) => v == null + ? Duration.zero + : Duration(microseconds: (v as num).toInt())), constClass: $checkedConvert( 'constClass', (v) => v == null @@ -72,7 +75,7 @@ DefaultValue _$DefaultValueFromJson(Map json) => $checkedCreate( : constClassFromJson(v as String)), intDefaultValueFromFunction: $checkedConvert( 'intDefaultValueFromFunction', - (v) => v as int? ?? intDefaultValueFunction()), + (v) => (v as num?)?.toInt() ?? intDefaultValueFunction()), valueFromDefaultValueDefaultConstructor: $checkedConvert( 'valueFromDefaultValueDefaultConstructor', (v) => v == null diff --git a/json_serializable/test/default_value/implicit_default_value.g.dart b/json_serializable/test/default_value/implicit_default_value.g.dart index 9bd1f19e0..408c1f0b2 100644 --- a/json_serializable/test/default_value/implicit_default_value.g.dart +++ b/json_serializable/test/default_value/implicit_default_value.g.dart @@ -13,14 +13,14 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( DefaultValueImplicit( fieldBool: json['fieldBool'] as bool? ?? true, fieldString: json['fieldString'] as String? ?? 'string', - fieldInt: json['fieldInt'] as int? ?? 42, + fieldInt: (json['fieldInt'] as num?)?.toInt() ?? 42, fieldDouble: (json['fieldDouble'] as num?)?.toDouble() ?? 3.14, fieldListEmpty: json['fieldListEmpty'] as List? ?? const [], fieldSetEmpty: (json['fieldSetEmpty'] as List?)?.toSet() ?? const {}, fieldMapEmpty: json['fieldMapEmpty'] as Map? ?? const {}, fieldListSimple: (json['fieldListSimple'] as List?) - ?.map((e) => e as int) + ?.map((e) => (e as num).toInt()) .toList() ?? const [1, 2, 3], fieldSetSimple: (json['fieldSetSimple'] as List?) @@ -28,7 +28,7 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( .toSet() ?? const {'entry1', 'entry2'}, fieldMapSimple: (json['fieldMapSimple'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ) ?? const {'answer': 42}, fieldMapListString: @@ -43,7 +43,7 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( $enumDecodeNullable(_$GreekEnumMap, json['fieldEnum']) ?? Greek.beta, durationField: json['durationField'] == null ? const Duration() - : Duration(microseconds: json['durationField'] as int), + : Duration(microseconds: (json['durationField'] as num).toInt()), constClass: json['constClass'] == null ? const ConstClass('value') : ConstClass.fromJson(json['constClass'] as Map), @@ -55,7 +55,7 @@ DefaultValueImplicit _$DefaultValueImplicitFromJson( ? const ConstClass('value') : constClassFromJson(json['valueFromFunction'] as String), intDefaultValueFromFunction: - json['intDefaultValueFromFunction'] as int? ?? 43, + (json['intDefaultValueFromFunction'] as num?)?.toInt() ?? 43, valueFromDefaultValueDefaultConstructor: json['valueFromDefaultValueDefaultConstructor'] == null ? const ConstClass() diff --git a/json_serializable/test/field_matrix_test.field_matrix.g.dart b/json_serializable/test/field_matrix_test.field_matrix.g.dart index 84891ef9a..aa18728ba 100644 --- a/json_serializable/test/field_matrix_test.field_matrix.g.dart +++ b/json_serializable/test/field_matrix_test.field_matrix.g.dart @@ -11,9 +11,9 @@ part of 'field_matrix_test.field_matrix.dart'; ToJsonNullFromJsonNullPublic _$ToJsonNullFromJsonNullPublicFromJson( Map json) => ToJsonNullFromJsonNullPublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonNullPublicToJson( ToJsonNullFromJsonNullPublic instance) => @@ -26,9 +26,9 @@ Map _$ToJsonNullFromJsonNullPublicToJson( ToJsonNullFromJsonTruePublic _$ToJsonNullFromJsonTruePublicFromJson( Map json) => ToJsonNullFromJsonTruePublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonTruePublicToJson( ToJsonNullFromJsonTruePublic instance) => @@ -41,8 +41,8 @@ Map _$ToJsonNullFromJsonTruePublicToJson( ToJsonNullFromJsonFalsePublic _$ToJsonNullFromJsonFalsePublicFromJson( Map json) => ToJsonNullFromJsonFalsePublic() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonFalsePublicToJson( ToJsonNullFromJsonFalsePublic instance) => @@ -54,9 +54,9 @@ Map _$ToJsonNullFromJsonFalsePublicToJson( ToJsonTrueFromJsonNullPublic _$ToJsonTrueFromJsonNullPublicFromJson( Map json) => ToJsonTrueFromJsonNullPublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonNullPublicToJson( ToJsonTrueFromJsonNullPublic instance) => @@ -69,9 +69,9 @@ Map _$ToJsonTrueFromJsonNullPublicToJson( ToJsonTrueFromJsonTruePublic _$ToJsonTrueFromJsonTruePublicFromJson( Map json) => ToJsonTrueFromJsonTruePublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonTruePublicToJson( ToJsonTrueFromJsonTruePublic instance) => @@ -84,8 +84,8 @@ Map _$ToJsonTrueFromJsonTruePublicToJson( ToJsonTrueFromJsonFalsePublic _$ToJsonTrueFromJsonFalsePublicFromJson( Map json) => ToJsonTrueFromJsonFalsePublic() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonFalsePublicToJson( ToJsonTrueFromJsonFalsePublic instance) => @@ -98,9 +98,9 @@ Map _$ToJsonTrueFromJsonFalsePublicToJson( ToJsonFalseFromJsonNullPublic _$ToJsonFalseFromJsonNullPublicFromJson( Map json) => ToJsonFalseFromJsonNullPublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonNullPublicToJson( ToJsonFalseFromJsonNullPublic instance) => @@ -112,9 +112,9 @@ Map _$ToJsonFalseFromJsonNullPublicToJson( ToJsonFalseFromJsonTruePublic _$ToJsonFalseFromJsonTruePublicFromJson( Map json) => ToJsonFalseFromJsonTruePublic() - ..aField = json['aField'] as int? - ..field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonTruePublicToJson( ToJsonFalseFromJsonTruePublic instance) => @@ -126,8 +126,8 @@ Map _$ToJsonFalseFromJsonTruePublicToJson( ToJsonFalseFromJsonFalsePublic _$ToJsonFalseFromJsonFalsePublicFromJson( Map json) => ToJsonFalseFromJsonFalsePublic() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonFalsePublicToJson( ToJsonFalseFromJsonFalsePublic instance) => @@ -139,8 +139,8 @@ Map _$ToJsonFalseFromJsonFalsePublicToJson( ToJsonNullFromJsonNullPrivate _$ToJsonNullFromJsonNullPrivateFromJson( Map json) => ToJsonNullFromJsonNullPrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonNullPrivateToJson( ToJsonNullFromJsonNullPrivate instance) => @@ -152,9 +152,9 @@ Map _$ToJsonNullFromJsonNullPrivateToJson( ToJsonNullFromJsonTruePrivate _$ToJsonNullFromJsonTruePrivateFromJson( Map json) => ToJsonNullFromJsonTruePrivate() - ..aField = json['aField'] as int? - .._field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + .._field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonTruePrivateToJson( ToJsonNullFromJsonTruePrivate instance) => @@ -167,8 +167,8 @@ Map _$ToJsonNullFromJsonTruePrivateToJson( ToJsonNullFromJsonFalsePrivate _$ToJsonNullFromJsonFalsePrivateFromJson( Map json) => ToJsonNullFromJsonFalsePrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonNullFromJsonFalsePrivateToJson( ToJsonNullFromJsonFalsePrivate instance) => @@ -180,8 +180,8 @@ Map _$ToJsonNullFromJsonFalsePrivateToJson( ToJsonTrueFromJsonNullPrivate _$ToJsonTrueFromJsonNullPrivateFromJson( Map json) => ToJsonTrueFromJsonNullPrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonNullPrivateToJson( ToJsonTrueFromJsonNullPrivate instance) => @@ -194,9 +194,9 @@ Map _$ToJsonTrueFromJsonNullPrivateToJson( ToJsonTrueFromJsonTruePrivate _$ToJsonTrueFromJsonTruePrivateFromJson( Map json) => ToJsonTrueFromJsonTruePrivate() - ..aField = json['aField'] as int? - .._field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + .._field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonTruePrivateToJson( ToJsonTrueFromJsonTruePrivate instance) => @@ -209,8 +209,8 @@ Map _$ToJsonTrueFromJsonTruePrivateToJson( ToJsonTrueFromJsonFalsePrivate _$ToJsonTrueFromJsonFalsePrivateFromJson( Map json) => ToJsonTrueFromJsonFalsePrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonTrueFromJsonFalsePrivateToJson( ToJsonTrueFromJsonFalsePrivate instance) => @@ -223,8 +223,8 @@ Map _$ToJsonTrueFromJsonFalsePrivateToJson( ToJsonFalseFromJsonNullPrivate _$ToJsonFalseFromJsonNullPrivateFromJson( Map json) => ToJsonFalseFromJsonNullPrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonNullPrivateToJson( ToJsonFalseFromJsonNullPrivate instance) => @@ -236,9 +236,9 @@ Map _$ToJsonFalseFromJsonNullPrivateToJson( ToJsonFalseFromJsonTruePrivate _$ToJsonFalseFromJsonTruePrivateFromJson( Map json) => ToJsonFalseFromJsonTruePrivate() - ..aField = json['aField'] as int? - .._field = json['field'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + .._field = (json['field'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonTruePrivateToJson( ToJsonFalseFromJsonTruePrivate instance) => @@ -250,8 +250,8 @@ Map _$ToJsonFalseFromJsonTruePrivateToJson( ToJsonFalseFromJsonFalsePrivate _$ToJsonFalseFromJsonFalsePrivateFromJson( Map json) => ToJsonFalseFromJsonFalsePrivate() - ..aField = json['aField'] as int? - ..zField = json['zField'] as int?; + ..aField = (json['aField'] as num?)?.toInt() + ..zField = (json['zField'] as num?)?.toInt(); Map _$ToJsonFalseFromJsonFalsePrivateToJson( ToJsonFalseFromJsonFalsePrivate instance) => diff --git a/json_serializable/test/generic_files/generic_argument_factories.g.dart b/json_serializable/test/generic_files/generic_argument_factories.g.dart index 188ac7116..3ae8ac8e1 100644 --- a/json_serializable/test/generic_files/generic_argument_factories.g.dart +++ b/json_serializable/test/generic_files/generic_argument_factories.g.dart @@ -34,7 +34,7 @@ ConcreteClass _$ConcreteClassFromJson(Map json) => ConcreteClass( GenericClassWithHelpers.fromJson( json['value'] as Map, - (value) => value as int, + (value) => (value as num).toInt(), (value) => value as String), GenericClassWithHelpers.fromJson( json['value2'] as Map, diff --git a/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart b/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart index 17b278eed..626fa171a 100644 --- a/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart +++ b/json_serializable/test/generic_files/generic_argument_factories_nullable.g.dart @@ -56,7 +56,7 @@ ConcreteClassNullable _$ConcreteClassNullableFromJson( ConcreteClassNullable( GenericClassWithHelpersNullable.fromJson( json['value'] as Map, - (value) => value as int, + (value) => (value as num).toInt(), (value) => value as String), GenericClassWithHelpersNullable.fromJson( json['value2'] as Map, diff --git a/json_serializable/test/generic_files/generic_class.dart b/json_serializable/test/generic_files/generic_class.dart index 0870c956f..0ebfe7d1e 100644 --- a/json_serializable/test/generic_files/generic_class.dart +++ b/json_serializable/test/generic_files/generic_class.dart @@ -48,12 +48,15 @@ class GenericClass { @_DurationMillisecondConverter.named() @_DurationListMillisecondConverter() class GenericClassWithConverter { + // TODO: this annotation is a no-op. Need to figure out what to do about it! @_SimpleConverter() Object? fieldObject; + // TODO: this annotation is a no-op. Need to figure out what to do about it! @_SimpleConverter() dynamic fieldDynamic; + // TODO: this annotation is a no-op. Need to figure out what to do about it! @_SimpleConverter() int? fieldInt; diff --git a/json_serializable/test/generic_files/generic_class.g.dart b/json_serializable/test/generic_files/generic_class.g.dart index c5809241c..104eec1d6 100644 --- a/json_serializable/test/generic_files/generic_class.g.dart +++ b/json_serializable/test/generic_files/generic_class.g.dart @@ -38,15 +38,15 @@ GenericClassWithConverter GenericClassWithConverter() ..fieldObject = json['fieldObject'] ..fieldDynamic = json['fieldDynamic'] - ..fieldInt = json['fieldInt'] as int? + ..fieldInt = (json['fieldInt'] as num?)?.toInt() ..fieldT = _$JsonConverterFromJson, T>( json['fieldT'], _SimpleConverter().fromJson) ..fieldS = _$JsonConverterFromJson, S>( json['fieldS'], _SimpleConverter().fromJson) ..duration = const _DurationMillisecondConverter.named() - .fromJson(json['duration'] as int?) + .fromJson((json['duration'] as num?)?.toInt()) ..listDuration = const _DurationListMillisecondConverter() - .fromJson(json['listDuration'] as int?); + .fromJson((json['listDuration'] as num?)?.toInt()); Map _$GenericClassWithConverterToJson( GenericClassWithConverter instance) => diff --git a/json_serializable/test/generic_files/generic_test.dart b/json_serializable/test/generic_files/generic_test.dart index e4f82d6f3..ea509a471 100644 --- a/json_serializable/test/generic_files/generic_test.dart +++ b/json_serializable/test/generic_files/generic_test.dart @@ -76,7 +76,7 @@ void main() { final decoded = GenericClassWithHelpers.fromJson( jsonDecode(encodedJson) as Map, (value) => DateTime.parse(value as String), - (value) => Duration(milliseconds: value as int), + (value) => Duration(milliseconds: (value as num).toInt()), ); final encodedJson2 = loudEncode( @@ -194,7 +194,7 @@ void main() { GenericClassWithHelpersNullable.fromJson( jsonDecode(encodedJson) as Map, (value) => DateTime.parse(value as String), - (value) => Duration(milliseconds: value as int), + (value) => Duration(milliseconds: (value as num).toInt()), ); final encodedJson2 = loudEncode( @@ -225,7 +225,7 @@ void main() { GenericClassWithHelpersNullable.fromJson( jsonDecode(encodedJson) as Map, (value) => DateTime.parse(value as String), - (value) => Duration(milliseconds: value as int), + (value) => Duration(milliseconds: (value as num).toInt()), ); final encodedJson2 = loudEncode( diff --git a/json_serializable/test/integration/converter_examples.g.dart b/json_serializable/test/integration/converter_examples.g.dart index 26da277f0..2829672a9 100644 --- a/json_serializable/test/integration/converter_examples.g.dart +++ b/json_serializable/test/integration/converter_examples.g.dart @@ -12,7 +12,7 @@ Issue1202RegressionClass _$Issue1202RegressionClassFromJson( Map json) => Issue1202RegressionClass( value: $enumDecode(_$Issue1202RegressionEnumEnumMap, json['value']), - normalNullableValue: json['normalNullableValue'] as int?, + normalNullableValue: (json['normalNullableValue'] as num?)?.toInt(), notNullableValueWithNullableConverter: const _Issue1202RegressionConverter().fromJson( json['notNullableValueWithNullableConverter'] as String?), diff --git a/json_serializable/test/integration/create_per_field_to_json_example.g.dart b/json_serializable/test/integration/create_per_field_to_json_example.g.dart index 0587c26ba..1c4b0fe88 100644 --- a/json_serializable/test/integration/create_per_field_to_json_example.g.dart +++ b/json_serializable/test/integration/create_per_field_to_json_example.g.dart @@ -23,7 +23,7 @@ Model _$ModelFromJson(Map json) => Model( ? null : GenericFactory.fromJson( json['nestedGeneric'] as Map, - (value) => value as int), + (value) => (value as num).toInt()), ); // ignore: unused_element diff --git a/json_serializable/test/integration/integration_test.dart b/json_serializable/test/integration/integration_test.dart index 8c5827ee8..6aef150f2 100644 --- a/json_serializable/test/integration/integration_test.dart +++ b/json_serializable/test/integration/integration_test.dart @@ -258,18 +258,23 @@ void main() { test('support ints as doubles', () { final value = { 'doubles': [0, 0.0], - 'nnDoubles': [0, 0.0] + 'nnDoubles': [0, 0.0], + 'doubleAsString': 3, }; - roundTripNumber(Numbers.fromJson(value)); + final output = roundTripObject(Numbers.fromJson(value), Numbers.fromJson); + expect(output.doubleAsString, 3.0.toString()); }); - test('does not support doubles as ints', () { + test('support doubles as ints', () { final value = { - 'ints': [3.14, 0], + 'ints': [3, 3.0, 3.14, 0], }; - expect(() => Numbers.fromJson(value), throwsTypeError); + final output = roundTripObject(Numbers.fromJson(value), Numbers.fromJson); + + // NOTE: all of the double values are truncated + expect(output.ints, [3, 3, 3, 0]); }); }); diff --git a/json_serializable/test/integration/json_test_common.dart b/json_serializable/test/integration/json_test_common.dart index d16c3b954..27415fb81 100644 --- a/json_serializable/test/integration/json_test_common.dart +++ b/json_serializable/test/integration/json_test_common.dart @@ -38,6 +38,11 @@ Duration? durationFromInt(int? ms) => int? durationToInt(Duration? duration) => duration?.inMilliseconds; +String? stringFromDouble(double? value) => value?.toString(); + +double? stringToDouble(String? value) => + value == null ? null : double.parse(value); + DateTime? dateTimeFromEpochUs(int? us) => us == null ? null : DateTime.fromMicrosecondsSinceEpoch(us); diff --git a/json_serializable/test/integration/json_test_example.dart b/json_serializable/test/integration/json_test_example.dart index d69be6022..7f3482935 100644 --- a/json_serializable/test/integration/json_test_example.dart +++ b/json_serializable/test/integration/json_test_example.dart @@ -155,6 +155,9 @@ class Numbers { @JsonKey(fromJson: durationFromInt, toJson: durationToInt) Duration? duration; + @JsonKey(fromJson: stringFromDouble, toJson: stringToDouble) + String? doubleAsString; + @JsonKey(fromJson: dateTimeFromEpochUs, toJson: dateTimeToEpochUs) DateTime? date; diff --git a/json_serializable/test/integration/json_test_example.g.dart b/json_serializable/test/integration/json_test_example.g.dart index b6a5330d4..ec12eb554 100644 --- a/json_serializable/test/integration/json_test_example.g.dart +++ b/json_serializable/test/integration/json_test_example.g.dart @@ -29,7 +29,8 @@ Person _$PersonFromJson(Map json) => Person( (k, e) => MapEntry(k, $enumDecode(_$CategoryEnumMap, e)), ) ..categoryCounts = (json['categoryCounts'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$CategoryEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$CategoryEnumMap, k), (e as num).toInt()), ); Map _$PersonToJson(Person instance) => { @@ -66,11 +67,11 @@ Order _$OrderFromJson(Map json) { (json['items'] as List?) ?.map((e) => Item.fromJson(e as Map)), ) - ..count = json['count'] as int? + ..count = (json['count'] as num?)?.toInt() ..isRushed = json['isRushed'] as bool? ..duration = json['duration'] == null ? null - : Duration(microseconds: json['duration'] as int) + : Duration(microseconds: (json['duration'] as num).toInt()) ..platform = json['platform'] == null ? null : Platform.fromJson(json['platform'] as String) @@ -113,13 +114,15 @@ const _$StatusCodeEnumMap = { }; Item _$ItemFromJson(Map json) => Item( - json['price'] as int?, + (json['price'] as num?)?.toInt(), ) - ..itemNumber = json['item-number'] as int? + ..itemNumber = (json['item-number'] as num?)?.toInt() ..saleDates = (json['saleDates'] as List?) ?.map((e) => DateTime.parse(e as String)) .toList() - ..rates = (json['rates'] as List?)?.map((e) => e as int).toList() + ..rates = (json['rates'] as List?) + ?.map((e) => (e as num).toInt()) + .toList() ..geoPoint = _fromJsonGeoPoint(json['geoPoint'] as Map?); Map _$ItemToJson(Item instance) { @@ -142,7 +145,8 @@ Map _$ItemToJson(Item instance) { } Numbers _$NumbersFromJson(Map json) => Numbers() - ..ints = (json['ints'] as List?)?.map((e) => e as int).toList() + ..ints = + (json['ints'] as List?)?.map((e) => (e as num).toInt()).toList() ..nums = (json['nums'] as List?)?.map((e) => e as num).toList() ..doubles = (json['doubles'] as List?) ?.map((e) => (e as num).toDouble()) @@ -150,8 +154,10 @@ Numbers _$NumbersFromJson(Map json) => Numbers() ..nnDoubles = (json['nnDoubles'] as List?) ?.map((e) => (e as num).toDouble()) .toList() - ..duration = durationFromInt(json['duration'] as int?) - ..date = dateTimeFromEpochUs(json['date'] as int?); + ..duration = durationFromInt((json['duration'] as num?)?.toInt()) + ..doubleAsString = + stringFromDouble((json['doubleAsString'] as num?)?.toDouble()) + ..date = dateTimeFromEpochUs((json['date'] as num?)?.toInt()); Map _$NumbersToJson(Numbers instance) => { 'ints': instance.ints, @@ -159,22 +165,23 @@ Map _$NumbersToJson(Numbers instance) => { 'doubles': instance.doubles, 'nnDoubles': instance.nnDoubles, 'duration': durationToInt(instance.duration), + 'doubleAsString': stringToDouble(instance.doubleAsString), 'date': dateTimeToEpochUs(instance.date), }; MapKeyVariety _$MapKeyVarietyFromJson(Map json) => MapKeyVariety() ..intIntMap = (json['intIntMap'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), e as int), + (k, e) => MapEntry(int.parse(k), (e as num).toInt()), ) ..uriIntMap = (json['uriIntMap'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), e as int), + (k, e) => MapEntry(Uri.parse(k), (e as num).toInt()), ) ..dateTimeIntMap = (json['dateTimeIntMap'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k), e as int), + (k, e) => MapEntry(DateTime.parse(k), (e as num).toInt()), ) ..bigIntMap = (json['bigIntMap'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k), e as int), + (k, e) => MapEntry(BigInt.parse(k), (e as num).toInt()), ); Map _$MapKeyVarietyToJson(MapKeyVariety instance) => @@ -204,7 +211,7 @@ UnknownEnumValue _$UnknownEnumValueFromJson(Map json) => PrivateConstructor _$PrivateConstructorFromJson(Map json) => PrivateConstructor._( - json['id'] as int, + (json['id'] as num).toInt(), json['value'] as String, ); diff --git a/json_serializable/test/integration/json_test_example.g_any_map.dart b/json_serializable/test/integration/json_test_example.g_any_map.dart index 2c6b51bda..b4789725d 100644 --- a/json_serializable/test/integration/json_test_example.g_any_map.dart +++ b/json_serializable/test/integration/json_test_example.g_any_map.dart @@ -161,6 +161,9 @@ class Numbers { @JsonKey(fromJson: durationFromInt, toJson: durationToInt) Duration? duration; + @JsonKey(fromJson: stringFromDouble, toJson: stringToDouble) + String? doubleAsString; + @JsonKey(fromJson: dateTimeFromEpochUs, toJson: dateTimeToEpochUs) DateTime? date; diff --git a/json_serializable/test/integration/json_test_example.g_any_map.g.dart b/json_serializable/test/integration/json_test_example.g_any_map.g.dart index b8ba1f9f4..5fe79152e 100644 --- a/json_serializable/test/integration/json_test_example.g_any_map.g.dart +++ b/json_serializable/test/integration/json_test_example.g_any_map.g.dart @@ -29,7 +29,8 @@ Person _$PersonFromJson(Map json) => Person( (k, e) => MapEntry(k as String, $enumDecode(_$CategoryEnumMap, e)), ) ..categoryCounts = (json['categoryCounts'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$CategoryEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$CategoryEnumMap, k), (e as num).toInt()), ); Map _$PersonToJson(Person instance) => { @@ -66,11 +67,11 @@ Order _$OrderFromJson(Map json) { (json['items'] as List?) ?.map((e) => Item.fromJson(Map.from(e as Map))), ) - ..count = json['count'] as int? + ..count = (json['count'] as num?)?.toInt() ..isRushed = json['isRushed'] as bool? ..duration = json['duration'] == null ? null - : Duration(microseconds: json['duration'] as int) + : Duration(microseconds: (json['duration'] as num).toInt()) ..platform = json['platform'] == null ? null : Platform.fromJson(json['platform'] as String) @@ -113,13 +114,15 @@ const _$StatusCodeEnumMap = { }; Item _$ItemFromJson(Map json) => Item( - json['price'] as int?, + (json['price'] as num?)?.toInt(), ) - ..itemNumber = json['item-number'] as int? + ..itemNumber = (json['item-number'] as num?)?.toInt() ..saleDates = (json['saleDates'] as List?) ?.map((e) => DateTime.parse(e as String)) .toList() - ..rates = (json['rates'] as List?)?.map((e) => e as int).toList() + ..rates = (json['rates'] as List?) + ?.map((e) => (e as num).toInt()) + .toList() ..geoPoint = _fromJsonGeoPoint(json['geoPoint'] as Map?); Map _$ItemToJson(Item instance) { @@ -142,7 +145,8 @@ Map _$ItemToJson(Item instance) { } Numbers _$NumbersFromJson(Map json) => Numbers() - ..ints = (json['ints'] as List?)?.map((e) => e as int).toList() + ..ints = + (json['ints'] as List?)?.map((e) => (e as num).toInt()).toList() ..nums = (json['nums'] as List?)?.map((e) => e as num).toList() ..doubles = (json['doubles'] as List?) ?.map((e) => (e as num).toDouble()) @@ -150,8 +154,10 @@ Numbers _$NumbersFromJson(Map json) => Numbers() ..nnDoubles = (json['nnDoubles'] as List?) ?.map((e) => (e as num).toDouble()) .toList() - ..duration = durationFromInt(json['duration'] as int?) - ..date = dateTimeFromEpochUs(json['date'] as int?); + ..duration = durationFromInt((json['duration'] as num?)?.toInt()) + ..doubleAsString = + stringFromDouble((json['doubleAsString'] as num?)?.toDouble()) + ..date = dateTimeFromEpochUs((json['date'] as num?)?.toInt()); Map _$NumbersToJson(Numbers instance) => { 'ints': instance.ints, @@ -159,21 +165,22 @@ Map _$NumbersToJson(Numbers instance) => { 'doubles': instance.doubles, 'nnDoubles': instance.nnDoubles, 'duration': durationToInt(instance.duration), + 'doubleAsString': stringToDouble(instance.doubleAsString), 'date': dateTimeToEpochUs(instance.date), }; MapKeyVariety _$MapKeyVarietyFromJson(Map json) => MapKeyVariety() ..intIntMap = (json['intIntMap'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k as String), e as int), + (k, e) => MapEntry(int.parse(k as String), (e as num).toInt()), ) ..uriIntMap = (json['uriIntMap'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k as String), e as int), + (k, e) => MapEntry(Uri.parse(k as String), (e as num).toInt()), ) ..dateTimeIntMap = (json['dateTimeIntMap'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k as String), e as int), + (k, e) => MapEntry(DateTime.parse(k as String), (e as num).toInt()), ) ..bigIntMap = (json['bigIntMap'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k as String), e as int), + (k, e) => MapEntry(BigInt.parse(k as String), (e as num).toInt()), ); Map _$MapKeyVarietyToJson(MapKeyVariety instance) => @@ -202,7 +209,7 @@ UnknownEnumValue _$UnknownEnumValueFromJson(Map json) => UnknownEnumValue() PrivateConstructor _$PrivateConstructorFromJson(Map json) => PrivateConstructor._( - json['id'] as int, + (json['id'] as num).toInt(), json['value'] as String, ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g.dart index d9230fbc5..6d376fdfe 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -85,11 +88,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson( json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -158,9 +161,11 @@ $Rec? _$recordConvertNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson( Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num?)?.toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => const DurationMillisecondConverter() + .fromJson((e as num?)?.toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -175,16 +180,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson( _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num?)?.toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num?)?.toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num?)?.toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart index 74a348f5e..69301303d 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.g_any_map.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -77,11 +80,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..simpleObject = SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson(json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertAnyNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -149,9 +152,11 @@ $Rec? _$recordConvertAnyNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num?)?.toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => const DurationMillisecondConverter() + .fromJson((e as num?)?.toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -166,16 +171,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num?)?.toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num?)?.toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num?)?.toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart index d08da32c5..c004dcc74 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_any_map__checked.g.dart @@ -13,7 +13,8 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( json, ($checkedConvert) { final val = KitchenSink( - ctorValidatedNo42: $checkedConvert('no-42', (v) => v as int?), + ctorValidatedNo42: + $checkedConvert('no-42', (v) => (v as num?)?.toInt()), iterable: $checkedConvert( 'iterable', (v) => v as List?, @@ -24,7 +25,7 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( objectIterable: $checkedConvert('objectIterable', (v) => (v as List?)?.map((e) => e as Object)), intIterable: $checkedConvert('intIterable', - (v) => (v as List?)?.map((e) => e as int)), + (v) => (v as List?)?.map((e) => (e as num).toInt())), dateTimeIterable: $checkedConvert( 'datetime-iterable', (v) => (v as List?) @@ -45,8 +46,8 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( (v as List).map((e) => e as Object).toSet()); $checkedConvert( 'intSet', - (v) => - val.intSet = (v as List).map((e) => e as int).toSet()); + (v) => val.intSet = + (v as List).map((e) => (e as num).toInt()).toSet()); $checkedConvert( 'dateTimeSet', (v) => val.dateTimeSet = (v as List) @@ -62,7 +63,7 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( $checkedConvert( 'intList', (v) => val.intList = - (v as List).map((e) => e as int).toList()); + (v as List).map((e) => (e as num).toInt()).toList()); $checkedConvert( 'dateTimeList', (v) => val.dateTimeList = (v as List) @@ -120,13 +121,13 @@ KitchenSink _$KitchenSinkFromJson(Map json) => $checkedCreate( $checkedConvert('strictKeysObject', (v) => val.strictKeysObject = StrictKeysObject.fromJson(v as Map)); $checkedConvert('validatedPropertyNo42', - (v) => val.validatedPropertyNo42 = v as int?); + (v) => val.validatedPropertyNo42 = (v as num?)?.toInt()); $checkedConvert( 'recordField', (v) => val.recordField = _$recordConvertAnyNullable( v, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -206,13 +207,15 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => json, ($checkedConvert) { final val = JsonConverterTestClass( - $checkedConvert('duration', - (v) => const DurationMillisecondConverter().fromJson(v as int?)), + $checkedConvert( + 'duration', + (v) => const DurationMillisecondConverter() + .fromJson((v as num?)?.toInt())), $checkedConvert( 'durationList', (v) => (v as List) - .map((e) => - const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => const DurationMillisecondConverter() + .fromJson((e as num?)?.toInt())) .toList()), $checkedConvert('bigInt', (v) => const BigIntStringConverter().fromJson(v as String)), @@ -234,25 +237,31 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson(Map json) => _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), )), - $checkedConvert('numberSilly', - (v) => TrivialNumberConverter.instance.fromJson(v as int?)), + $checkedConvert( + 'numberSilly', + (v) => TrivialNumberConverter.instance + .fromJson((v as num?)?.toInt())), $checkedConvert( 'numberSillySet', (v) => (v as List) - .map((e) => - TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => TrivialNumberConverter.instance + .fromJson((e as num?)?.toInt())) .toSet()), - $checkedConvert('dateTime', - (v) => const EpochDateTimeConverter().fromJson(v as int?)), + $checkedConvert( + 'dateTime', + (v) => const EpochDateTimeConverter() + .fromJson((v as num?)?.toInt())), $checkedConvert('trivialString', (v) => trivialStringConverter.fromJson(v as String?)), - $checkedConvert('nullableNumberSilly', - (v) => TrivialNumberConverter.instance.fromJson(v as int?)), + $checkedConvert( + 'nullableNumberSilly', + (v) => TrivialNumberConverter.instance + .fromJson((v as num?)?.toInt())), $checkedConvert( 'nullableNumberSillySet', (v) => (v as List) - .map((e) => - TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => TrivialNumberConverter.instance + .fromJson((e as num?)?.toInt())) .toSet()), ); return val; diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart index 76504317c..a3a8f8550 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.g_exclude_null.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -85,11 +88,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson( json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -168,9 +171,11 @@ $Rec? _$recordConvertNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson( Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num?)?.toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => const DurationMillisecondConverter() + .fromJson((e as num?)?.toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -185,16 +190,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson( _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num?)?.toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num?)?.toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num?)?.toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart index ff092269c..0115b3fff 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_explicit_to_json.g.dart @@ -9,13 +9,13 @@ part of 'kitchen_sink.g_explicit_to_json.dart'; // ************************************************************************** KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( - ctorValidatedNo42: json['no-42'] as int?, + ctorValidatedNo42: (json['no-42'] as num?)?.toInt(), iterable: _valueAccessor(json, 'iterable') as List?, dynamicIterable: json['dynamicIterable'] as List?, objectIterable: (json['objectIterable'] as List?)?.map((e) => e as Object), - intIterable: - (json['intIterable'] as List?)?.map((e) => e as int), + intIterable: (json['intIterable'] as List?) + ?.map((e) => (e as num).toInt()), dateTimeIterable: (json['datetime-iterable'] as List?) ?.map((e) => DateTime.parse(e as String)), ) @@ -28,7 +28,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicSet = (json['dynamicSet'] as List).toSet() ..objectSet = (json['objectSet'] as List).map((e) => e as Object).toSet() - ..intSet = (json['intSet'] as List).map((e) => e as int).toSet() + ..intSet = (json['intSet'] as List) + .map((e) => (e as num).toInt()) + .toSet() ..dateTimeSet = (json['dateTimeSet'] as List) .map((e) => DateTime.parse(e as String)) .toSet() @@ -36,8 +38,9 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ..dynamicList = json['dynamicList'] as List ..objectList = (json['objectList'] as List).map((e) => e as Object).toList() - ..intList = - (json['intList'] as List).map((e) => e as int).toList() + ..intList = (json['intList'] as List) + .map((e) => (e as num).toInt()) + .toList() ..dateTimeList = (json['dateTimeList'] as List) .map((e) => DateTime.parse(e as String)) .toList() @@ -85,11 +88,11 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( SimpleObject.fromJson(json['simpleObject'] as Map) ..strictKeysObject = StrictKeysObject.fromJson( json['strictKeysObject'] as Map) - ..validatedPropertyNo42 = json['validatedPropertyNo42'] as int? + ..validatedPropertyNo42 = (json['validatedPropertyNo42'] as num?)?.toInt() ..recordField = _$recordConvertNullable( json['recordField'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -160,9 +163,11 @@ $Rec? _$recordConvertNullable<$Rec>( JsonConverterTestClass _$JsonConverterTestClassFromJson( Map json) => JsonConverterTestClass( - const DurationMillisecondConverter().fromJson(json['duration'] as int?), + const DurationMillisecondConverter() + .fromJson((json['duration'] as num?)?.toInt()), (json['durationList'] as List) - .map((e) => const DurationMillisecondConverter().fromJson(e as int?)) + .map((e) => const DurationMillisecondConverter() + .fromJson((e as num?)?.toInt())) .toList(), const BigIntStringConverter().fromJson(json['bigInt'] as String), (json['bigIntMap'] as Map).map( @@ -177,16 +182,20 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson( _$JsonConverterFromJson( e, const BigIntStringConverter().fromJson)), ), - TrivialNumberConverter.instance.fromJson(json['numberSilly'] as int?), + TrivialNumberConverter.instance + .fromJson((json['numberSilly'] as num?)?.toInt()), (json['numberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), - const EpochDateTimeConverter().fromJson(json['dateTime'] as int?), + const EpochDateTimeConverter() + .fromJson((json['dateTime'] as num?)?.toInt()), trivialStringConverter.fromJson(json['trivialString'] as String?), TrivialNumberConverter.instance - .fromJson(json['nullableNumberSilly'] as int?), + .fromJson((json['nullableNumberSilly'] as num?)?.toInt()), (json['nullableNumberSillySet'] as List) - .map((e) => TrivialNumberConverter.instance.fromJson(e as int?)) + .map((e) => + TrivialNumberConverter.instance.fromJson((e as num?)?.toInt())) .toSet(), ); diff --git a/json_serializable/test/kitchen_sink/simple_object.g.dart b/json_serializable/test/kitchen_sink/simple_object.g.dart index b0bbfbef0..53442bc1b 100644 --- a/json_serializable/test/kitchen_sink/simple_object.g.dart +++ b/json_serializable/test/kitchen_sink/simple_object.g.dart @@ -9,7 +9,7 @@ part of 'simple_object.dart'; // ************************************************************************** SimpleObject _$SimpleObjectFromJson(Map json) => SimpleObject( - json['value'] as int, + (json['value'] as num).toInt(), ); Map _$SimpleObjectToJson(SimpleObject instance) => diff --git a/json_serializable/test/kitchen_sink/strict_keys_object.g.dart b/json_serializable/test/kitchen_sink/strict_keys_object.g.dart index b6b00cce3..820d237ee 100644 --- a/json_serializable/test/kitchen_sink/strict_keys_object.g.dart +++ b/json_serializable/test/kitchen_sink/strict_keys_object.g.dart @@ -15,7 +15,7 @@ StrictKeysObject _$StrictKeysObjectFromJson(Map json) { requiredKeys: const ['value', 'custom_field'], ); return StrictKeysObject( - json['value'] as int, + (json['value'] as num).toInt(), json['custom_field'] as String, ); } diff --git a/json_serializable/test/src/_json_serializable_test_input.dart b/json_serializable/test/src/_json_serializable_test_input.dart index af82c8440..1458630ff 100644 --- a/json_serializable/test/src/_json_serializable_test_input.dart +++ b/json_serializable/test/src/_json_serializable_test_input.dart @@ -55,12 +55,13 @@ GeneralTestClass1 _$GeneralTestClass1FromJson(Map json) => GeneralTestClass1() ..firstName = json['firstName'] as String ..lastName = json['lastName'] as String - ..height = json['h'] as int + ..height = (json['h'] as num).toInt() ..dateOfBirth = DateTime.parse(json['dateOfBirth'] as String) ..dynamicType = json['dynamicType'] ..varType = json['varType'] - ..listOfInts = - (json['listOfInts'] as List).map((e) => e as int).toList(); + ..listOfInts = (json['listOfInts'] as List) + .map((e) => (e as num).toInt()) + .toList(); Map _$GeneralTestClass1ToJson(GeneralTestClass1 instance) => { @@ -89,7 +90,7 @@ class GeneralTestClass1 { @ShouldGenerate(r''' GeneralTestClass2 _$GeneralTestClass2FromJson(Map json) => GeneralTestClass2( - json['height'] as int, + (json['height'] as num).toInt(), json['firstName'] as String, json['lastName'] as String?, )..dateOfBirth = DateTime.parse(json['dateOfBirth'] as String); @@ -117,7 +118,7 @@ class GeneralTestClass2 { @ShouldGenerate(r''' FinalFields _$FinalFieldsFromJson(Map json) => FinalFields( - json['a'] as int, + (json['a'] as num).toInt(), ); Map _$FinalFieldsToJson(FinalFields instance) => @@ -154,7 +155,7 @@ class FinalFieldsNotSetInCtor { @ShouldGenerate(r''' SetSupport _$SetSupportFromJson(Map json) => SetSupport( - (json['values'] as List).map((e) => e as int).toSet(), + (json['values'] as List).map((e) => (e as num).toInt()).toSet(), ); Map _$SetSupportToJson(SetSupport instance) => @@ -455,8 +456,8 @@ mixin _PropInMixinI448RegressionMixin { PropInMixinI448Regression _$PropInMixinI448RegressionFromJson( Map json) => PropInMixinI448Regression() - ..nullable = json['nullable'] as int - ..notNullable = json['notNullable'] as int; + ..nullable = (json['nullable'] as num).toInt() + ..notNullable = (json['notNullable'] as num).toInt(); Map _$PropInMixinI448RegressionToJson( PropInMixinI448Regression instance) => @@ -474,7 +475,7 @@ class PropInMixinI448Regression with _PropInMixinI448RegressionMixin { @ShouldGenerate( r''' IgnoreUnannotated _$IgnoreUnannotatedFromJson(Map json) => - IgnoreUnannotated()..annotated = json['annotated'] as int; + IgnoreUnannotated()..annotated = (json['annotated'] as num).toInt(); Map _$IgnoreUnannotatedToJson(IgnoreUnannotated instance) => { @@ -493,7 +494,7 @@ class IgnoreUnannotated { @ShouldGenerate( r''' SubclassedJsonKey _$SubclassedJsonKeyFromJson(Map json) => - SubclassedJsonKey()..annotatedWithSubclass = json['bob'] as int; + SubclassedJsonKey()..annotatedWithSubclass = (json['bob'] as num).toInt(); Map _$SubclassedJsonKeyToJson(SubclassedJsonKey instance) => { diff --git a/json_serializable/test/src/default_value_input.dart b/json_serializable/test/src/default_value_input.dart index a594aa761..7bdd1a35b 100644 --- a/json_serializable/test/src/default_value_input.dart +++ b/json_serializable/test/src/default_value_input.dart @@ -137,7 +137,7 @@ DefaultWithDisallowNullRequiredClass disallowNullValues: const ['theField'], ); return DefaultWithDisallowNullRequiredClass() - ..theField = json['theField'] as int? ?? 7; + ..theField = (json['theField'] as num?)?.toInt() ?? 7; } ''', expectedLogItems: [ @@ -159,7 +159,7 @@ CtorDefaultValueAndJsonKeyDefaultValue _$CtorDefaultValueAndJsonKeyDefaultValueFromJson( Map json) => CtorDefaultValueAndJsonKeyDefaultValue( - json['theField'] as int? ?? 7, + (json['theField'] as num?)?.toInt() ?? 7, ); ''', expectedLogItems: [ @@ -181,7 +181,7 @@ class CtorDefaultValueAndJsonKeyDefaultValue { SameCtorAndJsonKeyDefaultValue _$SameCtorAndJsonKeyDefaultValueFromJson( Map json) => SameCtorAndJsonKeyDefaultValue( - json['theField'] as int? ?? 3, + (json['theField'] as num?)?.toInt() ?? 3, ); ''', expectedLogItems: [ diff --git a/json_serializable/test/src/inheritance_test_input.dart b/json_serializable/test/src/inheritance_test_input.dart index afd6a6552..875743fc7 100644 --- a/json_serializable/test/src/inheritance_test_input.dart +++ b/json_serializable/test/src/inheritance_test_input.dart @@ -2,11 +2,11 @@ part of '_json_serializable_test_input.dart'; @ShouldGenerate(r''' SubType _$SubTypeFromJson(Map json) => SubType( - json['subTypeViaCtor'] as int, - json['super-final-field'] as int, + (json['subTypeViaCtor'] as num).toInt(), + (json['super-final-field'] as num).toInt(), ) - ..superReadWriteField = json['superReadWriteField'] as int? - ..subTypeReadWrite = json['subTypeReadWrite'] as int; + ..superReadWriteField = (json['superReadWriteField'] as num?)?.toInt() + ..subTypeReadWrite = (json['subTypeReadWrite'] as num).toInt(); Map _$SubTypeToJson(SubType instance) { final val = { diff --git a/json_serializable/test/src/json_converter_test_input.dart b/json_serializable/test/src/json_converter_test_input.dart index 865ee06a6..5f4075b82 100644 --- a/json_serializable/test/src/json_converter_test_input.dart +++ b/json_serializable/test/src/json_converter_test_input.dart @@ -11,11 +11,11 @@ JsonConverterNamedCtor _$JsonConverterNamedCtorFromJson( Map json) => JsonConverterNamedCtor() ..value = const _DurationMillisecondConverter.named() - .fromJson(json['value'] as int) - ..genericValue = - _GenericConverter.named().fromJson(json['genericValue'] as int) - ..keyAnnotationFirst = - JsonConverterNamedCtor._fromJson(json['keyAnnotationFirst'] as int); + .fromJson((json['value'] as num).toInt()) + ..genericValue = _GenericConverter.named() + .fromJson((json['genericValue'] as num).toInt()) + ..keyAnnotationFirst = JsonConverterNamedCtor._fromJson( + (json['keyAnnotationFirst'] as num).toInt()); Map _$JsonConverterNamedCtorToJson( JsonConverterNamedCtor instance) => @@ -49,13 +49,13 @@ JsonConvertOnField _$JsonConvertOnFieldFromJson( Map json) => JsonConvertOnField() ..annotatedField = const _DurationMillisecondConverter() - .fromJson(json['annotatedField'] as int) + .fromJson((json['annotatedField'] as num).toInt()) ..annotatedWithNamedCtor = const _DurationMillisecondConverter.named() - .fromJson(json['annotatedWithNamedCtor'] as int) - ..classAnnotatedWithField = - _durationConverter.fromJson(json['classAnnotatedWithField'] as int) - ..genericValue = - _GenericConverter().fromJson(json['genericValue'] as int); + .fromJson((json['annotatedWithNamedCtor'] as num).toInt()) + ..classAnnotatedWithField = _durationConverter + .fromJson((json['classAnnotatedWithField'] as num).toInt()) + ..genericValue = _GenericConverter() + .fromJson((json['genericValue'] as num).toInt()); Map _$JsonConvertOnFieldToJson( JsonConvertOnField instance) => 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 861512f18..2f07cf703 100644 --- a/json_serializable/test/src/map_key_variety_test_input.dart +++ b/json_serializable/test/src/map_key_variety_test_input.dart @@ -4,7 +4,7 @@ part of '_json_serializable_test_input.dart'; MapKeyVariety _$MapKeyVarietyFromJson(Map json) => MapKeyVariety() ..intIntMap = (json['intIntMap'] as Map).map( - (k, e) => MapEntry(int.parse(k), e as int), + (k, e) => MapEntry(int.parse(k), (e as num).toInt()), ); Map _$MapKeyVarietyToJson(MapKeyVariety instance) => 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 11ce9f447..7e5f57965 100644 --- a/json_serializable/test/src/to_from_json_test_input.dart +++ b/json_serializable/test/src/to_from_json_test_input.dart @@ -122,7 +122,7 @@ class Reproduce869NullableGenericTypeWithDefault { } List? _fromList(List? pairs) => - pairs?.map((it) => it as int).toList(growable: false); + pairs?.map((it) => (it as num).toInt()).toList(growable: false); List? _toList(List? pairs) => pairs?.map((it) => [it]).toList(growable: false); diff --git a/json_serializable/test/supported_types/enum_type.dart b/json_serializable/test/supported_types/enum_type.dart index 6e31deaf2..91750dd6b 100644 --- a/json_serializable/test/supported_types/enum_type.dart +++ b/json_serializable/test/supported_types/enum_type.dart @@ -10,7 +10,7 @@ class FromJsonDynamicParam { final int value; factory FromJsonDynamicParam.fromJson(dynamic json) => - FromJsonDynamicParam(value: json as int); + FromJsonDynamicParam(value: (json as num).toInt()); dynamic toJson() => null; } @@ -21,7 +21,7 @@ class FromJsonNullableObjectParam { final int value; factory FromJsonNullableObjectParam.fromJson(Object? json) => - FromJsonNullableObjectParam(value: json as int); + FromJsonNullableObjectParam(value: (json as num).toInt()); Object? toJson() => null; } @@ -32,7 +32,7 @@ class FromJsonObjectParam { final int value; factory FromJsonObjectParam.fromJson(Object json) => - FromJsonObjectParam(value: json as int); + FromJsonObjectParam(value: (json as num).toInt()); dynamic toJson() => null; } diff --git a/json_serializable/test/supported_types/input.type_duration.g.dart b/json_serializable/test/supported_types/input.type_duration.g.dart index 7ea4c7da6..9d57d843c 100644 --- a/json_serializable/test/supported_types/input.type_duration.g.dart +++ b/json_serializable/test/supported_types/input.type_duration.g.dart @@ -9,7 +9,7 @@ part of 'input.type_duration.dart'; // ************************************************************************** SimpleClass _$SimpleClassFromJson(Map json) => SimpleClass( - Duration(microseconds: json['value'] as int), + Duration(microseconds: (json['value'] as num).toInt()), ); Map _$SimpleClassToJson(SimpleClass instance) => @@ -21,7 +21,7 @@ SimpleClassNullable _$SimpleClassNullableFromJson(Map json) => SimpleClassNullable( json['value'] == null ? null - : Duration(microseconds: json['value'] as int), + : Duration(microseconds: (json['value'] as num).toInt()), ); Map _$SimpleClassNullableToJson( diff --git a/json_serializable/test/supported_types/input.type_int.g.dart b/json_serializable/test/supported_types/input.type_int.g.dart index ddb06ed57..2f248b74a 100644 --- a/json_serializable/test/supported_types/input.type_int.g.dart +++ b/json_serializable/test/supported_types/input.type_int.g.dart @@ -9,8 +9,8 @@ part of 'input.type_int.dart'; // ************************************************************************** SimpleClass _$SimpleClassFromJson(Map json) => SimpleClass( - json['value'] as int, - json['withDefault'] as int? ?? 42, + (json['value'] as num).toInt(), + (json['withDefault'] as num?)?.toInt() ?? 42, ); Map _$SimpleClassToJson(SimpleClass instance) => @@ -21,8 +21,8 @@ Map _$SimpleClassToJson(SimpleClass instance) => SimpleClassNullable _$SimpleClassNullableFromJson(Map json) => SimpleClassNullable( - json['value'] as int?, - json['withDefault'] as int? ?? 42, + (json['value'] as num?)?.toInt(), + (json['withDefault'] as num?)?.toInt() ?? 42, ); Map _$SimpleClassNullableToJson( diff --git a/json_serializable/test/supported_types/input.type_iterable.g.dart b/json_serializable/test/supported_types/input.type_iterable.g.dart index 95c3e0557..a9264f393 100644 --- a/json_serializable/test/supported_types/input.type_iterable.g.dart +++ b/json_serializable/test/supported_types/input.type_iterable.g.dart @@ -231,7 +231,7 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( Map json) => SimpleClassOfDuration( (json['value'] as List) - .map((e) => Duration(microseconds: e as int)), + .map((e) => Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassOfDurationToJson( @@ -244,7 +244,7 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( Map json) => SimpleClassNullableOfDuration( (json['value'] as List?) - ?.map((e) => Duration(microseconds: e as int)), + ?.map((e) => Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassNullableOfDurationToJson( @@ -256,8 +256,8 @@ Map _$SimpleClassNullableOfDurationToJson( SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( Map json) => SimpleClassOfDurationNullable( - (json['value'] as List) - .map((e) => e == null ? null : Duration(microseconds: e as int)), + (json['value'] as List).map( + (e) => e == null ? null : Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassOfDurationNullableToJson( @@ -270,8 +270,8 @@ SimpleClassNullableOfDurationNullable _$SimpleClassNullableOfDurationNullableFromJson( Map json) => SimpleClassNullableOfDurationNullable( - (json['value'] as List?) - ?.map((e) => e == null ? null : Duration(microseconds: e as int)), + (json['value'] as List?)?.map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())), ); Map _$SimpleClassNullableOfDurationNullableToJson( @@ -446,7 +446,7 @@ Map _$SimpleClassNullableOfFromJsonObjectParamToJson( SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => SimpleClassOfInt( - (json['value'] as List).map((e) => e as int), + (json['value'] as List).map((e) => (e as num).toInt()), ); Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => @@ -457,7 +457,7 @@ Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( Map json) => SimpleClassNullableOfInt( - (json['value'] as List?)?.map((e) => e as int), + (json['value'] as List?)?.map((e) => (e as num).toInt()), ); Map _$SimpleClassNullableOfIntToJson( @@ -469,7 +469,7 @@ Map _$SimpleClassNullableOfIntToJson( SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( Map json) => SimpleClassOfIntNullable( - (json['value'] as List).map((e) => e as int?), + (json['value'] as List).map((e) => (e as num?)?.toInt()), ); Map _$SimpleClassOfIntNullableToJson( @@ -481,7 +481,7 @@ Map _$SimpleClassOfIntNullableToJson( SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( Map json) => SimpleClassNullableOfIntNullable( - (json['value'] as List?)?.map((e) => e as int?), + (json['value'] as List?)?.map((e) => (e as num?)?.toInt()), ); Map _$SimpleClassNullableOfIntNullableToJson( @@ -588,7 +588,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => (json['value'] as List).map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -619,7 +619,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( (json['value'] as List?)?.map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_list.g.dart b/json_serializable/test/supported_types/input.type_list.g.dart index 2f4497581..f86a6d00c 100644 --- a/json_serializable/test/supported_types/input.type_list.g.dart +++ b/json_serializable/test/supported_types/input.type_list.g.dart @@ -249,7 +249,7 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( Map json) => SimpleClassOfDuration( (json['value'] as List) - .map((e) => Duration(microseconds: e as int)) + .map((e) => Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -263,7 +263,7 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( Map json) => SimpleClassNullableOfDuration( (json['value'] as List?) - ?.map((e) => Duration(microseconds: e as int)) + ?.map((e) => Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -277,7 +277,8 @@ SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( Map json) => SimpleClassOfDurationNullable( (json['value'] as List) - .map((e) => e == null ? null : Duration(microseconds: e as int)) + .map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -292,7 +293,8 @@ SimpleClassNullableOfDurationNullable Map json) => SimpleClassNullableOfDurationNullable( (json['value'] as List?) - ?.map((e) => e == null ? null : Duration(microseconds: e as int)) + ?.map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toList(), ); @@ -480,7 +482,7 @@ Map _$SimpleClassNullableOfFromJsonObjectParamToJson( SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => SimpleClassOfInt( - (json['value'] as List).map((e) => e as int).toList(), + (json['value'] as List).map((e) => (e as num).toInt()).toList(), ); Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => @@ -491,7 +493,9 @@ Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( Map json) => SimpleClassNullableOfInt( - (json['value'] as List?)?.map((e) => e as int).toList(), + (json['value'] as List?) + ?.map((e) => (e as num).toInt()) + .toList(), ); Map _$SimpleClassNullableOfIntToJson( @@ -503,7 +507,9 @@ Map _$SimpleClassNullableOfIntToJson( SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( Map json) => SimpleClassOfIntNullable( - (json['value'] as List).map((e) => e as int?).toList(), + (json['value'] as List) + .map((e) => (e as num?)?.toInt()) + .toList(), ); Map _$SimpleClassOfIntNullableToJson( @@ -515,7 +521,9 @@ Map _$SimpleClassOfIntNullableToJson( SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( Map json) => SimpleClassNullableOfIntNullable( - (json['value'] as List?)?.map((e) => e as int?).toList(), + (json['value'] as List?) + ?.map((e) => (e as num?)?.toInt()) + .toList(), ); Map _$SimpleClassNullableOfIntNullableToJson( @@ -623,7 +631,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => .map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -656,7 +664,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( ?.map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_map.g.dart b/json_serializable/test/supported_types/input.type_map.g.dart index 5f29d60ab..5c8a3ea82 100644 --- a/json_serializable/test/supported_types/input.type_map.g.dart +++ b/json_serializable/test/supported_types/input.type_map.g.dart @@ -1953,7 +1953,8 @@ SimpleClassOfBigIntToDuration _$SimpleClassOfBigIntToDurationFromJson( Map json) => SimpleClassOfBigIntToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(BigInt.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + BigInt.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -1969,8 +1970,8 @@ SimpleClassNullableOfBigIntToDuration Map json) => SimpleClassNullableOfBigIntToDuration( (json['value'] as Map?)?.map( - (k, e) => - MapEntry(BigInt.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + BigInt.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -1985,7 +1986,8 @@ SimpleClassOfDateTimeToDuration _$SimpleClassOfDateTimeToDurationFromJson( Map json) => SimpleClassOfDateTimeToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(DateTime.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + DateTime.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2001,8 +2003,8 @@ SimpleClassNullableOfDateTimeToDuration Map json) => SimpleClassNullableOfDateTimeToDuration( (json['value'] as Map?)?.map( - (k, e) => - MapEntry(DateTime.parse(k), Duration(microseconds: e as int)), + (k, e) => MapEntry( + DateTime.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2017,7 +2019,7 @@ SimpleClassOfDynamicToDuration _$SimpleClassOfDynamicToDurationFromJson( Map json) => SimpleClassOfDynamicToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2032,7 +2034,7 @@ SimpleClassNullableOfDynamicToDuration Map json) => SimpleClassNullableOfDynamicToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2047,7 +2049,7 @@ SimpleClassOfEnumTypeToDuration _$SimpleClassOfEnumTypeToDurationFromJson( SimpleClassOfEnumTypeToDuration( (json['value'] as Map).map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - Duration(microseconds: e as int)), + Duration(microseconds: (e as num).toInt())), ), ); @@ -2064,7 +2066,7 @@ SimpleClassNullableOfEnumTypeToDuration SimpleClassNullableOfEnumTypeToDuration( (json['value'] as Map?)?.map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - Duration(microseconds: e as int)), + Duration(microseconds: (e as num).toInt())), ), ); @@ -2079,7 +2081,8 @@ SimpleClassOfIntToDuration _$SimpleClassOfIntToDurationFromJson( Map json) => SimpleClassOfIntToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(int.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(int.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2094,7 +2097,8 @@ SimpleClassNullableOfIntToDuration _$SimpleClassNullableOfIntToDurationFromJson( Map json) => SimpleClassNullableOfIntToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(int.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2109,7 +2113,7 @@ SimpleClassOfObjectToDuration _$SimpleClassOfObjectToDurationFromJson( Map json) => SimpleClassOfObjectToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2124,7 +2128,7 @@ SimpleClassNullableOfObjectToDuration Map json) => SimpleClassNullableOfObjectToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2138,7 +2142,7 @@ SimpleClassOfStringToDuration _$SimpleClassOfStringToDurationFromJson( Map json) => SimpleClassOfStringToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2153,7 +2157,7 @@ SimpleClassNullableOfStringToDuration Map json) => SimpleClassNullableOfStringToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, Duration(microseconds: e as int)), + (k, e) => MapEntry(k, Duration(microseconds: (e as num).toInt())), ), ); @@ -2167,7 +2171,8 @@ SimpleClassOfUriToDuration _$SimpleClassOfUriToDurationFromJson( Map json) => SimpleClassOfUriToDuration( (json['value'] as Map).map( - (k, e) => MapEntry(Uri.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(Uri.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2182,7 +2187,8 @@ SimpleClassNullableOfUriToDuration _$SimpleClassNullableOfUriToDurationFromJson( Map json) => SimpleClassNullableOfUriToDuration( (json['value'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), Duration(microseconds: e as int)), + (k, e) => + MapEntry(Uri.parse(k), Duration(microseconds: (e as num).toInt())), ), ); @@ -2199,7 +2205,7 @@ SimpleClassOfBigIntToDurationNullable SimpleClassOfBigIntToDurationNullable( (json['value'] as Map).map( (k, e) => MapEntry(BigInt.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2216,7 +2222,7 @@ SimpleClassNullableOfBigIntToDurationNullable SimpleClassNullableOfBigIntToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(BigInt.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2233,7 +2239,7 @@ SimpleClassOfDateTimeToDurationNullable SimpleClassOfDateTimeToDurationNullable( (json['value'] as Map).map( (k, e) => MapEntry(DateTime.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2250,7 +2256,7 @@ SimpleClassNullableOfDateTimeToDurationNullable SimpleClassNullableOfDateTimeToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(DateTime.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2266,8 +2272,8 @@ SimpleClassOfDynamicToDurationNullable Map json) => SimpleClassOfDynamicToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2282,8 +2288,8 @@ SimpleClassNullableOfDynamicToDurationNullable Map json) => SimpleClassNullableOfDynamicToDurationNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2299,7 +2305,7 @@ SimpleClassOfEnumTypeToDurationNullable SimpleClassOfEnumTypeToDurationNullable( (json['value'] as Map).map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2316,7 +2322,7 @@ SimpleClassNullableOfEnumTypeToDurationNullable SimpleClassNullableOfEnumTypeToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2331,8 +2337,8 @@ SimpleClassOfIntToDurationNullable _$SimpleClassOfIntToDurationNullableFromJson( Map json) => SimpleClassOfIntToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - int.parse(k), e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(int.parse(k), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2349,7 +2355,7 @@ SimpleClassNullableOfIntToDurationNullable SimpleClassNullableOfIntToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(int.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2365,8 +2371,8 @@ SimpleClassOfObjectToDurationNullable Map json) => SimpleClassOfObjectToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2381,8 +2387,8 @@ SimpleClassNullableOfObjectToDurationNullable Map json) => SimpleClassNullableOfObjectToDurationNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2397,8 +2403,8 @@ SimpleClassOfStringToDurationNullable Map json) => SimpleClassOfStringToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2413,8 +2419,8 @@ SimpleClassNullableOfStringToDurationNullable Map json) => SimpleClassNullableOfStringToDurationNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry( - k, e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(k, + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2428,8 +2434,8 @@ SimpleClassOfUriToDurationNullable _$SimpleClassOfUriToDurationNullableFromJson( Map json) => SimpleClassOfUriToDurationNullable( (json['value'] as Map).map( - (k, e) => MapEntry( - Uri.parse(k), e == null ? null : Duration(microseconds: e as int)), + (k, e) => MapEntry(Uri.parse(k), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -2446,7 +2452,7 @@ SimpleClassNullableOfUriToDurationNullable SimpleClassNullableOfUriToDurationNullable( (json['value'] as Map?)?.map( (k, e) => MapEntry(Uri.parse(k), - e == null ? null : Duration(microseconds: e as int)), + e == null ? null : Duration(microseconds: (e as num).toInt())), ), ); @@ -3943,7 +3949,7 @@ SimpleClassOfBigIntToInt _$SimpleClassOfBigIntToIntFromJson( Map json) => SimpleClassOfBigIntToInt( (json['value'] as Map).map( - (k, e) => MapEntry(BigInt.parse(k), e as int), + (k, e) => MapEntry(BigInt.parse(k), (e as num).toInt()), ), ); @@ -3957,7 +3963,7 @@ SimpleClassNullableOfBigIntToInt _$SimpleClassNullableOfBigIntToIntFromJson( Map json) => SimpleClassNullableOfBigIntToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k), e as int), + (k, e) => MapEntry(BigInt.parse(k), (e as num).toInt()), ), ); @@ -3971,7 +3977,7 @@ SimpleClassOfDateTimeToInt _$SimpleClassOfDateTimeToIntFromJson( Map json) => SimpleClassOfDateTimeToInt( (json['value'] as Map).map( - (k, e) => MapEntry(DateTime.parse(k), e as int), + (k, e) => MapEntry(DateTime.parse(k), (e as num).toInt()), ), ); @@ -3985,7 +3991,7 @@ SimpleClassNullableOfDateTimeToInt _$SimpleClassNullableOfDateTimeToIntFromJson( Map json) => SimpleClassNullableOfDateTimeToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k), e as int), + (k, e) => MapEntry(DateTime.parse(k), (e as num).toInt()), ), ); @@ -4011,7 +4017,7 @@ SimpleClassNullableOfDynamicToInt _$SimpleClassNullableOfDynamicToIntFromJson( Map json) => SimpleClassNullableOfDynamicToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ), ); @@ -4025,7 +4031,8 @@ SimpleClassOfEnumTypeToInt _$SimpleClassOfEnumTypeToIntFromJson( Map json) => SimpleClassOfEnumTypeToInt( (json['value'] as Map).map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$EnumTypeEnumMap, k), (e as num).toInt()), ), ); @@ -4039,7 +4046,8 @@ SimpleClassNullableOfEnumTypeToInt _$SimpleClassNullableOfEnumTypeToIntFromJson( Map json) => SimpleClassNullableOfEnumTypeToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int), + (k, e) => + MapEntry($enumDecode(_$EnumTypeEnumMap, k), (e as num).toInt()), ), ); @@ -4054,7 +4062,7 @@ SimpleClassOfIntToInt _$SimpleClassOfIntToIntFromJson( Map json) => SimpleClassOfIntToInt( (json['value'] as Map).map( - (k, e) => MapEntry(int.parse(k), e as int), + (k, e) => MapEntry(int.parse(k), (e as num).toInt()), ), ); @@ -4068,7 +4076,7 @@ SimpleClassNullableOfIntToInt _$SimpleClassNullableOfIntToIntFromJson( Map json) => SimpleClassNullableOfIntToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), e as int), + (k, e) => MapEntry(int.parse(k), (e as num).toInt()), ), ); @@ -4094,7 +4102,7 @@ SimpleClassNullableOfObjectToInt _$SimpleClassNullableOfObjectToIntFromJson( Map json) => SimpleClassNullableOfObjectToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ), ); @@ -4120,7 +4128,7 @@ SimpleClassNullableOfStringToInt _$SimpleClassNullableOfStringToIntFromJson( Map json) => SimpleClassNullableOfStringToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int), + (k, e) => MapEntry(k, (e as num).toInt()), ), ); @@ -4134,7 +4142,7 @@ SimpleClassOfUriToInt _$SimpleClassOfUriToIntFromJson( Map json) => SimpleClassOfUriToInt( (json['value'] as Map).map( - (k, e) => MapEntry(Uri.parse(k), e as int), + (k, e) => MapEntry(Uri.parse(k), (e as num).toInt()), ), ); @@ -4148,7 +4156,7 @@ SimpleClassNullableOfUriToInt _$SimpleClassNullableOfUriToIntFromJson( Map json) => SimpleClassNullableOfUriToInt( (json['value'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), e as int), + (k, e) => MapEntry(Uri.parse(k), (e as num).toInt()), ), ); @@ -4162,7 +4170,7 @@ SimpleClassOfBigIntToIntNullable _$SimpleClassOfBigIntToIntNullableFromJson( Map json) => SimpleClassOfBigIntToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(BigInt.parse(k), e as int?), + (k, e) => MapEntry(BigInt.parse(k), (e as num?)?.toInt()), ), ); @@ -4177,7 +4185,7 @@ SimpleClassNullableOfBigIntToIntNullable Map json) => SimpleClassNullableOfBigIntToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(BigInt.parse(k), e as int?), + (k, e) => MapEntry(BigInt.parse(k), (e as num?)?.toInt()), ), ); @@ -4191,7 +4199,7 @@ SimpleClassOfDateTimeToIntNullable _$SimpleClassOfDateTimeToIntNullableFromJson( Map json) => SimpleClassOfDateTimeToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(DateTime.parse(k), e as int?), + (k, e) => MapEntry(DateTime.parse(k), (e as num?)?.toInt()), ), ); @@ -4206,7 +4214,7 @@ SimpleClassNullableOfDateTimeToIntNullable Map json) => SimpleClassNullableOfDateTimeToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(DateTime.parse(k), e as int?), + (k, e) => MapEntry(DateTime.parse(k), (e as num?)?.toInt()), ), ); @@ -4233,7 +4241,7 @@ SimpleClassNullableOfDynamicToIntNullable Map json) => SimpleClassNullableOfDynamicToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int?), + (k, e) => MapEntry(k, (e as num?)?.toInt()), ), ); @@ -4247,7 +4255,8 @@ SimpleClassOfEnumTypeToIntNullable _$SimpleClassOfEnumTypeToIntNullableFromJson( Map json) => SimpleClassOfEnumTypeToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int?), + (k, e) => + MapEntry($enumDecode(_$EnumTypeEnumMap, k), (e as num?)?.toInt()), ), ); @@ -4262,7 +4271,8 @@ SimpleClassNullableOfEnumTypeToIntNullable Map json) => SimpleClassNullableOfEnumTypeToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry($enumDecode(_$EnumTypeEnumMap, k), e as int?), + (k, e) => MapEntry( + $enumDecode(_$EnumTypeEnumMap, k), (e as num?)?.toInt()), ), ); @@ -4277,7 +4287,7 @@ SimpleClassOfIntToIntNullable _$SimpleClassOfIntToIntNullableFromJson( Map json) => SimpleClassOfIntToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(int.parse(k), e as int?), + (k, e) => MapEntry(int.parse(k), (e as num?)?.toInt()), ), ); @@ -4292,7 +4302,7 @@ SimpleClassNullableOfIntToIntNullable Map json) => SimpleClassNullableOfIntToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(int.parse(k), e as int?), + (k, e) => MapEntry(int.parse(k), (e as num?)?.toInt()), ), ); @@ -4319,7 +4329,7 @@ SimpleClassNullableOfObjectToIntNullable Map json) => SimpleClassNullableOfObjectToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int?), + (k, e) => MapEntry(k, (e as num?)?.toInt()), ), ); @@ -4346,7 +4356,7 @@ SimpleClassNullableOfStringToIntNullable Map json) => SimpleClassNullableOfStringToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(k, e as int?), + (k, e) => MapEntry(k, (e as num?)?.toInt()), ), ); @@ -4360,7 +4370,7 @@ SimpleClassOfUriToIntNullable _$SimpleClassOfUriToIntNullableFromJson( Map json) => SimpleClassOfUriToIntNullable( (json['value'] as Map).map( - (k, e) => MapEntry(Uri.parse(k), e as int?), + (k, e) => MapEntry(Uri.parse(k), (e as num?)?.toInt()), ), ); @@ -4375,7 +4385,7 @@ SimpleClassNullableOfUriToIntNullable Map json) => SimpleClassNullableOfUriToIntNullable( (json['value'] as Map?)?.map( - (k, e) => MapEntry(Uri.parse(k), e as int?), + (k, e) => MapEntry(Uri.parse(k), (e as num?)?.toInt()), ), ); @@ -5290,7 +5300,7 @@ SimpleClassOfBigIntToRecord _$SimpleClassOfBigIntToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5324,7 +5334,7 @@ SimpleClassNullableOfBigIntToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5352,7 +5362,7 @@ SimpleClassOfDateTimeToRecord _$SimpleClassOfDateTimeToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5381,7 +5391,7 @@ SimpleClassNullableOfDateTimeToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5409,7 +5419,7 @@ SimpleClassOfDynamicToRecord _$SimpleClassOfDynamicToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5436,7 +5446,7 @@ SimpleClassNullableOfDynamicToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5463,7 +5473,7 @@ SimpleClassOfEnumTypeToRecord _$SimpleClassOfEnumTypeToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5492,7 +5502,7 @@ SimpleClassNullableOfEnumTypeToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5520,7 +5530,7 @@ SimpleClassOfIntToRecord _$SimpleClassOfIntToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5548,7 +5558,7 @@ SimpleClassNullableOfIntToRecord _$SimpleClassNullableOfIntToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5576,7 +5586,7 @@ SimpleClassOfObjectToRecord _$SimpleClassOfObjectToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5603,7 +5613,7 @@ SimpleClassNullableOfObjectToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5630,7 +5640,7 @@ SimpleClassOfStringToRecord _$SimpleClassOfStringToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5657,7 +5667,7 @@ SimpleClassNullableOfStringToRecord _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5684,7 +5694,7 @@ SimpleClassOfUriToRecord _$SimpleClassOfUriToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -5712,7 +5722,7 @@ SimpleClassNullableOfUriToRecord _$SimpleClassNullableOfUriToRecordFromJson( _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_record.g.dart b/json_serializable/test/supported_types/input.type_record.g.dart index 5c96d58c8..bc37b7cd2 100644 --- a/json_serializable/test/supported_types/input.type_record.g.dart +++ b/json_serializable/test/supported_types/input.type_record.g.dart @@ -411,8 +411,8 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( _$recordConvert( json['value'], ($jsonValue) => ( - Duration(microseconds: $jsonValue[r'$1'] as int), - named: Duration(microseconds: $jsonValue['named'] as int), + Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), + named: Duration(microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -432,8 +432,8 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( _$recordConvertNullable( json['value'], ($jsonValue) => ( - Duration(microseconds: $jsonValue[r'$1'] as int), - named: Duration(microseconds: $jsonValue['named'] as int), + Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), + named: Duration(microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -457,10 +457,10 @@ SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( ($jsonValue) => ( $jsonValue[r'$1'] == null ? null - : Duration(microseconds: $jsonValue[r'$1'] as int), + : Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), named: $jsonValue['named'] == null ? null - : Duration(microseconds: $jsonValue['named'] as int), + : Duration(microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -483,10 +483,11 @@ SimpleClassNullableOfDurationNullable ($jsonValue) => ( $jsonValue[r'$1'] == null ? null - : Duration(microseconds: $jsonValue[r'$1'] as int), + : Duration(microseconds: ($jsonValue[r'$1'] as num).toInt()), named: $jsonValue['named'] == null ? null - : Duration(microseconds: $jsonValue['named'] as int), + : Duration( + microseconds: ($jsonValue['named'] as num).toInt()), ), ), ); @@ -785,8 +786,8 @@ SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => _$recordConvert( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, - named: $jsonValue['named'] as int, + ($jsonValue[r'$1'] as num).toInt(), + named: ($jsonValue['named'] as num).toInt(), ), ), ); @@ -805,8 +806,8 @@ SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( _$recordConvertNullable( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, - named: $jsonValue['named'] as int, + ($jsonValue[r'$1'] as num).toInt(), + named: ($jsonValue['named'] as num).toInt(), ), ), ); @@ -828,8 +829,8 @@ SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( _$recordConvert( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int?, - named: $jsonValue['named'] as int?, + ($jsonValue[r'$1'] as num?)?.toInt(), + named: ($jsonValue['named'] as num?)?.toInt(), ), ), ); @@ -849,8 +850,8 @@ SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( _$recordConvertNullable( json['value'], ($jsonValue) => ( - $jsonValue[r'$1'] as int?, - named: $jsonValue['named'] as int?, + ($jsonValue[r'$1'] as num?)?.toInt(), + named: ($jsonValue['named'] as num?)?.toInt(), ), ), ); @@ -1047,7 +1048,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => _$recordConvert( $jsonValue[r'$1'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -1055,7 +1056,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => named: _$recordConvert( $jsonValue['named'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -1090,7 +1091,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( _$recordConvert( $jsonValue[r'$1'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -1098,7 +1099,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( named: _$recordConvert( $jsonValue['named'], ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/test/supported_types/input.type_set.g.dart b/json_serializable/test/supported_types/input.type_set.g.dart index 73866adf9..234afad93 100644 --- a/json_serializable/test/supported_types/input.type_set.g.dart +++ b/json_serializable/test/supported_types/input.type_set.g.dart @@ -251,7 +251,7 @@ SimpleClassOfDuration _$SimpleClassOfDurationFromJson( Map json) => SimpleClassOfDuration( (json['value'] as List) - .map((e) => Duration(microseconds: e as int)) + .map((e) => Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -265,7 +265,7 @@ SimpleClassNullableOfDuration _$SimpleClassNullableOfDurationFromJson( Map json) => SimpleClassNullableOfDuration( (json['value'] as List?) - ?.map((e) => Duration(microseconds: e as int)) + ?.map((e) => Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -279,7 +279,8 @@ SimpleClassOfDurationNullable _$SimpleClassOfDurationNullableFromJson( Map json) => SimpleClassOfDurationNullable( (json['value'] as List) - .map((e) => e == null ? null : Duration(microseconds: e as int)) + .map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -294,7 +295,8 @@ SimpleClassNullableOfDurationNullable Map json) => SimpleClassNullableOfDurationNullable( (json['value'] as List?) - ?.map((e) => e == null ? null : Duration(microseconds: e as int)) + ?.map((e) => + e == null ? null : Duration(microseconds: (e as num).toInt())) .toSet(), ); @@ -482,7 +484,7 @@ Map _$SimpleClassNullableOfFromJsonObjectParamToJson( SimpleClassOfInt _$SimpleClassOfIntFromJson(Map json) => SimpleClassOfInt( - (json['value'] as List).map((e) => e as int).toSet(), + (json['value'] as List).map((e) => (e as num).toInt()).toSet(), ); Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => @@ -493,7 +495,7 @@ Map _$SimpleClassOfIntToJson(SimpleClassOfInt instance) => SimpleClassNullableOfInt _$SimpleClassNullableOfIntFromJson( Map json) => SimpleClassNullableOfInt( - (json['value'] as List?)?.map((e) => e as int).toSet(), + (json['value'] as List?)?.map((e) => (e as num).toInt()).toSet(), ); Map _$SimpleClassNullableOfIntToJson( @@ -505,7 +507,7 @@ Map _$SimpleClassNullableOfIntToJson( SimpleClassOfIntNullable _$SimpleClassOfIntNullableFromJson( Map json) => SimpleClassOfIntNullable( - (json['value'] as List).map((e) => e as int?).toSet(), + (json['value'] as List).map((e) => (e as num?)?.toInt()).toSet(), ); Map _$SimpleClassOfIntNullableToJson( @@ -517,7 +519,9 @@ Map _$SimpleClassOfIntNullableToJson( SimpleClassNullableOfIntNullable _$SimpleClassNullableOfIntNullableFromJson( Map json) => SimpleClassNullableOfIntNullable( - (json['value'] as List?)?.map((e) => e as int?).toSet(), + (json['value'] as List?) + ?.map((e) => (e as num?)?.toInt()) + .toSet(), ); Map _$SimpleClassNullableOfIntNullableToJson( @@ -625,7 +629,7 @@ SimpleClassOfRecord _$SimpleClassOfRecordFromJson(Map json) => .map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), @@ -658,7 +662,7 @@ SimpleClassNullableOfRecord _$SimpleClassNullableOfRecordFromJson( ?.map((e) => _$recordConvert( e, ($jsonValue) => ( - $jsonValue[r'$1'] as int, + ($jsonValue[r'$1'] as num).toInt(), $jsonValue[r'$2'] as String, truth: $jsonValue['truth'] as bool, ), diff --git a/json_serializable/tool/readme/readme_examples.g.dart b/json_serializable/tool/readme/readme_examples.g.dart index c22e9025b..b3a60ab36 100644 --- a/json_serializable/tool/readme/readme_examples.g.dart +++ b/json_serializable/tool/readme/readme_examples.g.dart @@ -9,7 +9,7 @@ part of 'readme_examples.dart'; // ************************************************************************** Sample1 _$Sample1FromJson(Map json) => Sample1( - Sample2.fromJson(json['value'] as int), + Sample2.fromJson((json['value'] as num).toInt()), ); Map _$Sample1ToJson(Sample1 instance) => { @@ -17,7 +17,7 @@ Map _$Sample1ToJson(Sample1 instance) => { }; Sample3 _$Sample3FromJson(Map json) => Sample3( - Sample3._fromJson(json['value'] as int), + Sample3._fromJson((json['value'] as num).toInt()), ); Map _$Sample3ToJson(Sample3 instance) => { @@ -25,7 +25,7 @@ Map _$Sample3ToJson(Sample3 instance) => { }; Sample4 _$Sample4FromJson(Map json) => Sample4( - const EpochDateTimeConverter().fromJson(json['value'] as int), + const EpochDateTimeConverter().fromJson((json['value'] as num).toInt()), ); Map _$Sample4ToJson(Sample4 instance) => { From eea959d5f9e971faae8887bc5aaa42b00534972e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 24 Apr 2024 12:47:41 -0700 Subject: [PATCH 30/42] json_annotation: prepare to release v4.9.0 (#1417) --- json_annotation/CHANGELOG.md | 4 ++-- json_annotation/lib/src/json_serializable.dart | 13 ++++++++----- json_annotation/pubspec.yaml | 2 +- json_serializable/CHANGELOG.md | 5 ++--- json_serializable/README.md | 18 +++++++++--------- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/json_annotation/CHANGELOG.md b/json_annotation/CHANGELOG.md index 1b3d6be21..3b95a5887 100644 --- a/json_annotation/CHANGELOG.md +++ b/json_annotation/CHANGELOG.md @@ -1,7 +1,7 @@ -## 4.9.0-wip +## 4.9.0 - Require Dart 3.0 -- Added `JsonSerializable(createJsonKeys: true)`. +- Add `JsonSerializable(createJsonKeys: true)`. ([#1401](https://github.com/google/json_serializable.dart/pull/1401)) ## 4.8.1 diff --git a/json_annotation/lib/src/json_serializable.dart b/json_annotation/lib/src/json_serializable.dart index 91600f097..fb4d8eade 100644 --- a/json_annotation/lib/src/json_serializable.dart +++ b/json_annotation/lib/src/json_serializable.dart @@ -88,16 +88,19 @@ class JsonSerializable { final bool? createFieldMap; /// If `true` (defaults to false), a private class `_$ExampleJsonKeys` - /// constant is created in the generated part file. + /// class is created in the generated part file. /// - /// This class will contain every property, with the json key as value, - /// exposing a secured way to access the json key from the property. + /// This class will contain every property as a [String] field with the JSON + /// key as the value. /// /// ```dart /// @JsonSerializable(createJsonKeys: true) /// class Example { - /// // ... - /// static const jsonKeys = _$PublicationImplJsonKeys(); + /// @JsonKey(name: 'LAST_NAME') + /// String? firstName; + /// + /// // Will have the value `LAST_NAME` + /// static const firstName = _$ExampleJsonKeys.firstName; /// } /// ``` final bool? createJsonKeys; diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index aabbd9681..5d748a0e9 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -1,5 +1,5 @@ name: json_annotation -version: 4.9.0-wip +version: 4.9.0 description: >- Classes and helper functions that support JSON code generation via the `json_serializable` package. diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 9ae8f098d..77bf34c15 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,9 +1,8 @@ ## 6.8.0-wip - Add type arguments to `Map` literals used for `Record` serialization. -- Added support for generating `ExampleJsonKeys`, exposing a secured way to - access the json keys from the properties. - ([#1164](https://github.com/google/json_serializable.dart/pull/1164)) +- Add support for `JsonSerializable(createJsonKeys: true)`. + ([#1401](https://github.com/google/json_serializable.dart/pull/1401)) - Handle decoding an `int` value from a `double` literal. This now matches the behavior of `double` values being encoded as `int`. diff --git a/json_serializable/README.md b/json_serializable/README.md index 5d30efd16..d30a13659 100644 --- a/json_serializable/README.md +++ b/json_serializable/README.md @@ -298,15 +298,15 @@ targets: [`Enum`]: https://api.dart.dev/stable/dart-core/Enum-class.html [`int`]: https://api.dart.dev/stable/dart-core/int-class.html [`Iterable`]: https://api.dart.dev/stable/dart-core/Iterable-class.html -[`JsonConverter`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html -[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum/valueField.html -[`JsonEnum`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum-class.html -[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html -[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html -[`JsonKey`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey-class.html -[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonLiteral-class.html -[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonSerializable-class.html -[`JsonValue`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonValue-class.html +[`JsonConverter`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonConverter-class.html +[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonEnum/valueField.html +[`JsonEnum`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonEnum-class.html +[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey/fromJson.html +[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey/toJson.html +[`JsonKey`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey-class.html +[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonLiteral-class.html +[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonSerializable-class.html +[`JsonValue`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonValue-class.html [`List`]: https://api.dart.dev/stable/dart-core/List-class.html [`Map`]: https://api.dart.dev/stable/dart-core/Map-class.html [`num`]: https://api.dart.dev/stable/dart-core/num-class.html From 9694cc5d5ebd08e131484c7de7784eefcc45db37 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 24 Apr 2024 13:15:13 -0700 Subject: [PATCH 31/42] json_serializable: publish v6.8.0 (#1418) --- json_serializable/CHANGELOG.md | 2 +- json_serializable/lib/src/check_dependencies.dart | 2 +- json_serializable/pubspec.yaml | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 77bf34c15..36ae2f96c 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,4 +1,4 @@ -## 6.8.0-wip +## 6.8.0 - Add type arguments to `Map` literals used for `Record` serialization. - Add support for `JsonSerializable(createJsonKeys: true)`. diff --git a/json_serializable/lib/src/check_dependencies.dart b/json_serializable/lib/src/check_dependencies.dart index 63512589d..7ea84bef4 100644 --- a/json_serializable/lib/src/check_dependencies.dart +++ b/json_serializable/lib/src/check_dependencies.dart @@ -10,7 +10,7 @@ import 'package:pubspec_parse/pubspec_parse.dart'; const _productionDirectories = {'lib', 'bin'}; const _annotationPkgName = 'json_annotation'; -final requiredJsonAnnotationMinVersion = Version.parse('4.8.1'); +final requiredJsonAnnotationMinVersion = Version.parse('4.9.0'); Future pubspecHasRightVersion(BuildStep buildStep) async { final segments = buildStep.inputId.pathSegments; diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 307e1f76c..e6d66865d 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -1,5 +1,5 @@ name: json_serializable -version: 6.8.0-wip +version: 6.8.0 description: >- Automatically generate code for converting to and from JSON by annotating Dart classes. @@ -21,7 +21,7 @@ dependencies: # Use a tight version constraint to ensure that a constraint on # `json_annotation` properly constrains all features it provides. - json_annotation: '>=4.8.1 <4.9.0' + json_annotation: '>=4.9.0 <4.10.0' meta: ^1.3.0 path: ^1.8.0 pub_semver: ^2.0.0 @@ -29,10 +29,6 @@ dependencies: source_gen: ^1.3.2 source_helper: ^1.3.0 -dependency_overrides: - json_annotation: - path: ../json_annotation - dev_dependencies: _json_serial_shared_test: path: ../shared_test From 02e17e56c5364ea734444148493c36939bc78648 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 24 Apr 2024 14:07:37 -0700 Subject: [PATCH 32/42] checked_yaml: fix test source (#1419) --- checked_yaml/example/example.g.dart | 2 +- checked_yaml/test/example_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/checked_yaml/example/example.g.dart b/checked_yaml/example/example.g.dart index c4d01aefb..96f10dae8 100644 --- a/checked_yaml/example/example.g.dart +++ b/checked_yaml/example/example.g.dart @@ -17,7 +17,7 @@ Configuration _$ConfigurationFromJson(Map json) => $checkedCreate( ); final val = Configuration( name: $checkedConvert('name', (v) => v as String), - count: $checkedConvert('count', (v) => v as int), + count: $checkedConvert('count', (v) => (v as num).toInt()), ); return val; }, diff --git a/checked_yaml/test/example_test.dart b/checked_yaml/test/example_test.dart index 08ff6f358..7761c36f5 100644 --- a/checked_yaml/test/example_test.dart +++ b/checked_yaml/test/example_test.dart @@ -33,7 +33,7 @@ line 1, column 1: Required keys are missing: name. _expectThrows( '{"name":"something"}', r''' -line 1, column 1: Missing key "count". type 'Null' is not a subtype of type 'int' in type cast +line 1, column 1: Missing key "count". type 'Null' is not a subtype of type 'num' in type cast ╷ 1 │ {"name":"something"} │ ^^^^^^^^^^^^^^^^^^^^ From 629d369f1f225da0b14c970a70d91c15cdc18c9b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 20 May 2024 14:13:02 -0700 Subject: [PATCH 33/42] Update analyzer version and min SDK constraint and fix analysis issues (#1428) --- .github/workflows/dart.yml | 64 +++++++++---------- _test_yaml/pubspec.yaml | 14 ++-- _test_yaml/test/ensure_build_test.dart | 2 +- _test_yaml/test/yaml_test.dart | 2 +- checked_yaml/CHANGELOG.md | 2 +- checked_yaml/pubspec.yaml | 10 +-- checked_yaml/test/ensure_build_test.dart | 2 +- example/README.md | 4 +- example/pubspec.yaml | 10 +-- example/test/ensure_build_test.dart | 2 +- example/test/readme_test.dart | 4 +- json_annotation/CHANGELOG.md | 4 ++ json_annotation/lib/json_annotation.dart | 2 +- json_annotation/pubspec.yaml | 6 +- json_serializable/CHANGELOG.md | 4 ++ json_serializable/lib/builder.dart | 2 +- json_serializable/lib/src/decode_helper.dart | 5 +- json_serializable/lib/src/field_helpers.dart | 4 +- json_serializable/lib/src/helper_core.dart | 2 +- json_serializable/lib/src/json_key_utils.dart | 4 +- .../lib/src/json_serializable_generator.dart | 8 --- .../type_helpers/generic_factory_helper.dart | 5 +- .../lib/src/type_helpers/map_helper.dart | 2 +- json_serializable/lib/src/utils.dart | 8 ++- json_serializable/pubspec.yaml | 34 +++++----- .../test/annotation_version_test.dart | 2 +- json_serializable/test/config_test.dart | 2 +- .../test/custom_configuration_test.dart | 2 +- json_serializable/test/ensure_build_test.dart | 2 +- json_serializable/test/enum_helper_test.dart | 2 +- .../test/json_serializable_test.dart | 2 +- .../test/literal/json_literal_test.dart | 2 +- .../test/supported_types/extra_map_test.dart | 2 +- .../type_test.bigint_test.dart | 2 +- .../supported_types/type_test.bool_test.dart | 2 +- .../test/supported_types/type_test.dart | 2 +- .../type_test.datetime_test.dart | 2 +- .../type_test.double_test.dart | 2 +- .../type_test.duration_test.dart | 2 +- .../type_test.enumtype_test.dart | 2 +- .../supported_types/type_test.int_test.dart | 2 +- .../type_test.iterable_test.dart | 2 +- .../supported_types/type_test.list_test.dart | 2 +- .../supported_types/type_test.map_test.dart | 2 +- .../supported_types/type_test.num_test.dart | 2 +- .../type_test.object_test.dart | 2 +- .../supported_types/type_test.set_test.dart | 2 +- .../type_test.string_test.dart | 2 +- .../supported_types/type_test.uri_test.dart | 2 +- shared_test/pubspec.yaml | 4 +- tool/ci.sh | 18 ++---- 51 files changed, 141 insertions(+), 135 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 0be82d568..121296a69 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,4 +1,4 @@ -# Created with package:mono_repo v6.5.7 +# Created with package:mono_repo v6.6.1 name: Dart CI on: push: @@ -36,27 +36,27 @@ jobs: name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: mono_repo self validate - run: dart pub global activate mono_repo 6.5.7 + run: dart pub global activate mono_repo 6.6.1 - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyzer_and_format; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`" + name: "analyzer_and_format; Dart 3.4.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -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.0.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" + name: "unit_test; Dart 3.4.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -253,23 +253,23 @@ jobs: - job_002 - job_003 job_005: - name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" + name: "unit_test; Dart 3.4.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_3" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_3" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -287,23 +287,23 @@ jobs: - job_002 - job_003 job_006: - name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "unit_test; Dart 3.4.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -321,23 +321,23 @@ jobs: - job_002 - job_003 job_007: - name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test -p chrome`" + name: "unit_test; Dart 3.4.0; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_2" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -518,23 +518,23 @@ jobs: - job_002 - job_003 job_012: - name: "ensure_build; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "ensure_build; Dart 3.4.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index 57f7a275b..8bf18a935 100644 --- a/_test_yaml/pubspec.yaml +++ b/_test_yaml/pubspec.yaml @@ -2,19 +2,19 @@ name: _test_yaml publish_to: none environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dev_dependencies: _json_serial_shared_test: path: ../shared_test - build_runner: ^2.0.0 + build_runner: ^2.2.1 build_verify: ^3.0.0 - checked_yaml: any - dart_flutter_team_lints: ^2.0.0 - json_annotation: ^4.8.1 - json_serializable: any + checked_yaml: ^2.0.4-wip + dart_flutter_team_lints: ^3.0.0 + json_annotation: ^4.9.0 + json_serializable: ^6.8.0 path: ^1.8.2 - test: ^1.6.0 + test: ^1.21.6 yaml: ^3.0.0 dependency_overrides: diff --git a/_test_yaml/test/ensure_build_test.dart b/_test_yaml/test/ensure_build_test.dart index 868332ed6..406a1aa77 100644 --- a/_test_yaml/test/ensure_build_test.dart +++ b/_test_yaml/test/ensure_build_test.dart @@ -4,7 +4,7 @@ @TestOn('vm') @Tags(['presubmit-only']) -library test; +library; import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/_test_yaml/test/yaml_test.dart b/_test_yaml/test/yaml_test.dart index 96f698b05..29856bf8c 100644 --- a/_test_yaml/test/yaml_test.dart +++ b/_test_yaml/test/yaml_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -library test; +library; import 'dart:io'; diff --git a/checked_yaml/CHANGELOG.md b/checked_yaml/CHANGELOG.md index 18603be88..543b0ce5e 100644 --- a/checked_yaml/CHANGELOG.md +++ b/checked_yaml/CHANGELOG.md @@ -1,6 +1,6 @@ ## 2.0.4-wip -- Require Dart 3.0 +- Require Dart 3.4 ## 2.0.3 diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index 821c9de5e..2be93cc62 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -13,7 +13,7 @@ topics: - codegen environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: json_annotation: ^4.3.0 @@ -21,12 +21,12 @@ dependencies: yaml: ^3.0.0 dev_dependencies: - build_runner: ^2.0.0 + build_runner: ^2.0.6 build_verify: ^3.0.0 - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 json_serializable: ^6.0.0 - path: ^1.0.0 - test: ^1.16.0 + path: ^1.8.0 + test: ^1.17.10 test_process: ^2.0.0 #dependency_overrides: diff --git a/checked_yaml/test/ensure_build_test.dart b/checked_yaml/test/ensure_build_test.dart index 0a5935d7b..ec5871f3c 100644 --- a/checked_yaml/test/ensure_build_test.dart +++ b/checked_yaml/test/ensure_build_test.dart @@ -4,7 +4,7 @@ @TestOn('vm') @Tags(['presubmit-only']) -library test; +library; import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/example/README.md b/example/README.md index bb6cf3c79..7eff2e695 100644 --- a/example/README.md +++ b/example/README.md @@ -5,11 +5,11 @@ dependencies to your `pubspec.yaml`. ```yaml dependencies: - json_annotation: ^4.8.0 + json_annotation: ^4.9.0 dev_dependencies: build_runner: ^2.3.3 - json_serializable: ^6.6.0 + json_serializable: ^6.8.0 ``` Annotate your code with classes defined in diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6191089bd..be24d38a3 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,10 +2,10 @@ name: example publish_to: none environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: - json_annotation: ^4.8.0 + json_annotation: ^4.9.0 dev_dependencies: # Used by tests. Not required to use `json_serializable`. @@ -19,14 +19,14 @@ dev_dependencies: build_verify: ^3.0.0 # Not required to use `json_serializable`. - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 # REQUIRED! - json_serializable: ^6.6.0 + json_serializable: ^6.8.0 # Not required to use `json_serializable`. path: ^1.8.0 - test: ^1.16.0 + test: ^1.21.6 # This section is used to verify changes to these packages. Do not include in # your code! diff --git a/example/test/ensure_build_test.dart b/example/test/ensure_build_test.dart index 5d06a2fd1..8d3d473e9 100644 --- a/example/test/ensure_build_test.dart +++ b/example/test/ensure_build_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @Tags(['presubmit-only']) -library test; +library; import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/example/test/readme_test.dart b/example/test/readme_test.dart index ab3267f8b..9ab00e93b 100644 --- a/example/test/readme_test.dart +++ b/example/test/readme_test.dart @@ -25,9 +25,9 @@ void _expect(String fileName) { const _pubspecContent = r''' dependencies: - json_annotation: ^4.8.0 + json_annotation: ^4.9.0 dev_dependencies: build_runner: ^2.3.3 - json_serializable: ^6.6.0 + json_serializable: ^6.8.0 '''; diff --git a/json_annotation/CHANGELOG.md b/json_annotation/CHANGELOG.md index 3b95a5887..911e1d671 100644 --- a/json_annotation/CHANGELOG.md +++ b/json_annotation/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.9.1-wip + +- Require Dart 3.4 + ## 4.9.0 - Require Dart 3.0 diff --git a/json_annotation/lib/json_annotation.dart b/json_annotation/lib/json_annotation.dart index 2dc5d00b1..05b3a8a8c 100644 --- a/json_annotation/lib/json_annotation.dart +++ b/json_annotation/lib/json_annotation.dart @@ -8,7 +8,7 @@ /// Also contains helper functions and classes – prefixed with `$` used by /// `json_serializable` when the `use_wrappers` or `checked` options are /// enabled. -library json_annotation; +library; export 'src/allowed_keys_helpers.dart'; export 'src/checked_helpers.dart'; diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index 5d748a0e9..917f8e111 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -1,5 +1,5 @@ name: json_annotation -version: 4.9.0 +version: 4.9.1-wip description: >- Classes and helper functions that support JSON code generation via the `json_serializable` package. @@ -11,13 +11,13 @@ topics: - codegen environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: meta: ^1.4.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 # When changing JsonSerializable class. # build_runner: ^2.0.0 # json_serializable: any diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 36ae2f96c..35c941633 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.8.1-wip + +- Require Dart 3.4 + ## 6.8.0 - Add type arguments to `Map` literals used for `Record` serialization. diff --git a/json_serializable/lib/builder.dart b/json_serializable/lib/builder.dart index 93a3aa2f5..833efcec3 100644 --- a/json_serializable/lib/builder.dart +++ b/json_serializable/lib/builder.dart @@ -10,7 +10,7 @@ /// This library is **not** intended to be imported by typical end-users unless /// you are creating a custom compilation pipeline. See documentation for /// details, and `build.yaml` for how these builders are configured by default. -library json_serializable.builder; +library; import 'package:build/build.dart'; import 'package:json_annotation/json_annotation.dart'; diff --git a/json_serializable/lib/src/decode_helper.dart b/json_serializable/lib/src/decode_helper.dart index a4a76d1ff..488e93ef3 100644 --- a/json_serializable/lib/src/decode_helper.dart +++ b/json_serializable/lib/src/decode_helper.dart @@ -61,7 +61,10 @@ mixin DecodeHelper implements HelperCore { config.constructor, accessibleFields.keys, accessibleFields.values - .where((fe) => element.lookUpSetter(fe.name, element.library) != null) + .where((fe) => + element.augmented + .lookUpSetter(name: fe.name, library: element.library) != + null) .map((fe) => fe.name) .toList(), unavailableReasons, diff --git a/json_serializable/lib/src/field_helpers.dart b/json_serializable/lib/src/field_helpers.dart index 4b6608f3f..f0b7828e9 100644 --- a/json_serializable/lib/src/field_helpers.dart +++ b/json_serializable/lib/src/field_helpers.dart @@ -88,8 +88,8 @@ List createSortedFieldSet(ClassElement element) { } if (v is PropertyAccessorElement && v.isGetter) { - assert(v.variable is FieldElement); - final variable = v.variable as FieldElement; + assert(v.variable2 is FieldElement); + final variable = v.variable2 as FieldElement; assert(!inheritedFields.containsKey(variable.name)); inheritedFields[variable.name] = variable; } diff --git a/json_serializable/lib/src/helper_core.dart b/json_serializable/lib/src/helper_core.dart index 5a8248c66..0a054f828 100644 --- a/json_serializable/lib/src/helper_core.dart +++ b/json_serializable/lib/src/helper_core.dart @@ -66,7 +66,7 @@ InvalidGenerationSourceError createInvalidGenerationError( String? todo; if (error.type is TypeParameterType) { message = '$message because of type ' - '`${error.type.getDisplayString(withNullability: false)}` ' + '`${error.type.toStringNonNullable()}` ' '(type parameter)'; todo = ''' diff --git a/json_serializable/lib/src/json_key_utils.dart b/json_serializable/lib/src/json_key_utils.dart index 42eb0cfce..addccaae8 100644 --- a/json_serializable/lib/src/json_key_utils.dart +++ b/json_serializable/lib/src/json_key_utils.dart @@ -176,9 +176,9 @@ KeyConfig _from(FieldElement element, ClassConfig classAnnotation) { throwUnsupported( element, '`$fieldName` has type ' - '`${targetEnumType.getDisplayString(withNullability: false)}`, but ' + '`${targetEnumType.toStringNonNullable()}`, but ' 'the provided unknownEnumValue is of type ' - '`${annotationType.getDisplayString(withNullability: false)}`.', + '`${annotationType.toStringNonNullable()}`.', ); } } diff --git a/json_serializable/lib/src/json_serializable_generator.dart b/json_serializable/lib/src/json_serializable_generator.dart index 611056131..2ff7b6dbf 100644 --- a/json_serializable/lib/src/json_serializable_generator.dart +++ b/json_serializable/lib/src/json_serializable_generator.dart @@ -61,14 +61,6 @@ class JsonSerializableGenerator ConstantReader annotation, BuildStep buildStep, ) { - if (!element.library!.isNonNullableByDefault) { - throw InvalidGenerationSourceError( - 'Generator cannot target libraries that have not been migrated to ' - 'null-safety.', - element: element, - ); - } - if (element is! ClassElement || element is EnumElement) { throw InvalidGenerationSourceError( '`@JsonSerializable` can only be used on classes.', diff --git a/json_serializable/lib/src/type_helpers/generic_factory_helper.dart b/json_serializable/lib/src/type_helpers/generic_factory_helper.dart index 3b807550c..6a005f4c6 100644 --- a/json_serializable/lib/src/type_helpers/generic_factory_helper.dart +++ b/json_serializable/lib/src/type_helpers/generic_factory_helper.dart @@ -7,6 +7,7 @@ import 'package:source_helper/source_helper.dart'; import '../lambda_result.dart'; import '../type_helper.dart'; +import '../utils.dart'; class GenericFactoryHelper extends TypeHelper { const GenericFactoryHelper(); @@ -75,11 +76,11 @@ Object? $_toJsonHelperName( '''; String toJsonForType(TypeParameterType type) => - toJsonForName(type.getDisplayString(withNullability: false)); + toJsonForName(type.toStringNonNullable()); String toJsonForName(String genericType) => 'toJson$genericType'; String fromJsonForType(TypeParameterType type) => - fromJsonForName(type.getDisplayString(withNullability: false)); + fromJsonForName(type.toStringNonNullable()); String fromJsonForName(String genericType) => 'fromJson$genericType'; diff --git a/json_serializable/lib/src/type_helpers/map_helper.dart b/json_serializable/lib/src/type_helpers/map_helper.dart index 806c7074e..51cb3a0a5 100644 --- a/json_serializable/lib/src/type_helpers/map_helper.dart +++ b/json_serializable/lib/src/type_helpers/map_helper.dart @@ -94,7 +94,7 @@ class MapHelper extends TypeHelper { // `toDouble` on input values valueArg.isSimpleJsonTypeNotDouble)) { // No mapping of the values or null check required! - final valueString = valueArg.getDisplayString(withNullability: true); + final valueString = valueArg.getDisplayString(); return 'Map.from($expression as Map)'; } } diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index 0bf6dba64..782eeb53d 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -177,6 +177,12 @@ Iterable? iterateEnumFields(DartType targetType) { extension DartTypeExtension on DartType { DartType promoteNonNullable() => element?.library?.typeSystem.promoteToNonNull(this) ?? this; + + String toStringNonNullable() { + final val = getDisplayString(); + if (val.endsWith('?')) return val.substring(0, val.length - 1); + return val; + } } String ifNullOrElse(String test, String ifNull, String ifNotNull) => @@ -216,7 +222,7 @@ String typeToCode( } if (type is TypeParameterType) { - return type.getDisplayString(withNullability: false); + return type.toStringNonNullable(); } throw UnimplementedError('(${type.runtimeType}) $type'); } diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index e6d66865d..2ad1e7a1d 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -1,11 +1,11 @@ name: json_serializable -version: 6.8.0 +version: 6.8.1-wip 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.0.0 + sdk: ^3.4.0 topics: - json - build-runner @@ -13,32 +13,32 @@ topics: - codegen dependencies: - analyzer: '>=5.12.0 <7.0.0' - async: ^2.8.0 - build: ^2.0.0 - build_config: '>=0.4.4 <2.0.0' - collection: ^1.14.0 + analyzer: ^6.5.0 + async: ^2.10.0 + build: ^2.4.1 + build_config: ^1.1.0 + collection: ^1.17.0 # Use a tight version constraint to ensure that a constraint on # `json_annotation` properly constrains all features it provides. json_annotation: '>=4.9.0 <4.10.0' - meta: ^1.3.0 - path: ^1.8.0 - pub_semver: ^2.0.0 + meta: ^1.14.0 + path: ^1.9.0 + pub_semver: ^2.1.4 pubspec_parse: ^1.0.0 - source_gen: ^1.3.2 - source_helper: ^1.3.0 + source_gen: ^1.4.0 + source_helper: ^1.3.4 dev_dependencies: _json_serial_shared_test: path: ../shared_test - build_runner: ^2.0.0 + build_runner: ^2.4.6 build_verify: ^3.0.0 - dart_flutter_team_lints: ^2.0.0 - dart_style: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 + dart_style: ^2.3.2 logging: ^1.0.0 - source_gen_test: ^1.0.0 - test: ^1.16.0 + source_gen_test: ^1.0.6 + test: ^1.24.4 test_descriptor: ^2.0.0 test_process: ^2.0.0 yaml: ^3.0.0 diff --git a/json_serializable/test/annotation_version_test.dart b/json_serializable/test/annotation_version_test.dart index a12d3398b..1aed36547 100644 --- a/json_serializable/test/annotation_version_test.dart +++ b/json_serializable/test/annotation_version_test.dart @@ -5,7 +5,7 @@ @TestOn('vm') @Tags(['presubmit-only']) @Timeout.factor(2) -library test; +library; import 'dart:io'; diff --git a/json_serializable/test/config_test.dart b/json_serializable/test/config_test.dart index 2bcaa242a..318697f54 100644 --- a/json_serializable/test/config_test.dart +++ b/json_serializable/test/config_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -library test; +library; import 'dart:io'; diff --git a/json_serializable/test/custom_configuration_test.dart b/json_serializable/test/custom_configuration_test.dart index 8fc7ce097..a717b7bb8 100644 --- a/json_serializable/test/custom_configuration_test.dart +++ b/json_serializable/test/custom_configuration_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -library test; +library; import 'dart:async'; diff --git a/json_serializable/test/ensure_build_test.dart b/json_serializable/test/ensure_build_test.dart index a8c75e638..9dac5390d 100644 --- a/json_serializable/test/ensure_build_test.dart +++ b/json_serializable/test/ensure_build_test.dart @@ -4,7 +4,7 @@ @TestOn('vm') @Tags(['presubmit-only']) -library test; +library; import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/json_serializable/test/enum_helper_test.dart b/json_serializable/test/enum_helper_test.dart index cfc18ad9b..280ff9e28 100644 --- a/json_serializable/test/enum_helper_test.dart +++ b/json_serializable/test/enum_helper_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -library test; +library; import 'package:json_serializable/src/type_helpers/enum_helper.dart'; import 'package:test/test.dart'; diff --git a/json_serializable/test/json_serializable_test.dart b/json_serializable/test/json_serializable_test.dart index 5644b51cb..b6ff36789 100644 --- a/json_serializable/test/json_serializable_test.dart +++ b/json_serializable/test/json_serializable_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -library test; +library; import 'package:json_serializable/json_serializable.dart'; import 'package:path/path.dart' as p; diff --git a/json_serializable/test/literal/json_literal_test.dart b/json_serializable/test/literal/json_literal_test.dart index edcb7855f..a3f66f836 100644 --- a/json_serializable/test/literal/json_literal_test.dart +++ b/json_serializable/test/literal/json_literal_test.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -library test; +library; import 'dart:convert'; import 'dart:io'; diff --git a/json_serializable/test/supported_types/extra_map_test.dart b/json_serializable/test/supported_types/extra_map_test.dart index 449a8d9ba..e4fc69c1d 100644 --- a/json_serializable/test/supported_types/extra_map_test.dart +++ b/json_serializable/test/supported_types/extra_map_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.bigint_test.dart b/json_serializable/test/supported_types/type_test.bigint_test.dart index 26e7a001b..1fa7140da 100644 --- a/json_serializable/test/supported_types/type_test.bigint_test.dart +++ b/json_serializable/test/supported_types/type_test.bigint_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.bool_test.dart b/json_serializable/test/supported_types/type_test.bool_test.dart index 19247a81c..33d1e9bcc 100644 --- a/json_serializable/test/supported_types/type_test.bool_test.dart +++ b/json_serializable/test/supported_types/type_test.bool_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.dart b/json_serializable/test/supported_types/type_test.dart index 1d5d72ded..2e7c63a3a 100644 --- a/json_serializable/test/supported_types/type_test.dart +++ b/json_serializable/test/supported_types/type_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.datetime_test.dart b/json_serializable/test/supported_types/type_test.datetime_test.dart index dee0b5cf5..690cde74c 100644 --- a/json_serializable/test/supported_types/type_test.datetime_test.dart +++ b/json_serializable/test/supported_types/type_test.datetime_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.double_test.dart b/json_serializable/test/supported_types/type_test.double_test.dart index 4704157ff..31c72aa00 100644 --- a/json_serializable/test/supported_types/type_test.double_test.dart +++ b/json_serializable/test/supported_types/type_test.double_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.duration_test.dart b/json_serializable/test/supported_types/type_test.duration_test.dart index f7651278c..a928fd914 100644 --- a/json_serializable/test/supported_types/type_test.duration_test.dart +++ b/json_serializable/test/supported_types/type_test.duration_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.enumtype_test.dart b/json_serializable/test/supported_types/type_test.enumtype_test.dart index cd2b527e4..3c2e8bc9a 100644 --- a/json_serializable/test/supported_types/type_test.enumtype_test.dart +++ b/json_serializable/test/supported_types/type_test.enumtype_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.int_test.dart b/json_serializable/test/supported_types/type_test.int_test.dart index 9f36677dd..b9f36ec4f 100644 --- a/json_serializable/test/supported_types/type_test.int_test.dart +++ b/json_serializable/test/supported_types/type_test.int_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.iterable_test.dart b/json_serializable/test/supported_types/type_test.iterable_test.dart index a9c34fee7..b31313d97 100644 --- a/json_serializable/test/supported_types/type_test.iterable_test.dart +++ b/json_serializable/test/supported_types/type_test.iterable_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.list_test.dart b/json_serializable/test/supported_types/type_test.list_test.dart index 007a386a3..6791be995 100644 --- a/json_serializable/test/supported_types/type_test.list_test.dart +++ b/json_serializable/test/supported_types/type_test.list_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.map_test.dart b/json_serializable/test/supported_types/type_test.map_test.dart index 54a37fa9c..2ccce34e6 100644 --- a/json_serializable/test/supported_types/type_test.map_test.dart +++ b/json_serializable/test/supported_types/type_test.map_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.num_test.dart b/json_serializable/test/supported_types/type_test.num_test.dart index 8bc9e72b5..7cd62d61b 100644 --- a/json_serializable/test/supported_types/type_test.num_test.dart +++ b/json_serializable/test/supported_types/type_test.num_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.object_test.dart b/json_serializable/test/supported_types/type_test.object_test.dart index c7f28dd71..f6333fa7a 100644 --- a/json_serializable/test/supported_types/type_test.object_test.dart +++ b/json_serializable/test/supported_types/type_test.object_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.set_test.dart b/json_serializable/test/supported_types/type_test.set_test.dart index 4dfc0b82f..12f2521ee 100644 --- a/json_serializable/test/supported_types/type_test.set_test.dart +++ b/json_serializable/test/supported_types/type_test.set_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.string_test.dart b/json_serializable/test/supported_types/type_test.string_test.dart index f7ed73127..a868de260 100644 --- a/json_serializable/test/supported_types/type_test.string_test.dart +++ b/json_serializable/test/supported_types/type_test.string_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/json_serializable/test/supported_types/type_test.uri_test.dart b/json_serializable/test/supported_types/type_test.uri_test.dart index 4b8493ca4..c49a890fa 100644 --- a/json_serializable/test/supported_types/type_test.uri_test.dart +++ b/json_serializable/test/supported_types/type_test.uri_test.dart @@ -4,7 +4,7 @@ // ignore_for_file: prefer_const_declarations @TestOn('vm') -library test; +library; import 'dart:convert'; diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index 6cb35af92..975abe375 100644 --- a/shared_test/pubspec.yaml +++ b/shared_test/pubspec.yaml @@ -1,11 +1,11 @@ name: _json_serial_shared_test publish_to: none environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: stack_trace: ^1.10.0 test: ^1.6.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 diff --git a/tool/ci.sh b/tool/ci.sh index 436465312..deac64920 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -1,9 +1,10 @@ #!/bin/bash -# Created with package:mono_repo v6.5.7 +# Created with package:mono_repo v6.6.1 # Support built in commands on windows out of the box. + # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". +# then "flutter pub" is called instead of "dart pub". # This assumes that the Flutter SDK has been installed in a previous step. function pub() { if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then @@ -12,18 +13,13 @@ function pub() { command dart pub "$@" fi } -# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". -# This assumes that the Flutter SDK has been installed in a previous step. + function format() { - if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then - command flutter format "$@" - else - command dart format "$@" - fi + command dart format "$@" } + # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". +# then "flutter analyze" is called instead of "dart analyze". # This assumes that the Flutter SDK has been installed in a previous step. function analyze() { if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then From a7f3893e87bc38339503dc5da09acf6df3784777 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 15:15:19 -0700 Subject: [PATCH 34/42] --- (#1429) updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- .github/workflows/markdown_linter.yml | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 121296a69..49573086a 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -34,7 +34,7 @@ jobs: sdk: stable - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - name: mono_repo self validate run: dart pub global activate mono_repo 6.6.1 - name: mono_repo self validate @@ -59,7 +59,7 @@ jobs: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -125,7 +125,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -211,7 +211,7 @@ jobs: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -272,7 +272,7 @@ jobs: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -306,7 +306,7 @@ jobs: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -340,7 +340,7 @@ jobs: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -374,7 +374,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -435,7 +435,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -469,7 +469,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -503,7 +503,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -537,7 +537,7 @@ jobs: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -597,7 +597,7 @@ jobs: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 6cf4457c5..d0a51ba90 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -11,10 +11,10 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 markdown_lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: DavidAnson/markdownlint-cli2-action@510b996878fc0d1a46c8a04ec86b06dbfba09de7 From c672f2d8769275782b8a70efc479b588034813bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 15:15:46 -0700 Subject: [PATCH 35/42] Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (#1424) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.2 to 1.6.4. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/fedb1266e91cf51be2fdb382869461a434b920a3...f0ead981b4d9a35b37f30d36160575d60931ec30) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 49573086a..44490feec 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -29,7 +29,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: stable - id: checkout @@ -54,7 +54,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: "3.4.0" - id: checkout @@ -120,7 +120,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: dev - id: checkout @@ -206,7 +206,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: "3.4.0" - id: checkout @@ -267,7 +267,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: "3.4.0" - id: checkout @@ -301,7 +301,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: "3.4.0" - id: checkout @@ -335,7 +335,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: "3.4.0" - id: checkout @@ -369,7 +369,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: dev - id: checkout @@ -430,7 +430,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: dev - id: checkout @@ -464,7 +464,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: dev - id: checkout @@ -498,7 +498,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: dev - id: checkout @@ -532,7 +532,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: "3.4.0" - id: checkout @@ -592,7 +592,7 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: dev - id: checkout From a58b190949647dc4aa87be3d6cbc217470408f46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 15:26:35 -0700 Subject: [PATCH 36/42] Bump DavidAnson/markdownlint-cli2-action from 15.0.0 to 16.0.0 (#1423) Bumps [DavidAnson/markdownlint-cli2-action](https://github.com/davidanson/markdownlint-cli2-action) from 15.0.0 to 16.0.0. - [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases) - [Commits](https://github.com/davidanson/markdownlint-cli2-action/compare/510b996878fc0d1a46c8a04ec86b06dbfba09de7...b4c9feab76d8025d1e83c653fa3990936df0e6c8) --- updated-dependencies: - dependency-name: DavidAnson/markdownlint-cli2-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/markdown_linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index d0a51ba90..7951d1884 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -17,4 +17,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - uses: DavidAnson/markdownlint-cli2-action@510b996878fc0d1a46c8a04ec86b06dbfba09de7 + - uses: DavidAnson/markdownlint-cli2-action@b4c9feab76d8025d1e83c653fa3990936df0e6c8 From 23dd460fe0f53d6c3915cc7f3a500f3c82f35790 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 20 May 2024 15:28:47 -0700 Subject: [PATCH 37/42] blast_repo fixes (#1430) dependabot --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f4169fa24..5524d4ed5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,3 +10,7 @@ updates: interval: monthly labels: - autosubmit + groups: + dependencies: + patterns: + - "*" From ca77b65f505a21d43c41c2b230f9459f3ec6cda7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 30 Jun 2024 21:14:57 -0700 Subject: [PATCH 38/42] Bump the dependencies group with 2 updates (#1434) Bumps the dependencies group with 2 updates: [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) and [actions/checkout](https://github.com/actions/checkout). Updates `dart-lang/setup-dart` from 1.6.4 to 1.6.5 - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/f0ead981b4d9a35b37f30d36160575d60931ec30...0a8a0fc875eb934c15d08629302413c671d3f672) Updates `actions/checkout` from 4.1.6 to 4.1.7 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/a5ac7e51b41094c92402da3b24376905380afc29...692973e3d937129bcbf40652eb9f2f61becf3332) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dependencies ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/dart.yml | 52 +++++++++++++-------------- .github/workflows/markdown_linter.yml | 4 +-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 44490feec..d03227527 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -29,12 +29,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: stable - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - name: mono_repo self validate run: dart pub global activate mono_repo 6.6.1 - name: mono_repo self validate @@ -54,12 +54,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -120,12 +120,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -206,12 +206,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -267,12 +267,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -301,12 +301,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -335,12 +335,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -369,12 +369,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -430,12 +430,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -464,12 +464,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -498,12 +498,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: json_serializable_pub_upgrade name: json_serializable; dart pub upgrade run: dart pub upgrade @@ -532,12 +532,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: "3.4.0" - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade @@ -592,12 +592,12 @@ jobs: os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: dev - id: checkout name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - id: _test_yaml_pub_upgrade name: _test_yaml; dart pub upgrade run: dart pub upgrade diff --git a/.github/workflows/markdown_linter.yml b/.github/workflows/markdown_linter.yml index 7951d1884..9e838ec6d 100644 --- a/.github/workflows/markdown_linter.yml +++ b/.github/workflows/markdown_linter.yml @@ -11,10 +11,10 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 markdown_lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - uses: DavidAnson/markdownlint-cli2-action@b4c9feab76d8025d1e83c653fa3990936df0e6c8 From ac55cd4ce052b6ab15e643150641f142d7bb18ee Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 5 Aug 2024 14:25:50 -0700 Subject: [PATCH 39/42] Move to use (experimental) workspaces (#1433) --- .github/workflows/dart.yml | 64 +++++++++++----------- _test_yaml/pubspec.yaml | 12 +--- checked_yaml/pubspec.yaml | 10 +--- example/pubspec.yaml | 12 +--- json_annotation/pubspec.yaml | 4 +- json_serializable/README.md | 18 +++--- json_serializable/pubspec.yaml | 4 +- json_serializable/tool/readme_builder.dart | 14 ++--- pubspec.yaml | 15 +++++ shared_test/pubspec.yaml | 4 +- tool/ci.sh | 2 +- 11 files changed, 82 insertions(+), 77 deletions(-) create mode 100644 pubspec.yaml diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index d03227527..cffabe4cf 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,4 +1,4 @@ -# Created with package:mono_repo v6.6.1 +# Created with package:mono_repo v6.6.2 name: Dart CI on: push: @@ -36,27 +36,27 @@ jobs: name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - name: mono_repo self validate - run: dart pub global activate mono_repo 6.6.1 + run: dart pub global activate mono_repo 6.6.2 - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyzer_and_format; Dart 3.4.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`" + name: "analyzer_and_format; Dart 3.5.0-259.0.dev; 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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.4.0" + sdk: "3.5.0-259.0.dev" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -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.4.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" + name: "unit_test; Dart 3.5.0-259.0.dev; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.4.0" + sdk: "3.5.0-259.0.dev" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -253,23 +253,23 @@ jobs: - job_002 - job_003 job_005: - name: "unit_test; Dart 3.4.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" + name: "unit_test; Dart 3.5.0-259.0.dev; 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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_3" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable;commands:test_3" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.4.0" + sdk: "3.5.0-259.0.dev" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -287,23 +287,23 @@ jobs: - job_002 - job_003 job_006: - name: "unit_test; Dart 3.4.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "unit_test; Dart 3.5.0-259.0.dev; 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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.4.0" + sdk: "3.5.0-259.0.dev" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -321,23 +321,23 @@ jobs: - job_002 - job_003 job_007: - name: "unit_test; Dart 3.4.0; PKG: json_serializable; `dart test -p chrome`" + name: "unit_test; Dart 3.5.0-259.0.dev; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable;commands:test_2" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.4.0" + sdk: "3.5.0-259.0.dev" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -518,23 +518,23 @@ jobs: - job_002 - job_003 job_012: - name: "ensure_build; Dart 3.4.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "ensure_build; Dart 3.5.0-259.0.dev; 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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example - os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example + os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.4.0" + sdk: "3.5.0-259.0.dev" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index 8bf18a935..967c84111 100644 --- a/_test_yaml/pubspec.yaml +++ b/_test_yaml/pubspec.yaml @@ -2,7 +2,9 @@ name: _test_yaml publish_to: none environment: - sdk: ^3.4.0 + sdk: ^3.5.0-259.0.dev + +resolution: workspace dev_dependencies: _json_serial_shared_test: @@ -16,11 +18,3 @@ dev_dependencies: path: ^1.8.2 test: ^1.21.6 yaml: ^3.0.0 - -dependency_overrides: - checked_yaml: - path: ../checked_yaml - json_annotation: - path: ../json_annotation - json_serializable: - path: ../json_serializable diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index 2be93cc62..bc8bcc7e0 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -13,7 +13,9 @@ topics: - codegen environment: - sdk: ^3.4.0 + sdk: ^3.5.0-259.0.dev + +resolution: workspace dependencies: json_annotation: ^4.3.0 @@ -28,9 +30,3 @@ dev_dependencies: path: ^1.8.0 test: ^1.17.10 test_process: ^2.0.0 - -#dependency_overrides: -# json_annotation: -# path: ../json_annotation -# json_serializable: -# path: ../json_serializable diff --git a/example/pubspec.yaml b/example/pubspec.yaml index be24d38a3..6e7e6362d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,7 +2,9 @@ name: example publish_to: none environment: - sdk: ^3.4.0 + sdk: ^3.5.0-259.0.dev + +resolution: workspace dependencies: json_annotation: ^4.9.0 @@ -27,11 +29,3 @@ dev_dependencies: # Not required to use `json_serializable`. path: ^1.8.0 test: ^1.21.6 - -# This section is used to verify changes to these packages. Do not include in -# your code! -dependency_overrides: - json_annotation: - path: ../json_annotation - json_serializable: - path: ../json_serializable diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index 917f8e111..b1bff234c 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -11,7 +11,9 @@ topics: - codegen environment: - sdk: ^3.4.0 + sdk: ^3.5.0-259.0.dev + +resolution: workspace dependencies: meta: ^1.4.0 diff --git a/json_serializable/README.md b/json_serializable/README.md index d30a13659..5d30efd16 100644 --- a/json_serializable/README.md +++ b/json_serializable/README.md @@ -298,15 +298,15 @@ targets: [`Enum`]: https://api.dart.dev/stable/dart-core/Enum-class.html [`int`]: https://api.dart.dev/stable/dart-core/int-class.html [`Iterable`]: https://api.dart.dev/stable/dart-core/Iterable-class.html -[`JsonConverter`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonConverter-class.html -[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonEnum/valueField.html -[`JsonEnum`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonEnum-class.html -[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey/fromJson.html -[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey/toJson.html -[`JsonKey`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonKey-class.html -[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonLiteral-class.html -[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonSerializable-class.html -[`JsonValue`]: https://pub.dev/documentation/json_annotation/4.9.0/json_annotation/JsonValue-class.html +[`JsonConverter`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html +[`JsonEnum.valueField`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum/valueField.html +[`JsonEnum`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonEnum-class.html +[`JsonKey.fromJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html +[`JsonKey.toJson`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html +[`JsonKey`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey-class.html +[`JsonLiteral`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonLiteral-class.html +[`JsonSerializable`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonSerializable-class.html +[`JsonValue`]: https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonValue-class.html [`List`]: https://api.dart.dev/stable/dart-core/List-class.html [`Map`]: https://api.dart.dev/stable/dart-core/Map-class.html [`num`]: https://api.dart.dev/stable/dart-core/num-class.html diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 2ad1e7a1d..5773ec736 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -5,13 +5,15 @@ description: >- Dart classes. repository: https://github.com/google/json_serializable.dart/tree/master/json_serializable environment: - sdk: ^3.4.0 + sdk: ^3.5.0-259.0.dev topics: - json - build-runner - json-serializable - codegen +resolution: workspace + dependencies: analyzer: ^6.5.0 async: ^2.10.0 diff --git a/json_serializable/tool/readme_builder.dart b/json_serializable/tool/readme_builder.dart index 5de07dfe3..cd832eab5 100644 --- a/json_serializable/tool/readme_builder.dart +++ b/json_serializable/tool/readme_builder.dart @@ -154,13 +154,13 @@ extension on BuildStep { AssetId assetIdForInputPackage(String path) => AssetId(inputId.package, path); Future jsonAnnotationVersion() async { - final lockFileAssetId = assetIdForInputPackage('pubspec.lock'); - final lockFileContent = await readAsString(lockFileAssetId); - final lockFileYaml = - loadYaml(lockFileContent, sourceUrl: lockFileAssetId.uri) as YamlMap; - final pkgMap = lockFileYaml['packages'] as YamlMap; - final jsonAnnotationMap = pkgMap['json_annotation'] as YamlMap; - final jsonAnnotationVersionString = jsonAnnotationMap['version'] as String; + final jsonAnnotationPubspecAssetId = + AssetId('json_annotation', 'pubspec.yaml'); + final jsonAnnotationPubspecContent = + await readAsString(jsonAnnotationPubspecAssetId); + final pubspecYaml = loadYaml(jsonAnnotationPubspecContent, + sourceUrl: jsonAnnotationPubspecAssetId.uri) as YamlMap; + final jsonAnnotationVersionString = pubspecYaml['version'] as String; final jsonAnnotationVersion = Version.parse(jsonAnnotationVersionString.trim()); diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 000000000..2f7c7b72f --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,15 @@ +name: json_serial_workspace # Can be anything +environment: + sdk: ^3.5.0-259.0.dev # Must be ^3.5.0 or later for workspace to be allowed + +publish_to: none + +dev_dependencies: + dart_flutter_team_lints: ^3.1.0 +workspace: + - _test_yaml + - checked_yaml + - example + - json_annotation + - json_serializable + - shared_test diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index 975abe375..f88ea12db 100644 --- a/shared_test/pubspec.yaml +++ b/shared_test/pubspec.yaml @@ -1,7 +1,9 @@ name: _json_serial_shared_test publish_to: none environment: - sdk: ^3.4.0 + sdk: ^3.5.0-259.0.dev + +resolution: workspace dependencies: stack_trace: ^1.10.0 diff --git a/tool/ci.sh b/tool/ci.sh index deac64920..c6a601c34 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Created with package:mono_repo v6.6.1 +# Created with package:mono_repo v6.6.2 # Support built in commands on windows out of the box. From 27df6994e14028dde3901b157c00bdd04d6f3d4c Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 6 Aug 2024 09:58:43 -0700 Subject: [PATCH 40/42] Move SDK constraint to map to 3.5 stable (#1440) --- .github/workflows/dart.yml | 60 +++++++++++++++++----------------- _test_yaml/pubspec.yaml | 2 +- checked_yaml/CHANGELOG.md | 2 +- checked_yaml/pubspec.yaml | 2 +- example/pubspec.yaml | 2 +- json_annotation/CHANGELOG.md | 2 +- json_annotation/pubspec.yaml | 2 +- json_serializable/CHANGELOG.md | 2 +- json_serializable/pubspec.yaml | 2 +- pubspec.yaml | 2 +- shared_test/pubspec.yaml | 2 +- 11 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index cffabe4cf..85a9d8d5b 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-259.0.dev; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`" + name: "analyzer_and_format; Dart 3.5.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.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-259.0.dev;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev + 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 os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.5.0-259.0.dev" + sdk: "3.5.0" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -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-259.0.dev; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" + name: "unit_test; Dart 3.5.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev + 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 os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.5.0-259.0.dev" + sdk: "3.5.0" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -253,23 +253,23 @@ jobs: - job_002 - job_003 job_005: - name: "unit_test; Dart 3.5.0-259.0.dev; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" + name: "unit_test; Dart 3.5.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable;commands:test_3" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_3" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev + 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 os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.5.0-259.0.dev" + sdk: "3.5.0" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -287,23 +287,23 @@ jobs: - job_002 - job_003 job_006: - name: "unit_test; Dart 3.5.0-259.0.dev; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "unit_test; Dart 3.5.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@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev + 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 os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.5.0-259.0.dev" + sdk: "3.5.0" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -321,23 +321,23 @@ jobs: - job_002 - job_003 job_007: - name: "unit_test; Dart 3.5.0-259.0.dev; PKG: json_serializable; `dart test -p chrome`" + name: "unit_test; Dart 3.5.0; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable;commands:test_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:json_serializable;commands:test_2" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev + 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 os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.5.0-259.0.dev" + sdk: "3.5.0" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 @@ -518,23 +518,23 @@ jobs: - job_002 - job_003 job_012: - name: "ensure_build; Dart 3.5.0-259.0.dev; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + 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`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:_test_yaml-checked_yaml-example;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev;packages:_test_yaml-checked_yaml-example - os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0-259.0.dev + 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 os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: - sdk: "3.5.0-259.0.dev" + sdk: "3.5.0" - id: checkout name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index 967c84111..e189c8ee8 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-259.0.dev + sdk: ^3.5.0 resolution: workspace diff --git a/checked_yaml/CHANGELOG.md b/checked_yaml/CHANGELOG.md index 543b0ce5e..292ecc01a 100644 --- a/checked_yaml/CHANGELOG.md +++ b/checked_yaml/CHANGELOG.md @@ -1,6 +1,6 @@ ## 2.0.4-wip -- Require Dart 3.4 +- Require Dart 3.5 ## 2.0.3 diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index bc8bcc7e0..d86daebf6 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -13,7 +13,7 @@ topics: - codegen environment: - sdk: ^3.5.0-259.0.dev + sdk: ^3.5.0 resolution: workspace diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6e7e6362d..c75056710 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,7 +2,7 @@ name: example publish_to: none environment: - sdk: ^3.5.0-259.0.dev + sdk: ^3.5.0 resolution: workspace diff --git a/json_annotation/CHANGELOG.md b/json_annotation/CHANGELOG.md index 911e1d671..0c341a220 100644 --- a/json_annotation/CHANGELOG.md +++ b/json_annotation/CHANGELOG.md @@ -1,6 +1,6 @@ ## 4.9.1-wip -- Require Dart 3.4 +- Require Dart 3.5 ## 4.9.0 diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index b1bff234c..86ed2b1ad 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -11,7 +11,7 @@ topics: - codegen environment: - sdk: ^3.5.0-259.0.dev + sdk: ^3.5.0 resolution: workspace diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 35c941633..222e369d9 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,6 +1,6 @@ ## 6.8.1-wip -- Require Dart 3.4 +- Require Dart 3.5 ## 6.8.0 diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 5773ec736..29c37c4cc 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -5,7 +5,7 @@ description: >- Dart classes. repository: https://github.com/google/json_serializable.dart/tree/master/json_serializable environment: - sdk: ^3.5.0-259.0.dev + sdk: ^3.5.0 topics: - json - build-runner diff --git a/pubspec.yaml b/pubspec.yaml index 2f7c7b72f..028d1d235 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: json_serial_workspace # Can be anything environment: - sdk: ^3.5.0-259.0.dev # Must be ^3.5.0 or later for workspace to be allowed + sdk: ^3.5.0 publish_to: none diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index f88ea12db..ee379c326 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-259.0.dev + sdk: ^3.5.0 resolution: workspace From 9ccbbb2b51c95f4b74d0886be240f48a74cf7d48 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 8 Aug 2024 16:22:22 -0700 Subject: [PATCH 41/42] Update and fix lints (#1442) --- _test_yaml/pubspec.yaml | 1 - checked_yaml/pubspec.yaml | 1 - example/pubspec.yaml | 3 --- json_annotation/lib/src/json_converter.dart | 2 +- json_annotation/lib/src/json_serializable.dart | 2 +- json_annotation/pubspec.yaml | 6 ------ json_serializable/pubspec.yaml | 1 - pubspec.yaml | 2 +- shared_test/pubspec.yaml | 3 --- 9 files changed, 3 insertions(+), 18 deletions(-) diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index e189c8ee8..f54503684 100644 --- a/_test_yaml/pubspec.yaml +++ b/_test_yaml/pubspec.yaml @@ -12,7 +12,6 @@ dev_dependencies: build_runner: ^2.2.1 build_verify: ^3.0.0 checked_yaml: ^2.0.4-wip - dart_flutter_team_lints: ^3.0.0 json_annotation: ^4.9.0 json_serializable: ^6.8.0 path: ^1.8.2 diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index d86daebf6..bb765cb1d 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -25,7 +25,6 @@ dependencies: dev_dependencies: build_runner: ^2.0.6 build_verify: ^3.0.0 - dart_flutter_team_lints: ^3.0.0 json_serializable: ^6.0.0 path: ^1.8.0 test: ^1.17.10 diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c75056710..0875abdd3 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -20,9 +20,6 @@ dev_dependencies: # Used by tests. Not required to use `json_serializable`. build_verify: ^3.0.0 - # Not required to use `json_serializable`. - dart_flutter_team_lints: ^3.0.0 - # REQUIRED! json_serializable: ^6.8.0 diff --git a/json_annotation/lib/src/json_converter.dart b/json_annotation/lib/src/json_converter.dart index bd0738e80..d50db4f4b 100644 --- a/json_annotation/lib/src/json_converter.dart +++ b/json_annotation/lib/src/json_converter.dart @@ -7,7 +7,7 @@ /// [T] is the data type you'd like to convert to and from. /// /// [S] is the type of the value stored in JSON. It must be a valid JSON type -/// such as [String], [int], or [Map]. +/// such as [String], [int], or [Map]``. /// /// /// [JsonConverter]s can be placed either on the class: diff --git a/json_annotation/lib/src/json_serializable.dart b/json_annotation/lib/src/json_serializable.dart index fb4d8eade..64d1990e0 100644 --- a/json_annotation/lib/src/json_serializable.dart +++ b/json_annotation/lib/src/json_serializable.dart @@ -39,7 +39,7 @@ enum FieldRename { ) @Target({TargetKind.classType}) class JsonSerializable { - /// If `true`, [Map] types are *not* assumed to be [Map] + /// If `true`, [Map] types are *not* assumed to be [Map]`` /// – which is the default type of [Map] instances return by JSON decode in /// `dart:convert`. /// diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index 86ed2b1ad..cf334679b 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -17,9 +17,3 @@ resolution: workspace dependencies: meta: ^1.4.0 - -dev_dependencies: - dart_flutter_team_lints: ^3.0.0 -# When changing JsonSerializable class. -# build_runner: ^2.0.0 -# json_serializable: any diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 29c37c4cc..1adf0afb2 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -36,7 +36,6 @@ dev_dependencies: path: ../shared_test build_runner: ^2.4.6 build_verify: ^3.0.0 - dart_flutter_team_lints: ^3.0.0 dart_style: ^2.3.2 logging: ^1.0.0 source_gen_test: ^1.0.6 diff --git a/pubspec.yaml b/pubspec.yaml index 028d1d235..ac2343cc3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ environment: publish_to: none dev_dependencies: - dart_flutter_team_lints: ^3.1.0 + dart_flutter_team_lints: ^3.2.0 workspace: - _test_yaml - checked_yaml diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index ee379c326..09b960f69 100644 --- a/shared_test/pubspec.yaml +++ b/shared_test/pubspec.yaml @@ -8,6 +8,3 @@ resolution: workspace dependencies: stack_trace: ^1.10.0 test: ^1.6.0 - -dev_dependencies: - dart_flutter_team_lints: ^3.0.0 From 55d68f4f57d9fbfca96dff9f53a7cdc0c9208792 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 8 Aug 2024 21:30:40 -0700 Subject: [PATCH 42/42] Use map syntax to clean up `null` handling in `toJson` functions (#1443) --- _test_yaml/test/src/build_config.g.dart | 39 ++-- example/lib/example.g.dart | 53 ++--- example/test/example_test.dart | 8 +- json_serializable/CHANGELOG.md | 3 +- json_serializable/lib/src/constants.dart | 3 +- json_serializable/lib/src/encoder_helper.dart | 97 ++------- json_serializable/pubspec.yaml | 2 +- .../test/custom_configuration_test.dart | 1 - .../integration/converter_examples.g.dart | 69 +++--- .../create_per_field_to_json_example.g.dart | 31 +-- .../test/integration/json_enum_example.g.dart | 20 +- .../test/integration/json_test_example.g.dart | 56 ++--- .../json_test_example.g_any_map.g.dart | 56 ++--- .../kitchen_sink.g_exclude_null.g.dart | 203 +++++++++--------- .../src/_json_serializable_test_input.dart | 19 +- .../test/src/inheritance_test_input.dart | 45 ++-- .../test/src/to_from_json_test_input.dart | 17 +- 17 files changed, 261 insertions(+), 461 deletions(-) diff --git a/_test_yaml/test/src/build_config.g.dart b/_test_yaml/test/src/build_config.g.dart index 61e578ec4..e4d832e78 100644 --- a/_test_yaml/test/src/build_config.g.dart +++ b/_test_yaml/test/src/build_config.g.dart @@ -103,28 +103,23 @@ Builder _$BuilderFromJson(Map json) => $checkedCreate( }, ); -Map _$BuilderToJson(Builder instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('target', instance.target); - writeNotNull('import', instance.import); - writeNotNull('is_optional', instance.isOptional); - writeNotNull('configLocation', instance.configLocation?.toString()); - writeNotNull('auto_apply', _$AutoApplyEnumMap[instance.autoApply]); - writeNotNull('build_to', _$BuildToEnumMap[instance.buildTo]); - writeNotNull('defaultEnumTest', _$AutoApplyEnumMap[instance.defaultEnumTest]); - val['builder_factories'] = instance.builderFactories; - writeNotNull('applies_builders', instance.appliesBuilders); - writeNotNull('required_inputs', instance.requiredInputs); - writeNotNull('build_extensions', instance.buildExtensions); - return val; -} +Map _$BuilderToJson(Builder instance) => { + if (instance.target case final value?) 'target': value, + if (instance.import case final value?) 'import': value, + if (instance.isOptional case final value?) 'is_optional': value, + if (instance.configLocation?.toString() case final value?) + 'configLocation': value, + if (_$AutoApplyEnumMap[instance.autoApply] case final value?) + 'auto_apply': value, + if (_$BuildToEnumMap[instance.buildTo] case final value?) + 'build_to': value, + if (_$AutoApplyEnumMap[instance.defaultEnumTest] case final value?) + 'defaultEnumTest': value, + 'builder_factories': instance.builderFactories, + if (instance.appliesBuilders case final value?) 'applies_builders': value, + if (instance.requiredInputs case final value?) 'required_inputs': value, + if (instance.buildExtensions case final value?) 'build_extensions': value, + }; const _$BuildToEnumMap = { BuildTo.cache: 'cache', diff --git a/example/lib/example.g.dart b/example/lib/example.g.dart index b4cf7de11..f497bc0e7 100644 --- a/example/lib/example.g.dart +++ b/example/lib/example.g.dart @@ -19,24 +19,14 @@ Person _$PersonFromJson(Map json) => Person( .toList(), ); -Map _$PersonToJson(Person instance) { - final val = { - 'firstName': instance.firstName, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('middleName', instance.middleName); - val['lastName'] = instance.lastName; - val['date-of-birth'] = instance.dateOfBirth.toIso8601String(); - val['last-order'] = instance.lastOrder?.toIso8601String(); - val['orders'] = instance.orders; - return val; -} +Map _$PersonToJson(Person instance) => { + 'firstName': instance.firstName, + if (instance.middleName case final value?) 'middleName': value, + 'lastName': instance.lastName, + 'date-of-birth': instance.dateOfBirth.toIso8601String(), + 'last-order': instance.lastOrder?.toIso8601String(), + 'orders': instance.orders, + }; Order _$OrderFromJson(Map json) => Order( Order._dateTimeFromEpochUs((json['date'] as num).toInt()), @@ -50,23 +40,16 @@ Order _$OrderFromJson(Map json) => Order( ..prepTime = Order._durationFromMilliseconds((json['prep-time'] as num?)?.toInt()); -Map _$OrderToJson(Order instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('count', instance.count); - writeNotNull('itemNumber', instance.itemNumber); - writeNotNull('isRushed', instance.isRushed); - writeNotNull('item', instance.item); - writeNotNull('prep-time', Order._durationToMilliseconds(instance.prepTime)); - writeNotNull('date', Order._dateTimeToEpochUs(instance.date)); - return val; -} +Map _$OrderToJson(Order instance) => { + if (instance.count case final value?) 'count': value, + if (instance.itemNumber case final value?) 'itemNumber': value, + if (instance.isRushed case final value?) 'isRushed': value, + if (instance.item case final value?) 'item': value, + if (Order._durationToMilliseconds(instance.prepTime) case final value?) + 'prep-time': value, + if (Order._dateTimeToEpochUs(instance.date) case final value?) + 'date': value, + }; Item _$ItemFromJson(Map json) => Item() ..count = (json['count'] as num?)?.toInt() diff --git a/example/test/example_test.dart b/example/test/example_test.dart index e2abf3424..99dc2ed53 100644 --- a/example/test/example_test.dart +++ b/example/test/example_test.dart @@ -10,8 +10,12 @@ import 'package:test/test.dart'; void main() { test('JsonSerializable', () { - final person = Person('Inigo', 'Montoya', DateTime(1560, 5, 5)) - ..orders = [Order(DateTime.now())..item = (Item()..count = 42)]; + final person = Person( + 'Inigo', + 'Montoya', + DateTime(1560, 5, 5), + middleName: 'Bob', + )..orders = [Order(DateTime.now())..item = (Item()..count = 42)]; final personJson = loudEncode(person); diff --git a/json_serializable/CHANGELOG.md b/json_serializable/CHANGELOG.md index 222e369d9..7c14862e2 100644 --- a/json_serializable/CHANGELOG.md +++ b/json_serializable/CHANGELOG.md @@ -1,5 +1,6 @@ -## 6.8.1-wip +## 6.9.0-wip +- Use conditional map syntax to clean up `null` handling in `toJson` functions. - Require Dart 3.5 ## 6.8.0 diff --git a/json_serializable/lib/src/constants.dart b/json_serializable/lib/src/constants.dart index 9949b77cc..a151ff034 100644 --- a/json_serializable/lib/src/constants.dart +++ b/json_serializable/lib/src/constants.dart @@ -5,8 +5,7 @@ /// Name used for closure argument when generating calls to `map`. const closureArg = 'e'; -const generatedLocalVarName = 'val'; -const toJsonMapHelperName = 'writeNotNull'; +const generatedLocalVarName = 'value'; const converterOrKeyInstructions = r''' * Use `JsonConverter` diff --git a/json_serializable/lib/src/encoder_helper.dart b/json_serializable/lib/src/encoder_helper.dart index 05d4c714d..4e876b757 100644 --- a/json_serializable/lib/src/encoder_helper.dart +++ b/json_serializable/lib/src/encoder_helper.dart @@ -97,18 +97,22 @@ mixin EncodeHelper implements HelperCore { if (config.genericArgumentFactories) _writeGenericArgumentFactories(buffer); - buffer.write(') '); + buffer + ..write(') ') + ..writeln('=> {') + ..writeAll(accessibleFields.map((field) { + final access = _fieldAccess(field); - final canWriteAllJsonValuesWithoutNullCheck = - accessibleFields.every(_canWriteJsonWithoutNullCheck); + final keyExpression = safeNameAccess(field); + final valueExpression = _serializeField(field, access); - if (canWriteAllJsonValuesWithoutNullCheck) { - // write simple `toJson` method that includes all keys... - _writeToJsonSimple(buffer, accessibleFields); - } else { - // At least one field should be excluded if null - _writeToJsonWithNullChecks(buffer, accessibleFields); - } + final keyValuePair = _canWriteJsonWithoutNullCheck(field) + ? '$keyExpression: $valueExpression' + : 'if ($valueExpression case final $generatedLocalVarName?) ' + '$keyExpression: $generatedLocalVarName'; + return ' $keyValuePair,\n'; + })) + ..writeln('};'); yield buffer.toString(); } @@ -125,81 +129,8 @@ mixin EncodeHelper implements HelperCore { } } - void _writeToJsonSimple(StringBuffer buffer, Iterable fields) { - buffer - ..writeln('=> {') - ..writeAll(fields.map((field) { - final access = _fieldAccess(field); - final value = - '${safeNameAccess(field)}: ${_serializeField(field, access)}'; - return ' $value,\n'; - })) - ..writeln('};'); - } - static const _toJsonParamName = 'instance'; - void _writeToJsonWithNullChecks( - StringBuffer buffer, - Iterable fields, - ) { - buffer - ..writeln('{') - ..writeln(' final $generatedLocalVarName = {'); - - // Note that the map literal is left open above. As long as target fields - // don't need to be intercepted by the `only if null` logic, write them - // to the map literal directly. In theory, should allow more efficient - // serialization. - var directWrite = true; - - for (final field in fields) { - var safeFieldAccess = _fieldAccess(field); - final safeJsonKeyString = safeNameAccess(field); - - // If `fieldName` collides with one of the local helpers, prefix - // access with `this.`. - if (safeFieldAccess == generatedLocalVarName || - safeFieldAccess == toJsonMapHelperName) { - safeFieldAccess = 'this.$safeFieldAccess'; - } - - final expression = _serializeField(field, safeFieldAccess); - if (_canWriteJsonWithoutNullCheck(field)) { - if (directWrite) { - buffer.writeln(' $safeJsonKeyString: $expression,'); - } else { - buffer.writeln( - ' $generatedLocalVarName[$safeJsonKeyString] = $expression;'); - } - } else { - if (directWrite) { - // close the still-open map literal - buffer - ..writeln(' };') - ..writeln() - - // write the helper to be used by all following null-excluding - // fields - ..writeln(''' - void $toJsonMapHelperName(String key, dynamic value) { - if (value != null) { - $generatedLocalVarName[key] = value; - } - } -'''); - directWrite = false; - } - buffer.writeln( - ' $toJsonMapHelperName($safeJsonKeyString, $expression);'); - } - } - - buffer - ..writeln(' return $generatedLocalVarName;') - ..writeln(' }'); - } - String _serializeField(FieldElement field, String accessExpression) { try { return getHelperContext(field) diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index 1adf0afb2..854f2c7fd 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -1,5 +1,5 @@ name: json_serializable -version: 6.8.1-wip +version: 6.9.0-wip description: >- Automatically generate code for converting to and from JSON by annotating Dart classes. diff --git a/json_serializable/test/custom_configuration_test.dart b/json_serializable/test/custom_configuration_test.dart index a717b7bb8..4ac5d02ca 100644 --- a/json_serializable/test/custom_configuration_test.dart +++ b/json_serializable/test/custom_configuration_test.dart @@ -214,7 +214,6 @@ Map _$TrivialNestedNonNullableToJson( test('some', () async { final output = await runForElementNamed('IncludeIfNullAll'); expect(output, isNot(contains(generatedLocalVarName))); - expect(output, isNot(contains(toJsonMapHelperName))); }); }); } diff --git a/json_serializable/test/integration/converter_examples.g.dart b/json_serializable/test/integration/converter_examples.g.dart index 2829672a9..f19c8fc2e 100644 --- a/json_serializable/test/integration/converter_examples.g.dart +++ b/json_serializable/test/integration/converter_examples.g.dart @@ -26,33 +26,26 @@ Issue1202RegressionClass _$Issue1202RegressionClassFromJson( ); Map _$Issue1202RegressionClassToJson( - Issue1202RegressionClass instance) { - final val = { - 'valueWithFunctions': - Issue1202RegressionClass._toJson(instance.valueWithFunctions), - 'notNullableValueWithConverter': - const _Issue1202RegressionNotNullConverter() - .toJson(instance.notNullableValueWithConverter), - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('value', _$Issue1202RegressionEnumEnumMap[instance.value]); - writeNotNull('normalNullableValue', instance.normalNullableValue); - writeNotNull( - 'notNullableValueWithNullableConverter', - const _Issue1202RegressionConverter() - .toJson(instance.notNullableValueWithNullableConverter)); - writeNotNull( - 'valueWithNullableFunctions', - Issue1202RegressionClass._toJsonNullable( - instance.valueWithNullableFunctions)); - return val; -} + Issue1202RegressionClass instance) => + { + 'valueWithFunctions': + Issue1202RegressionClass._toJson(instance.valueWithFunctions), + 'notNullableValueWithConverter': + const _Issue1202RegressionNotNullConverter() + .toJson(instance.notNullableValueWithConverter), + if (_$Issue1202RegressionEnumEnumMap[instance.value] case final value?) + 'value': value, + if (instance.normalNullableValue case final value?) + 'normalNullableValue': value, + if (const _Issue1202RegressionConverter() + .toJson(instance.notNullableValueWithNullableConverter) + case final value?) + 'notNullableValueWithNullableConverter': value, + if (Issue1202RegressionClass._toJsonNullable( + instance.valueWithNullableFunctions) + case final value?) + 'valueWithNullableFunctions': value, + }; const _$Issue1202RegressionEnumEnumMap = { Issue1202RegressionEnum.normalValue: 42, @@ -65,21 +58,13 @@ Regression1229 _$Regression1229FromJson(Map json) => json['date'], const DateTimeConverter().fromJson), ); -Map _$Regression1229ToJson(Regression1229 instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull( - 'date', - _$JsonConverterToJson( - instance.date, const DateTimeConverter().toJson)); - return val; -} +Map _$Regression1229ToJson(Regression1229 instance) => + { + if (_$JsonConverterToJson( + instance.date, const DateTimeConverter().toJson) + case final value?) + 'date': value, + }; Value? _$JsonConverterFromJson( Object? json, diff --git a/json_serializable/test/integration/create_per_field_to_json_example.g.dart b/json_serializable/test/integration/create_per_field_to_json_example.g.dart index 1c4b0fe88..28f3443a5 100644 --- a/json_serializable/test/integration/create_per_field_to_json_example.g.dart +++ b/json_serializable/test/integration/create_per_field_to_json_example.g.dart @@ -45,26 +45,17 @@ abstract class _$ModelPerFieldToJson { static Object? nestedExcludeIfNull(Nested? instance) => instance?.toJson(); } -Map _$ModelToJson(Model instance) { - final val = { - 'firstName': instance.firstName, - 'lastName': instance.lastName, - 'enumValue': _$EnumValueEnumMap[instance.enumValue], - 'nested': instance.nested?.toJson(), - 'nestedGeneric': instance.nestedGeneric?.toJson( - (value) => value, - ), - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('nestedExcludeIfNull', instance.nestedExcludeIfNull?.toJson()); - return val; -} +Map _$ModelToJson(Model instance) => { + 'firstName': instance.firstName, + 'lastName': instance.lastName, + 'enumValue': _$EnumValueEnumMap[instance.enumValue], + 'nested': instance.nested?.toJson(), + 'nestedGeneric': instance.nestedGeneric?.toJson( + (value) => value, + ), + if (instance.nestedExcludeIfNull?.toJson() case final value?) + 'nestedExcludeIfNull': value, + }; const _$EnumValueEnumMap = { EnumValue.first: '1', diff --git a/json_serializable/test/integration/json_enum_example.g.dart b/json_serializable/test/integration/json_enum_example.g.dart index 6408e9e1d..95ae41b17 100644 --- a/json_serializable/test/integration/json_enum_example.g.dart +++ b/json_serializable/test/integration/json_enum_example.g.dart @@ -53,19 +53,13 @@ Issue1226Regression _$Issue1226RegressionFromJson(Map json) => _$Issue1145RegressionEnumEnumMap, json['durationType']), ); -Map _$Issue1226RegressionToJson(Issue1226Regression instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull( - 'durationType', _$Issue1145RegressionEnumEnumMap[instance.durationType]); - return val; -} +Map _$Issue1226RegressionToJson( + Issue1226Regression instance) => + { + if (_$Issue1145RegressionEnumEnumMap[instance.durationType] + case final value?) + 'durationType': value, + }; const _$StandAloneEnumEnumMap = { StandAloneEnum.alpha: 'a', diff --git a/json_serializable/test/integration/json_test_example.g.dart b/json_serializable/test/integration/json_test_example.g.dart index ec12eb554..bf56859ed 100644 --- a/json_serializable/test/integration/json_test_example.g.dart +++ b/json_serializable/test/integration/json_test_example.g.dart @@ -85,26 +85,17 @@ Order _$OrderFromJson(Map json) { StatusCode.success; } -Map _$OrderToJson(Order instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('count', instance.count); - val['isRushed'] = instance.isRushed; - val['duration'] = instance.duration?.inMicroseconds; - val['category'] = _$CategoryEnumMap[instance.category]; - val['items'] = instance.items; - val['platform'] = instance.platform; - val['altPlatforms'] = instance.altPlatforms; - val['homepage'] = instance.homepage?.toString(); - val['status_code'] = _$StatusCodeEnumMap[instance.statusCode]; - return val; -} +Map _$OrderToJson(Order instance) => { + if (instance.count case final value?) 'count': value, + 'isRushed': instance.isRushed, + 'duration': instance.duration?.inMicroseconds, + 'category': _$CategoryEnumMap[instance.category], + 'items': instance.items, + 'platform': instance.platform, + 'altPlatforms': instance.altPlatforms, + 'homepage': instance.homepage?.toString(), + 'status_code': _$StatusCodeEnumMap[instance.statusCode], + }; const _$StatusCodeEnumMap = { StatusCode.success: 200, @@ -125,24 +116,13 @@ Item _$ItemFromJson(Map json) => Item( .toList() ..geoPoint = _fromJsonGeoPoint(json['geoPoint'] as Map?); -Map _$ItemToJson(Item instance) { - final val = { - 'price': instance.price, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('item-number', instance.itemNumber); - val['saleDates'] = - instance.saleDates?.map((e) => e.toIso8601String()).toList(); - val['rates'] = instance.rates; - val['geoPoint'] = _toJsonGeoPoint(instance.geoPoint); - return val; -} +Map _$ItemToJson(Item instance) => { + 'price': instance.price, + if (instance.itemNumber case final value?) 'item-number': value, + 'saleDates': instance.saleDates?.map((e) => e.toIso8601String()).toList(), + 'rates': instance.rates, + 'geoPoint': _toJsonGeoPoint(instance.geoPoint), + }; Numbers _$NumbersFromJson(Map json) => Numbers() ..ints = diff --git a/json_serializable/test/integration/json_test_example.g_any_map.g.dart b/json_serializable/test/integration/json_test_example.g_any_map.g.dart index 5fe79152e..ef2ad4f95 100644 --- a/json_serializable/test/integration/json_test_example.g_any_map.g.dart +++ b/json_serializable/test/integration/json_test_example.g_any_map.g.dart @@ -85,26 +85,17 @@ Order _$OrderFromJson(Map json) { StatusCode.success; } -Map _$OrderToJson(Order instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('count', instance.count); - val['isRushed'] = instance.isRushed; - val['duration'] = instance.duration?.inMicroseconds; - val['category'] = _$CategoryEnumMap[instance.category]; - val['items'] = instance.items; - val['platform'] = instance.platform; - val['altPlatforms'] = instance.altPlatforms; - val['homepage'] = instance.homepage?.toString(); - val['status_code'] = _$StatusCodeEnumMap[instance.statusCode]; - return val; -} +Map _$OrderToJson(Order instance) => { + if (instance.count case final value?) 'count': value, + 'isRushed': instance.isRushed, + 'duration': instance.duration?.inMicroseconds, + 'category': _$CategoryEnumMap[instance.category], + 'items': instance.items, + 'platform': instance.platform, + 'altPlatforms': instance.altPlatforms, + 'homepage': instance.homepage?.toString(), + 'status_code': _$StatusCodeEnumMap[instance.statusCode], + }; const _$StatusCodeEnumMap = { StatusCode.success: 200, @@ -125,24 +116,13 @@ Item _$ItemFromJson(Map json) => Item( .toList() ..geoPoint = _fromJsonGeoPoint(json['geoPoint'] as Map?); -Map _$ItemToJson(Item instance) { - final val = { - 'price': instance.price, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('item-number', instance.itemNumber); - val['saleDates'] = - instance.saleDates?.map((e) => e.toIso8601String()).toList(); - val['rates'] = instance.rates; - val['geoPoint'] = _toJsonGeoPoint(instance.geoPoint); - return val; -} +Map _$ItemToJson(Item instance) => { + 'price': instance.price, + if (instance.itemNumber case final value?) 'item-number': value, + 'saleDates': instance.saleDates?.map((e) => e.toIso8601String()).toList(), + 'rates': instance.rates, + 'geoPoint': _toJsonGeoPoint(instance.geoPoint), + }; Numbers _$NumbersFromJson(Map json) => Numbers() ..ints = diff --git a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart index a3a8f8550..39b0eb184 100644 --- a/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart +++ b/json_serializable/test/kitchen_sink/kitchen_sink.g_exclude_null.g.dart @@ -98,69 +98,63 @@ KitchenSink _$KitchenSinkFromJson(Map json) => KitchenSink( ), ); -Map _$KitchenSinkToJson(KitchenSink instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('no-42', instance.ctorValidatedNo42); - writeNotNull('dateTime', instance.dateTime?.toIso8601String()); - writeNotNull('bigInt', instance.bigInt?.toString()); - writeNotNull('iterable', instance.iterable?.toList()); - val['dynamicIterable'] = instance.dynamicIterable.toList(); - val['objectIterable'] = instance.objectIterable.toList(); - val['intIterable'] = instance.intIterable.toList(); - val['set'] = instance.set.toList(); - val['dynamicSet'] = instance.dynamicSet.toList(); - val['objectSet'] = instance.objectSet.toList(); - val['intSet'] = instance.intSet.toList(); - val['dateTimeSet'] = - instance.dateTimeSet.map((e) => e.toIso8601String()).toList(); - val['datetime-iterable'] = - instance.dateTimeIterable.map((e) => e.toIso8601String()).toList(); - val['list'] = instance.list; - val['dynamicList'] = instance.dynamicList; - val['objectList'] = instance.objectList; - val['intList'] = instance.intList; - val['dateTimeList'] = - instance.dateTimeList.map((e) => e.toIso8601String()).toList(); - val['nullableSimpleObjectList'] = instance.nullableSimpleObjectList; - val['map'] = instance.map; - val['stringStringMap'] = instance.stringStringMap; - val['dynamicIntMap'] = instance.dynamicIntMap; - val['objectDateTimeMap'] = instance.objectDateTimeMap - .map((k, e) => MapEntry(k, e.toIso8601String())); - val['nullableSimpleObjectMap'] = instance.nullableSimpleObjectMap; - val['crazyComplex'] = instance.crazyComplex - .map((e) => e?.map((k, e) => MapEntry( - k, - e?.map((k, e) => MapEntry( +Map _$KitchenSinkToJson(KitchenSink instance) => + { + if (instance.ctorValidatedNo42 case final value?) 'no-42': value, + if (instance.dateTime?.toIso8601String() case final value?) + 'dateTime': value, + if (instance.bigInt?.toString() case final value?) 'bigInt': value, + if (instance.iterable?.toList() case final value?) 'iterable': value, + 'dynamicIterable': instance.dynamicIterable.toList(), + 'objectIterable': instance.objectIterable.toList(), + 'intIterable': instance.intIterable.toList(), + 'set': instance.set.toList(), + 'dynamicSet': instance.dynamicSet.toList(), + 'objectSet': instance.objectSet.toList(), + 'intSet': instance.intSet.toList(), + 'dateTimeSet': + instance.dateTimeSet.map((e) => e.toIso8601String()).toList(), + 'datetime-iterable': + instance.dateTimeIterable.map((e) => e.toIso8601String()).toList(), + 'list': instance.list, + 'dynamicList': instance.dynamicList, + 'objectList': instance.objectList, + 'intList': instance.intList, + 'dateTimeList': + instance.dateTimeList.map((e) => e.toIso8601String()).toList(), + 'nullableSimpleObjectList': instance.nullableSimpleObjectList, + 'map': instance.map, + 'stringStringMap': instance.stringStringMap, + 'dynamicIntMap': instance.dynamicIntMap, + 'objectDateTimeMap': instance.objectDateTimeMap + .map((k, e) => MapEntry(k, e.toIso8601String())), + 'nullableSimpleObjectMap': instance.nullableSimpleObjectMap, + 'crazyComplex': instance.crazyComplex + .map((e) => e?.map((k, e) => MapEntry( k, - e - ?.map((e) => e?.map((e) => e.toIso8601String()).toList()) - .toList()))))) - .toList(); - val['val'] = instance.val; - writeNotNull('writeNotNull', instance.writeNotNull); - writeNotNull(r'$string', instance.string); - val['simpleObject'] = instance.simpleObject; - val['strictKeysObject'] = instance.strictKeysObject; - writeNotNull('validatedPropertyNo42', instance.validatedPropertyNo42); - writeNotNull( - 'recordField', - instance.recordField == null - ? null - : { - r'$1': instance.recordField!.$1, - r'$2': instance.recordField!.$2, - 'truth': instance.recordField!.truth, - }); - return val; -} + e?.map((k, e) => MapEntry( + k, + e + ?.map((e) => e?.map((e) => e.toIso8601String()).toList()) + .toList()))))) + .toList(), + 'val': instance.val, + if (instance.writeNotNull case final value?) 'writeNotNull': value, + if (instance.string case final value?) r'$string': value, + 'simpleObject': instance.simpleObject, + 'strictKeysObject': instance.strictKeysObject, + if (instance.validatedPropertyNo42 case final value?) + 'validatedPropertyNo42': value, + if (instance.recordField == null + ? null + : { + r'$1': instance.recordField!.$1, + r'$2': instance.recordField!.$2, + 'truth': instance.recordField!.truth, + } + case final value?) + 'recordField': value, + }; $Rec? _$recordConvertNullable<$Rec>( Object? value, @@ -208,50 +202,47 @@ JsonConverterTestClass _$JsonConverterTestClassFromJson( ); Map _$JsonConverterTestClassToJson( - JsonConverterTestClass instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('duration', - const DurationMillisecondConverter().toJson(instance.duration)); - val['durationList'] = instance.durationList - .map(const DurationMillisecondConverter().toJson) - .toList(); - val['bigInt'] = const BigIntStringConverter().toJson(instance.bigInt); - val['bigIntMap'] = instance.bigIntMap - .map((k, e) => MapEntry(k, const BigIntStringConverter().toJson(e))); - writeNotNull( - 'nullableBigInt', - _$JsonConverterToJson( - instance.nullableBigInt, const BigIntStringConverter().toJson)); - val['nullableBigIntMap'] = instance.nullableBigIntMap.map((k, e) => MapEntry( - k, - _$JsonConverterToJson( - e, const BigIntStringConverter().toJson))); - writeNotNull('numberSilly', - TrivialNumberConverter.instance.toJson(instance.numberSilly)); - val['numberSillySet'] = instance.numberSillySet - .map(TrivialNumberConverter.instance.toJson) - .toList(); - writeNotNull( - 'dateTime', const EpochDateTimeConverter().toJson(instance.dateTime)); - writeNotNull( - 'trivialString', trivialStringConverter.toJson(instance.trivialString)); - writeNotNull( - 'nullableNumberSilly', - _$JsonConverterToJson(instance.nullableNumberSilly, - TrivialNumberConverter.instance.toJson)); - val['nullableNumberSillySet'] = instance.nullableNumberSillySet - .map((e) => _$JsonConverterToJson( - e, TrivialNumberConverter.instance.toJson)) - .toList(); - return val; -} + JsonConverterTestClass instance) => + { + if (const DurationMillisecondConverter().toJson(instance.duration) + case final value?) + 'duration': value, + 'durationList': instance.durationList + .map(const DurationMillisecondConverter().toJson) + .toList(), + 'bigInt': const BigIntStringConverter().toJson(instance.bigInt), + 'bigIntMap': instance.bigIntMap + .map((k, e) => MapEntry(k, const BigIntStringConverter().toJson(e))), + if (_$JsonConverterToJson( + instance.nullableBigInt, const BigIntStringConverter().toJson) + case final value?) + 'nullableBigInt': value, + 'nullableBigIntMap': instance.nullableBigIntMap.map((k, e) => MapEntry( + k, + _$JsonConverterToJson( + e, const BigIntStringConverter().toJson))), + if (TrivialNumberConverter.instance.toJson(instance.numberSilly) + case final value?) + 'numberSilly': value, + 'numberSillySet': instance.numberSillySet + .map(TrivialNumberConverter.instance.toJson) + .toList(), + if (const EpochDateTimeConverter().toJson(instance.dateTime) + case final value?) + 'dateTime': value, + if (trivialStringConverter.toJson(instance.trivialString) + case final value?) + 'trivialString': value, + if (_$JsonConverterToJson( + instance.nullableNumberSilly, + TrivialNumberConverter.instance.toJson) + case final value?) + 'nullableNumberSilly': value, + 'nullableNumberSillySet': instance.nullableNumberSillySet + .map((e) => _$JsonConverterToJson( + e, TrivialNumberConverter.instance.toJson)) + .toList(), + }; Value? _$JsonConverterFromJson( Object? json, diff --git a/json_serializable/test/src/_json_serializable_test_input.dart b/json_serializable/test/src/_json_serializable_test_input.dart index 1458630ff..f8537f346 100644 --- a/json_serializable/test/src/_json_serializable_test_input.dart +++ b/json_serializable/test/src/_json_serializable_test_input.dart @@ -215,20 +215,11 @@ class NoDeserializeBadKey { @ShouldGenerate( r''' Map _$IncludeIfNullOverrideToJson( - IncludeIfNullOverride instance) { - final val = { - 'number': instance.number, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('str', instance.str); - return val; -} + IncludeIfNullOverride instance) => + { + 'number': instance.number, + if (instance.str case final value?) 'str': value, + }; ''', ) @JsonSerializable(createFactory: false, includeIfNull: false) diff --git a/json_serializable/test/src/inheritance_test_input.dart b/json_serializable/test/src/inheritance_test_input.dart index 875743fc7..921e442e3 100644 --- a/json_serializable/test/src/inheritance_test_input.dart +++ b/json_serializable/test/src/inheritance_test_input.dart @@ -8,22 +8,13 @@ SubType _$SubTypeFromJson(Map json) => SubType( ..superReadWriteField = (json['superReadWriteField'] as num?)?.toInt() ..subTypeReadWrite = (json['subTypeReadWrite'] as num).toInt(); -Map _$SubTypeToJson(SubType instance) { - final val = { - 'super-final-field': instance.superFinalField, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('superReadWriteField', instance.superReadWriteField); - val['subTypeViaCtor'] = instance.subTypeViaCtor; - val['subTypeReadWrite'] = instance.subTypeReadWrite; - return val; -} +Map _$SubTypeToJson(SubType instance) => { + 'super-final-field': instance.superFinalField, + if (instance.superReadWriteField case final value?) + 'superReadWriteField': value, + 'subTypeViaCtor': instance.subTypeViaCtor, + 'subTypeReadWrite': instance.subTypeReadWrite, + }; ''') @JsonSerializable() class SubType extends SuperType { @@ -54,21 +45,13 @@ class SuperType { @ShouldGenerate(r''' Map _$SubTypeWithAnnotatedFieldOverrideExtendsToJson( - SubTypeWithAnnotatedFieldOverrideExtends instance) { - final val = { - 'super-final-field': instance.superFinalField, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('superReadWriteField', instance.superReadWriteField); - val['priceHalf'] = instance.priceHalf; - return val; -} + SubTypeWithAnnotatedFieldOverrideExtends instance) => + { + 'super-final-field': instance.superFinalField, + if (instance.superReadWriteField case final value?) + 'superReadWriteField': value, + 'priceHalf': instance.priceHalf, + }; ''') @JsonSerializable(createFactory: false) class SubTypeWithAnnotatedFieldOverrideExtends extends SuperType { 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 7e5f57965..abeb24be2 100644 --- a/json_serializable/test/src/to_from_json_test_input.dart +++ b/json_serializable/test/src/to_from_json_test_input.dart @@ -175,18 +175,11 @@ String? _toStringNullOnEmpty(String input) => input.isEmpty ? null : input; @ShouldGenerate( r''' Map _$ToJsonNullableFalseIncludeIfNullFalseToJson( - ToJsonNullableFalseIncludeIfNullFalse instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('field', _toStringNullOnEmpty(instance.field)); - return val; -} + ToJsonNullableFalseIncludeIfNullFalse instance) => + { + if (_toStringNullOnEmpty(instance.field) case final value?) + 'field': value, + }; ''', ) @JsonSerializable(createFactory: false)