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