Skip to content

Commit

Permalink
## 1.0.4
Browse files Browse the repository at this point in the history
- Relaxed dependency versions
- Fixed bug for abstract class json serialize & deserialize

## 1.0.3
- Relaxed analyzer requiremenst to 6.0.0

## 1.0.2
- Added jsonserialization annotation dependency included in morphy

## 1.0.1
- Added jsonserialization dependency included in morphy
  • Loading branch information
atreeon committed Nov 30, 2023
1 parent 0f04a2b commit 5089751
Show file tree
Hide file tree
Showing 31 changed files with 476 additions and 169 deletions.
4 changes: 3 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ dependency_overrides:
path: ../morphy_annotation

dependencies:
json_serializable: ^6.7.1
meta: any

morphy:
path: ../morphy

# morphy: ^1.0.1

dev_dependencies:
build_runner: ^2.4.6
test: ^1.24.8
Expand Down
12 changes: 6 additions & 6 deletions example/test/ex21_custom_constructors_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ part 'ex21_custom_constructors_test.morphy.dart';
//In this example class A has an underscore thereby hiding its default constructor.
//Instead we create a function called A_DifferentConstructor.

@morphy
abstract class $A_ {
@Morphy(privateConstructor: true)
abstract class $A {
String get a;
}

void main() {
test("0 default value", () {
var a = A_._(a: "my default value");
var a = A._(a: "my default value");
expect(a.a, "my default value");
});

test("1 default value", () {
var a = A_DifferentConstructor();
var a = A_Factory();
expect(a.a, "my default value");
});
}

A_ A_DifferentConstructor() {
return A_._(a: "my default value");
A A_Factory() {
return A._(a: "my default value");
}
16 changes: 8 additions & 8 deletions example/test/ex21_custom_constructors_test.morphy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ part of 'ex21_custom_constructors_test.dart';
// **************************************************************************

///
class A_ extends $A_ {
class A extends $A {
final String a;

///
A_._({
A._({
required this.a,
});
String toString() => "(A_-a:${a.toString()})";
String toString() => "(A-a:${a.toString()})";
int get hashCode => hashObjects([a.hashCode]);
bool operator ==(Object other) =>
identical(this, other) ||
other is A_ && runtimeType == other.runtimeType && a == other.a;
A_ copyWith_A_({
other is A && runtimeType == other.runtimeType && a == other.a;
A copyWith_A({
Opt<String>? a,
}) {
return A_._(
return A._(
a: a == null ? this.a as String : a.value as String,
);
}
}

extension $A__changeTo_E on $A_ {}
extension $A_changeTo_E on $A {}

enum A_$ { a }
enum A$ { a }
1 change: 0 additions & 1 deletion example/test/ex46_json_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// ignore_for_file: unnecessary_cast

import 'package:json_annotation/json_annotation.dart';
import 'package:test/test.dart';
import 'package:morphy/morphy.dart';

Expand Down
15 changes: 0 additions & 15 deletions example/test/ex46_json_test.g.dart

This file was deleted.

8 changes: 5 additions & 3 deletions example/test/ex46_json_test.morphy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ part of 'ex46_json_test.dart';

///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class Pet extends $Pet {
final String kind;

Expand Down Expand Up @@ -45,8 +47,8 @@ class Pet extends $Pet {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down
24 changes: 15 additions & 9 deletions example/test/ex47_json_inheritance_test.morphy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ part of 'ex47_json_inheritance_test.dart';

///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class A extends $A {
final String id;

Expand Down Expand Up @@ -54,8 +56,8 @@ class A extends $A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down Expand Up @@ -98,7 +100,9 @@ enum A$ { id }
///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class B extends $B implements A {
final String id;

Expand Down Expand Up @@ -147,8 +151,8 @@ class B extends $B implements A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand All @@ -173,7 +177,9 @@ enum B$ { id }
///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class C extends $C implements A {
final String id;
final List<int> items;
Expand Down Expand Up @@ -230,8 +236,8 @@ class C extends $C implements A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down
16 changes: 10 additions & 6 deletions example/test/ex48_json_with_subtype_test.morphy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ part of 'ex48_json_with_subtype_test.dart';
/// Every subtype needs to also implement toJson & fromJson
///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class A extends $A {
final String id;
final X x;
Expand Down Expand Up @@ -60,8 +62,8 @@ class A extends $A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand All @@ -82,7 +84,9 @@ enum A$ { id, x, xs }

///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class X extends $X {
final List<int> items;

Expand Down Expand Up @@ -121,8 +125,8 @@ class X extends $X {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down
25 changes: 16 additions & 9 deletions example/test/ex50_json_inheritance_generic_test.morphy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ part of 'ex50_json_inheritance_generic_test.dart';

///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class A extends $A {
final String id;

Expand Down Expand Up @@ -45,8 +47,8 @@ class A extends $A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down Expand Up @@ -79,7 +81,10 @@ class B_Generics_Sing {
B_Generics_Sing._internal() {}
}

@JsonSerializable(explicitToJson: true, genericArgumentFactories: true)
@JsonSerializable(
explicitToJson: true,
genericArgumentFactories: true,
)
class B<T> extends $B<T> implements A {
final String id;
final T blah;
Expand Down Expand Up @@ -139,8 +144,8 @@ class B<T> extends $B<T> implements A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand All @@ -162,7 +167,9 @@ enum B$ { id, blah }

///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class X extends $X {
final String xyz;

Expand Down Expand Up @@ -199,8 +206,8 @@ class X extends $X {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down
25 changes: 16 additions & 9 deletions example/test/ex51_json_inheritance_generic_from_test.morphy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ part of 'ex51_json_inheritance_generic_from_test.dart';

///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class A extends $A {
final String id;

Expand Down Expand Up @@ -52,8 +54,8 @@ class A extends $A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down Expand Up @@ -96,7 +98,10 @@ class B_Generics_Sing {
B_Generics_Sing._internal() {}
}

@JsonSerializable(explicitToJson: true, genericArgumentFactories: true)
@JsonSerializable(
explicitToJson: true,
genericArgumentFactories: true,
)
class B<T> extends $B<T> implements A {
final String id;
final T blah;
Expand Down Expand Up @@ -156,8 +161,8 @@ class B<T> extends $B<T> implements A {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand All @@ -179,7 +184,9 @@ enum B$ { id, blah }

///
@JsonSerializable(explicitToJson: true)
@JsonSerializable(
explicitToJson: true,
)
class X extends $X {
final String xyz;

Expand Down Expand Up @@ -216,8 +223,8 @@ class X extends $X {
// ignore: unused_field
Map<Type, Object? Function(Never)> _fns = {};

Map<String, dynamic> toJson_2(Map<Type, Object? Function(Never)> fns) {
this._fns = fns;
Map<String, dynamic> toJson_2([Map<Type, Object? Function(Never)>? fns]) {
this._fns = fns ?? {};
return toJson();
}

Expand Down
Loading

0 comments on commit 5089751

Please sign in to comment.