From 5ad3ab195db2a4a2ed5decf6251a73e907d73fa4 Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Sun, 26 Mar 2023 09:38:56 +0800 Subject: [PATCH] Migrated to Dart 3 --- packages/json_serializer/CHANGELOG.md | 4 ++++ packages/json_serializer/README.md | 2 +- packages/json_serializer/pubspec.yaml | 6 +++--- .../test/deserialization_test.dart | 4 ++-- packages/json_serializer/test/shared.dart | 20 +++++++++---------- .../json_serializer/test/to_json_test.dart | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/json_serializer/CHANGELOG.md b/packages/json_serializer/CHANGELOG.md index 634a713..2861c1a 100644 --- a/packages/json_serializer/CHANGELOG.md +++ b/packages/json_serializer/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.0-beta.1 + +* Require Dart >= 3.0 + ## 6.0.1 * Updated README diff --git a/packages/json_serializer/README.md b/packages/json_serializer/README.md index 5b26248..def3b27 100644 --- a/packages/json_serializer/README.md +++ b/packages/json_serializer/README.md @@ -12,7 +12,7 @@ The ***new and improved*** definitive solution for JSON in Dart. It supports syn ## Installation dependencies: - belatuk_json_serializer: ^6.0.0 + belatuk_json_serializer: ^7.0.0 ## Usage diff --git a/packages/json_serializer/pubspec.yaml b/packages/json_serializer/pubspec.yaml index 2257aac..57f4b99 100644 --- a/packages/json_serializer/pubspec.yaml +++ b/packages/json_serializer/pubspec.yaml @@ -1,12 +1,12 @@ name: belatuk_json_serializer -version: 6.0.1 +version: 7.0.0-beta.1 description: Easy JSON to Object serialization and deserialization in Dart. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/json_serializer environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.0-290.3.beta <4.0.0' dependencies: logging: ^1.0.1 dev_dependencies: stack_trace: ^1.10.0 - test: ^1.17.4 + test: ^1.24.0 lints: ^2.0.0 \ No newline at end of file diff --git a/packages/json_serializer/test/deserialization_test.dart b/packages/json_serializer/test/deserialization_test.dart index d9d3535..9edef21 100644 --- a/packages/json_serializer/test/deserialization_test.dart +++ b/packages/json_serializer/test/deserialization_test.dart @@ -105,11 +105,11 @@ testDeserializationWithSchemaValidation() async { god.deserialize(babelRcJson, outputType: BabelRc) as BabelRc; print(deserialized.presets.runtimeType); - expect(deserialized.presets is List, equals(true)); + //expect(deserialized.presets is List, equals(true)); expect(deserialized.presets.length, equals(2)); expect(deserialized.presets[0], equals('es2015')); expect(deserialized.presets[1], equals('stage-0')); - expect(deserialized.plugins is List, equals(true)); + //expect(deserialized.plugins is List, equals(true)); expect(deserialized.plugins.length, equals(1)); expect(deserialized.plugins[0], equals('add-module-exports')); } diff --git a/packages/json_serializer/test/shared.dart b/packages/json_serializer/test/shared.dart index a35ce4f..78261c6 100644 --- a/packages/json_serializer/test/shared.dart +++ b/packages/json_serializer/test/shared.dart @@ -11,14 +11,14 @@ void printRecord(LogRecord rec) { class SampleNestedClass { String? bar; - SampleNestedClass([String? this.bar]); + SampleNestedClass([this.bar]); } class SampleClass { String? hello; List nested = []; - SampleClass([String? this.hello]); + SampleClass([this.hello]); } @WithSchemaUrl( @@ -27,25 +27,23 @@ class BabelRc { List presets; List plugins; - BabelRc( - {List this.presets: const [], - List this.plugins: const []}); + BabelRc({this.presets = const [], this.plugins = const []}); } -@WithSchema(const { +@WithSchema({ r"$schema": "http://json-schema.org/draft-04/schema#", "title": "Validated Sample Class", "description": "Sample schema for validation via JSON God", "type": "object", - "hello": const {"description": "A friendly greeting.", "type": "string"}, - "nested": const { + "hello": {"description": "A friendly greeting.", "type": "string"}, + "nested": { "description": "A list of NestedSampleClass items within this instance.", "type": "array", - "items": const { + "items": { "type": "object", - "bar": const {"description": "Filler text", "type": "string"} + "bar": {"description": "Filler text", "type": "string"} } }, - "required": const ["hello", "nested"] + "required": ["hello", "nested"] }) class ValidatedSampleClass {} diff --git a/packages/json_serializer/test/to_json_test.dart b/packages/json_serializer/test/to_json_test.dart index 8da16ef..0e7911b 100644 --- a/packages/json_serializer/test/to_json_test.dart +++ b/packages/json_serializer/test/to_json_test.dart @@ -8,7 +8,7 @@ main() { test('fromJson', () { var foo = god.deserialize('{"bar":"baz"}', outputType: Foo) as Foo; - expect(foo is Foo, true); + //expect(foo is Foo, true); expect(foo.text, equals('baz')); });