Skip to content

Commit

Permalink
Update dependencies and SDK constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed May 20, 2024
1 parent 02e17e5 commit 30619a1
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 98 deletions.
64 changes: 32 additions & 32 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions _test_yaml/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions checked_yaml/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ topics:
- codegen

environment:
sdk: ^3.0.0
sdk: ^3.4.0

dependencies:
json_annotation: ^4.3.0
source_span: ^1.8.0
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:
Expand Down
10 changes: 5 additions & 5 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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!
Expand Down
4 changes: 2 additions & 2 deletions json_annotation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion json_serializable/lib/src/decode_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions json_serializable/lib/src/field_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ List<FieldElement> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion json_serializable/lib/src/helper_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '''
Expand Down
4 changes: 2 additions & 2 deletions json_serializable/lib/src/json_key_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`.',
);
}
}
Expand Down
8 changes: 0 additions & 8 deletions json_serializable/lib/src/json_serializable_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/element/type.dart';
import 'package:json_serializable/src/utils.dart';
import 'package:source_helper/source_helper.dart';

import '../lambda_result.dart';
Expand Down Expand Up @@ -75,11 +76,11 @@ Object? $_toJsonHelperName<T>(
''';

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';
2 changes: 1 addition & 1 deletion json_serializable/lib/src/type_helpers/map_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MapHelper extends TypeHelper<TypeHelperContextWithConfig> {
// `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<String, $valueString>.from($expression as Map)';
}
}
Expand Down
8 changes: 7 additions & 1 deletion json_serializable/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ Iterable<FieldElement>? 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) =>
Expand Down Expand Up @@ -216,7 +222,7 @@ String typeToCode(
}

if (type is TypeParameterType) {
return type.getDisplayString(withNullability: false);
return type.toStringNonNullable();
}
throw UnimplementedError('(${type.runtimeType}) $type');
}
Expand Down
Loading

0 comments on commit 30619a1

Please sign in to comment.