From 02bc43133499939ff9114c8d1040f6877476cfe9 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Wed, 11 Jul 2018 11:49:46 -0400 Subject: [PATCH] Formatting + README --- README.md | 5 ++++ angel_serialize/example/main.dart | 2 +- angel_serialize/lib/angel_serialize.dart | 3 +- angel_serialize_generator/example/main.dart | 2 +- .../test/models/author.serializer.g.dart | 28 +++++++++++++++++++ .../test/models/book.dart | 2 +- .../test/models/book.serializer.g.dart | 12 ++++++++ .../test/models/game_pad.dart | 12 +++++--- .../test/models/game_pad.g.dart | 7 +++-- .../test/models/game_pad.serializer.g.dart | 2 ++ .../test/models/game_pad_button.dart | 2 +- .../models/game_pad_button.serializer.g.dart | 2 ++ .../test/models/with_enum.serializer.g.dart | 2 ++ angel_serialize_generator/tool/build.dart | 2 +- 14 files changed, 70 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 65405b21..5f3ce61c 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,11 @@ The following files will be generated: * `book.g.dart` * `book.serializer.g.dart` +Producing these classes: + * `Book`: Extends or implements `_Book`; may be `const`-enabled. + * `BookSerializer`: static functionality for serializing `Book` models. + * `BookFields`: The names of all fields from the `Book` model, statically-available. + # Serialization You can use the generated files as follows: diff --git a/angel_serialize/example/main.dart b/angel_serialize/example/main.dart index 7ad2b1e0..8aebb4cc 100644 --- a/angel_serialize/example/main.dart +++ b/angel_serialize/example/main.dart @@ -4,4 +4,4 @@ import 'package:angel_serialize/angel_serialize.dart'; class _Todo { String text; bool completed; -} \ No newline at end of file +} diff --git a/angel_serialize/lib/angel_serialize.dart b/angel_serialize/lib/angel_serialize.dart index 51c462e6..b68088c9 100644 --- a/angel_serialize/lib/angel_serialize.dart +++ b/angel_serialize/lib/angel_serialize.dart @@ -42,7 +42,8 @@ class GeneratedSerializable { const GeneratedSerializable(); } -const GeneratedSerializable generatedSerializable = const GeneratedSerializable(); +const GeneratedSerializable generatedSerializable = + const GeneratedSerializable(); /// The supported serialization types. abstract class Serializers { diff --git a/angel_serialize_generator/example/main.dart b/angel_serialize_generator/example/main.dart index 7ad2b1e0..8aebb4cc 100644 --- a/angel_serialize_generator/example/main.dart +++ b/angel_serialize_generator/example/main.dart @@ -4,4 +4,4 @@ import 'package:angel_serialize/angel_serialize.dart'; class _Todo { String text; bool completed; -} \ No newline at end of file +} diff --git a/angel_serialize_generator/test/models/author.serializer.g.dart b/angel_serialize_generator/test/models/author.serializer.g.dart index c14b32e7..a4970f28 100644 --- a/angel_serialize_generator/test/models/author.serializer.g.dart +++ b/angel_serialize_generator/test/models/author.serializer.g.dart @@ -66,6 +66,18 @@ abstract class AuthorSerializer { } abstract class AuthorFields { + static const List allFields = const [ + id, + name, + age, + books, + newestBook, + secret, + obscured, + createdAt, + updatedAt + ]; + static const String id = 'id'; static const String name = 'name'; @@ -125,6 +137,13 @@ abstract class LibrarySerializer { } abstract class LibraryFields { + static const List allFields = const [ + id, + collection, + createdAt, + updatedAt + ]; + static const String id = 'id'; static const String collection = 'collection'; @@ -177,6 +196,15 @@ abstract class BookmarkSerializer { } abstract class BookmarkFields { + static const List allFields = const [ + id, + history, + page, + comment, + createdAt, + updatedAt + ]; + static const String id = 'id'; static const String history = 'history'; diff --git a/angel_serialize_generator/test/models/book.dart b/angel_serialize_generator/test/models/book.dart index b130ee8d..790c8926 100644 --- a/angel_serialize_generator/test/models/book.dart +++ b/angel_serialize_generator/test/models/book.dart @@ -14,4 +14,4 @@ abstract class _Book extends Model { @Alias('camelCase') String camelCaseString; -} \ No newline at end of file +} diff --git a/angel_serialize_generator/test/models/book.serializer.g.dart b/angel_serialize_generator/test/models/book.serializer.g.dart index 4eb44cce..f1eff5f3 100644 --- a/angel_serialize_generator/test/models/book.serializer.g.dart +++ b/angel_serialize_generator/test/models/book.serializer.g.dart @@ -47,6 +47,18 @@ abstract class BookSerializer { } abstract class BookFields { + static const List allFields = const [ + id, + author, + title, + description, + pageCount, + notModels, + camelCaseString, + createdAt, + updatedAt + ]; + static const String id = 'id'; static const String author = 'author'; diff --git a/angel_serialize_generator/test/models/game_pad.dart b/angel_serialize_generator/test/models/game_pad.dart index 9d158051..7503cd75 100644 --- a/angel_serialize_generator/test/models/game_pad.dart +++ b/angel_serialize_generator/test/models/game_pad.dart @@ -1,12 +1,16 @@ import 'package:angel_serialize/angel_serialize.dart'; import 'package:collection/collection.dart'; import 'game_pad_button.dart'; + part 'game_pad.g.dart'; + part 'game_pad.serializer.g.dart'; @Serializable(autoIdAndDateFields: false) -abstract class _Gamepad { - List get buttons; +class _Gamepad { + List buttons; - Map get dynamicMap; -} \ No newline at end of file + Map dynamicMap; + + String _somethingPrivate; +} diff --git a/angel_serialize_generator/test/models/game_pad.g.dart b/angel_serialize_generator/test/models/game_pad.g.dart index fedaf393..f1797746 100644 --- a/angel_serialize_generator/test/models/game_pad.g.dart +++ b/angel_serialize_generator/test/models/game_pad.g.dart @@ -7,9 +7,10 @@ part of 'game_pad.dart'; // ************************************************************************** @generatedSerializable -class Gamepad implements _Gamepad { - const Gamepad( - {List this.buttons, Map this.dynamicMap}); +class Gamepad extends _Gamepad { + Gamepad({List buttons, Map dynamicMap}) + : this.buttons = new List.unmodifiable(buttons ?? []), + this.dynamicMap = new Map.unmodifiable(dynamicMap ?? {}); @override final List buttons; diff --git a/angel_serialize_generator/test/models/game_pad.serializer.g.dart b/angel_serialize_generator/test/models/game_pad.serializer.g.dart index 7f60eb7e..ce27183b 100644 --- a/angel_serialize_generator/test/models/game_pad.serializer.g.dart +++ b/angel_serialize_generator/test/models/game_pad.serializer.g.dart @@ -29,6 +29,8 @@ abstract class GamepadSerializer { } abstract class GamepadFields { + static const List allFields = const [buttons, dynamicMap]; + static const String buttons = 'buttons'; static const String dynamicMap = 'dynamic_map'; diff --git a/angel_serialize_generator/test/models/game_pad_button.dart b/angel_serialize_generator/test/models/game_pad_button.dart index fe61c5aa..e3777b75 100644 --- a/angel_serialize_generator/test/models/game_pad_button.dart +++ b/angel_serialize_generator/test/models/game_pad_button.dart @@ -6,4 +6,4 @@ part 'game_pad_button.serializer.g.dart'; abstract class _GamepadButton { String get name; int get radius; -} \ No newline at end of file +} diff --git a/angel_serialize_generator/test/models/game_pad_button.serializer.g.dart b/angel_serialize_generator/test/models/game_pad_button.serializer.g.dart index 06d3ad1a..e9cb0dfa 100644 --- a/angel_serialize_generator/test/models/game_pad_button.serializer.g.dart +++ b/angel_serialize_generator/test/models/game_pad_button.serializer.g.dart @@ -21,6 +21,8 @@ abstract class GamepadButtonSerializer { } abstract class GamepadButtonFields { + static const List allFields = const [name, radius]; + static const String name = 'name'; static const String radius = 'radius'; diff --git a/angel_serialize_generator/test/models/with_enum.serializer.g.dart b/angel_serialize_generator/test/models/with_enum.serializer.g.dart index d7d230d2..9d545083 100644 --- a/angel_serialize_generator/test/models/with_enum.serializer.g.dart +++ b/angel_serialize_generator/test/models/with_enum.serializer.g.dart @@ -30,6 +30,8 @@ abstract class WithEnumSerializer { } abstract class WithEnumFields { + static const List allFields = const [type, finalList]; + static const String type = 'type'; static const String finalList = 'final_list'; diff --git a/angel_serialize_generator/tool/build.dart b/angel_serialize_generator/tool/build.dart index 8bb0bc7e..6bb6d535 100644 --- a/angel_serialize_generator/tool/build.dart +++ b/angel_serialize_generator/tool/build.dart @@ -1,4 +1,4 @@ import 'package:build_runner/build_runner.dart'; import 'applications.dart'; -main() => build(applications, deleteFilesByDefault: true, verbose: false); \ No newline at end of file +main() => build(applications, deleteFilesByDefault: true, verbose: false);