diff --git a/angel_serialize_generator/CHANGELOG.md b/angel_serialize_generator/CHANGELOG.md index 9102b9ca..4308c950 100644 --- a/angel_serialize_generator/CHANGELOG.md +++ b/angel_serialize_generator/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.2.1 +* Explicit changes for assisting `angel_orm_generator`. + # 2.2.0 * Build to `cache`. * Only generate one `.g.dart` file. diff --git a/angel_serialize_generator/lib/serialize.dart b/angel_serialize_generator/lib/serialize.dart index 3c388972..eaa872aa 100644 --- a/angel_serialize_generator/lib/serialize.dart +++ b/angel_serialize_generator/lib/serialize.dart @@ -61,7 +61,7 @@ class SerializerGenerator extends GeneratorForAnnotation { ..requiredParameters.add(new Parameter((b) { b ..name = 'model' - ..type = ctx.modelClassType; + ..type = refer(ctx.originalClassName); })); var buf = new StringBuffer(); @@ -90,10 +90,9 @@ class SerializerGenerator extends GeneratorForAnnotation { String serializedRepresentation = 'model.${field.name}'; String serializerToMap(ReCase rc, String value) { - if (rc.pascalCase == ctx.modelClassName) { - return '($value)?.toJson()'; - } - + // if (rc.pascalCase == ctx.modelClassName) { + // return '($value)?.toJson()'; + // } return '${rc.pascalCase}Serializer.toMap($value)'; } @@ -110,10 +109,13 @@ class SerializerGenerator extends GeneratorForAnnotation { var t = field.type as InterfaceType; if (isListOfModelType(t)) { - //var rc = new ReCase(t.typeArguments[0].name); + var name = t.typeArguments[0].name; + if (name.startsWith('_')) name = name.substring(1); + var rc = new ReCase(name); + var m = serializerToMap(rc, 'm'); serializedRepresentation = ''' model.${field.name} - ?.map((m) => m.toJson()) + ?.map((m) => $m) ?.toList()'''; } else if (isMapToModelType(t)) { var rc = new ReCase(t.typeArguments[1].name); diff --git a/angel_serialize_generator/pubspec.yaml b/angel_serialize_generator/pubspec.yaml index a44f90b4..5c93388f 100644 --- a/angel_serialize_generator/pubspec.yaml +++ b/angel_serialize_generator/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_serialize_generator -version: 2.2.0 +version: 2.2.1 description: Model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling. author: Tobe O homepage: https://github.com/angel-dart/serialize