2.2.2 add idioms

This commit is contained in:
Tobe O 2019-01-25 09:44:58 -05:00
parent d97feaa899
commit 532301432a
4 changed files with 27 additions and 23 deletions

View file

@ -1,3 +1,7 @@
# 2.2.2
* Add `HasAlias`, `DefaultsTo`, `nullable` idioms.
* `isNullable` defaults to `false` now.
# 2.2.1
* Add `serializesTo`.

View file

@ -1,26 +1,23 @@
export 'package:quiver_hashcode/hashcode.dart' show hashObjects;
/// Excludes a field from being excluded.
@deprecated
class Exclude {
final bool canSerialize;
final bool canDeserialize;
const Exclude({this.canDeserialize: false, this.canSerialize: false});
class Exclude extends SerializableField {
const Exclude({bool canDeserialize: false, bool canSerialize: false})
: super(canDeserialize: canDeserialize, canSerialize: canSerialize);
}
@deprecated
// ignore: deprecated_member_use
const SerializableField nullable = const SerializableField(isNullable: true);
const Exclude exclude = const Exclude();
@deprecated
/// Shorthand for [SerializableField].
class DefaultsTo extends SerializableField {
const DefaultsTo(value) : super(defaultValue: value);
}
/// Prefer [SerializableField] instead.
class DefaultValue {
final value;
const DefaultValue(this.value);
/// Shorthand for [SerializableField].
class HasAlias extends SerializableField {
const HasAlias(String name) : super(alias: name);
}
/// Attaches options to a field.
@ -66,7 +63,7 @@ class SerializableField {
this.serializer,
this.deserializer,
this.errorMessage,
this.isNullable: true,
this.isNullable: false,
this.exclude: false,
this.canDeserialize: false,
this.canSerialize: false,
@ -122,6 +119,13 @@ abstract class Serializers {
static const int typescript = 2;
}
@deprecated
class DefaultValue {
final value;
const DefaultValue(this.value);
}
@deprecated
/// Prefer [SerializableField] instead.

View file

@ -1,5 +1,5 @@
name: angel_serialize
version: 2.2.1+2
version: 2.2.2
description: Static annotations powering Angel model serialization. Combine with angel_serialize_generator for flexible modeling.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/serialize

View file

@ -32,12 +32,8 @@ const TypeChecker generatedSerializableTypeChecker =
final Map<String, BuildContext> _cache = {};
/// Create a [BuildContext].
Future<BuildContext> buildContext(
ClassElement clazz,
ConstantReader annotation,
BuildStep buildStep,
Resolver resolver,
bool autoSnakeCaseNames,
Future<BuildContext> buildContext(ClassElement clazz, ConstantReader annotation,
BuildStep buildStep, Resolver resolver, bool autoSnakeCaseNames,
{bool heedExclude: true}) async {
var id = clazz.location.components.join('-');
if (_cache.containsKey(id)) {