Skip to content

Commit 69603d2

Browse files
committed
refactor: rearrange files for a more consistent layout and extract annotations from converter.dart
1 parent 1ef7267 commit 69603d2

File tree

21 files changed

+158
-231
lines changed

21 files changed

+158
-231
lines changed

benchmarks/pubspec.lock

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ packages:
7777
dependency: transitive
7878
description:
7979
name: build
80-
sha256: "6439a9c71a4e6eca8d9490c1b380a25b02675aa688137dfbe66d2062884a23ac"
80+
sha256: ce76b1d48875e3233fde17717c23d1f60a91cc631597e49a400c89b475395b1d
8181
url: "https://pub.dev"
8282
source: hosted
83-
version: "3.0.2"
83+
version: "3.1.0"
8484
build_config:
8585
dependency: transitive
8686
description:
@@ -101,42 +101,42 @@ packages:
101101
dependency: transitive
102102
description:
103103
name: build_modules
104-
sha256: "78f00844db79736785b1f00aa416bf8187936a4033246104f299e60c8ba73531"
104+
sha256: "5d599f7213e465cbc5193f73d7b323a9e6d7d300734b63a63eb99500cba259ac"
105105
url: "https://pub.dev"
106106
source: hosted
107-
version: "5.0.16"
107+
version: "5.0.17"
108108
build_resolvers:
109109
dependency: transitive
110110
description:
111111
name: build_resolvers
112-
sha256: "2b21a125d66a86b9511cc3fb6c668c42e9a1185083922bf60e46d483a81a9712"
112+
sha256: d1d57f7807debd7349b4726a19fd32ec8bc177c71ad0febf91a20f84cd2d4b46
113113
url: "https://pub.dev"
114114
source: hosted
115-
version: "3.0.2"
115+
version: "3.0.3"
116116
build_runner:
117117
dependency: "direct dev"
118118
description:
119119
name: build_runner
120-
sha256: fd3c09f4bbff7fa6e8d8ef688a0b2e8a6384e6483a25af0dac75fef362bcfe6f
120+
sha256: b24597fceb695969d47025c958f3837f9f0122e237c6a22cb082a5ac66c3ca30
121121
url: "https://pub.dev"
122122
source: hosted
123-
version: "2.7.0"
123+
version: "2.7.1"
124124
build_runner_core:
125125
dependency: transitive
126126
description:
127127
name: build_runner_core
128-
sha256: ab27e46c8aa233e610cf6084ee6d8a22c6f873a0a9929241d8855b7a72978ae7
128+
sha256: "066dda7f73d8eb48ba630a55acb50c4a84a2e6b453b1cb4567f581729e794f7b"
129129
url: "https://pub.dev"
130130
source: hosted
131-
version: "9.3.0"
131+
version: "9.3.1"
132132
build_web_compilers:
133133
dependency: "direct dev"
134134
description:
135135
name: build_web_compilers
136-
sha256: "7a6bb81907c3cdcc538af003db497cb9af37c94991bc960f9f25affd7a15df15"
136+
sha256: f730cf4decb4e3906cd93a8777500aa8daf55dac64f46cf5ec33b83d2cf635c5
137137
url: "https://pub.dev"
138138
source: hosted
139-
version: "4.2.2"
139+
version: "4.2.3"
140140
built_collection:
141141
dependency: "direct main"
142142
description:
@@ -149,18 +149,18 @@ packages:
149149
dependency: "direct main"
150150
description:
151151
name: built_value
152-
sha256: ba95c961bafcd8686d1cf63be864eb59447e795e124d98d6a27d91fcd13602fb
152+
sha256: a30f0a0e38671e89a492c44d005b5545b830a961575bbd8336d42869ff71066d
153153
url: "https://pub.dev"
154154
source: hosted
155-
version: "8.11.1"
155+
version: "8.12.0"
156156
built_value_generator:
157157
dependency: "direct dev"
158158
description:
159159
name: built_value_generator
160-
sha256: "82281895e5347dd70ffd3aab2756f39d52b55c945fa0efa635ad6d643dae5833"
160+
sha256: "65f5823a2c4158384ebc845218e19286fdf5dd04f8ac2cf607b01a502be40b1b"
161161
url: "https://pub.dev"
162162
source: hosted
163-
version: "8.11.1"
163+
version: "8.12.0"
164164
cbor:
165165
dependency: transitive
166166
description:
@@ -255,35 +255,35 @@ packages:
255255
path: "../formats/dogs_cbor"
256256
relative: true
257257
source: path
258-
version: "2.3.5-dev.4"
258+
version: "2.3.5-dev.6"
259259
dogs_core:
260260
dependency: "direct main"
261261
description:
262262
path: "../packages/dogs_core"
263263
relative: true
264264
source: path
265-
version: "10.0.0-dev.4"
265+
version: "10.0.0-dev.6"
266266
dogs_generator:
267267
dependency: "direct dev"
268268
description:
269269
path: "../packages/dogs_generator"
270270
relative: true
271271
source: path
272-
version: "7.0.0-dev.4"
272+
version: "7.0.0-dev.6"
273273
dogs_toml:
274274
dependency: "direct main"
275275
description:
276276
path: "../formats/dogs_toml"
277277
relative: true
278278
source: path
279-
version: "2.3.5-dev.4"
279+
version: "2.3.5-dev.6"
280280
dogs_yaml:
281281
dependency: "direct main"
282282
description:
283283
path: "../formats/dogs_yaml"
284284
relative: true
285285
source: path
286-
version: "2.3.5-dev.4"
286+
version: "2.3.5-dev.6"
287287
duffer:
288288
dependency: transitive
289289
description:
@@ -432,10 +432,10 @@ packages:
432432
dependency: "direct dev"
433433
description:
434434
name: json_serializable
435-
sha256: "3f2913b7c2430afe8ac5afe6fb15c1de4a60af4f630625e6e238f80ba4b80cbd"
435+
sha256: "33a040668b31b320aafa4822b7b1e177e163fc3c1e835c6750319d4ab23aa6fe"
436436
url: "https://pub.dev"
437437
source: hosted
438-
version: "6.11.0"
438+
version: "6.11.1"
439439
lints:
440440
dependency: "direct dev"
441441
description:
@@ -456,18 +456,18 @@ packages:
456456
dependency: transitive
457457
description:
458458
name: lyell
459-
sha256: "552cbf1ae9ba85040c0da34e1bbb2bcec769de4ee9a97ffb3496e60fbd8e03de"
459+
sha256: "0cad511dc437e83acc9c4e1a30dcbe984c95e91fa0ad48623e3d2c61e358f3b4"
460460
url: "https://pub.dev"
461461
source: hosted
462-
version: "1.4.5"
462+
version: "1.4.6"
463463
lyell_gen:
464464
dependency: transitive
465465
description:
466466
name: lyell_gen
467-
sha256: ce9d006796e2f8286c68e988f7ed7aa1e98e993838ed4e5120d7a526caef0cee
467+
sha256: "90eafd2e98c7f8d67c1c10ab4f36f447bd7a533e767005089e3b1981a3718a4d"
468468
url: "https://pub.dev"
469469
source: hosted
470-
version: "3.0.9"
470+
version: "3.0.12"
471471
matcher:
472472
dependency: transitive
473473
description:
@@ -608,10 +608,10 @@ packages:
608608
dependency: transitive
609609
description:
610610
name: scratch_space
611-
sha256: "816989dd0a1f92cd5f0db012ed330035571034956dc3593fba66aaa6ee6a7e43"
611+
sha256: efe807ddf27b148b500465957ceee4255deb4a8558575530b6398840436300ce
612612
url: "https://pub.dev"
613613
source: hosted
614-
version: "1.1.0"
614+
version: "1.1.1"
615615
shelf:
616616
dependency: transitive
617617
description:
@@ -656,10 +656,10 @@ packages:
656656
dependency: transitive
657657
description:
658658
name: source_helper
659-
sha256: a447acb083d3a5ef17f983dd36201aeea33fedadb3228fa831f2f0c92f0f3aca
659+
sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723"
660660
url: "https://pub.dev"
661661
source: hosted
662-
version: "1.3.7"
662+
version: "1.3.8"
663663
source_map_stack_trace:
664664
dependency: transitive
665665
description:

packages/dogs_core/lib/dogs_core.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ library;
2121
// Include lyell
2222
export "package:lyell/lyell.dart";
2323

24+
export "src/annotations.dart";
2425
export "src/codec.dart";
2526
export "src/converter.dart";
2627
export "src/converters/common.dart";

packages/dogs_core/lib/dogs_validation.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
library;
1818

19-
export "validation/blank.dart";
20-
export "validation/description.dart";
21-
export "validation/length.dart";
22-
export "validation/must_match.dart" hide MustMatchCacheEntry;
23-
export "validation/range.dart";
24-
export "validation/regex.dart" hide RegexCacheEntry;
25-
export "validation/size.dart";
26-
export "validation/validated.dart" hide ValidatedCacheEntry;
19+
export "src/validation/validators/blank.dart";
20+
export "src/schema/annotations/description.dart";
21+
export "src/validation/validators/length.dart";
22+
export "src/validation/validators/must_match.dart" hide MustMatchCacheEntry;
23+
export "src/validation/validators/range.dart";
24+
export "src/validation/validators/regex.dart" hide RegexCacheEntry;
25+
export "src/validation/validators/size.dart";
26+
export "src/validation/validators/validated.dart" hide ValidatedCacheEntry;
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// TODO: Future replacement for @serializable
2+
import "package:dogs_core/dogs_core.dart";
3+
import "package:meta/meta.dart";
4+
5+
/// Configures the dogs structuration of a class or enum.
6+
class Structure extends Serializable implements StructureMetadata {
7+
/// If the type is serializable.
8+
final bool serializable;
9+
10+
/// Configures the dogs structuration of a class or enum.
11+
const Structure({this.serializable = false, super.serialName});
12+
}
13+
14+
/// See @[serializable].
15+
class Serializable {
16+
/// The name of the type used for serialization.
17+
final String? serialName;
18+
19+
/// See @[serializable].
20+
const Serializable({this.serialName});
21+
}
22+
23+
/// Marks a class or enum as serializable.
24+
const serializable = Structure(serializable: true);
25+
26+
@internal
27+
class DogLinked {
28+
const DogLinked();
29+
}
30+
31+
/// Manually marks a custom dog converter implementation for linking.
32+
/// The dogs_generator will then include an instance of this converter.
33+
const linkSerializer = DogLinked();
34+
35+
/// Automatically links a [DogLinkable] object when running the generated
36+
/// dogs plugin.
37+
const dogsLinked = DogLinked();
38+
39+
/// Supplier function for default values.
40+
typedef DefaultValueSupplier = dynamic Function();
41+
42+
class _BeanIgnore {
43+
const _BeanIgnore();
44+
}
45+
46+
/// Marks a property as ignored when using the bean conformity.
47+
const beanIgnore = _BeanIgnore();
48+
49+
/// Marks a property as polymorphic, meaning its values type can vary.
50+
class _Polymorphic extends StructureMetadata {
51+
const _Polymorphic();
52+
}
53+
54+
/// Marks a property as polymorphic, meaning its value's type can vary.
55+
const polymorphic = _Polymorphic();
56+
57+
@internal
58+
59+
/// Checks if a field is marked as polymorphic.
60+
bool isPolymorphicField(DogStructureField field) {
61+
return field.annotationsOf<_Polymorphic>().isNotEmpty;
62+
}
63+
64+
/// Overrides the name that will be used by the [GeneratedDogConverter] for this
65+
/// specific property. By default, the field name will be used.
66+
class PropertyName {
67+
/// The name of the property used as a map key in serialization.
68+
final String name;
69+
70+
/// Instantiates a new [PropertyName] with the given [name].
71+
const PropertyName(this.name);
72+
}
73+
74+
/// Overrides the serializer that will be used by the [GeneratedDogConverter]
75+
/// for this specific property. By default, the field will be serialized using
76+
/// the convert associated with its type.
77+
class PropertySerializer {
78+
/// The type of the serializer.
79+
final Type type;
80+
81+
/// Instantiates a new [PropertySerializer] with the given [type].
82+
const PropertySerializer(this.type);
83+
}
84+
85+
/// Configures how the [GeneratedEnumDogConverter] will serialize this individual
86+
/// enum value. The name can be overridden by specifying a [name]. This enum
87+
/// value can also be marked as the fallback value.
88+
class EnumProperty {
89+
/// The name of the enum value used as a map key in serialization.
90+
final String? name;
91+
92+
/// If this enum value should be used as a fallback value when an invalid
93+
/// value is encountered during deserialization.
94+
final bool fallback;
95+
96+
/// Instantiates a new [EnumProperty] with the given [name] and [fallback].
97+
const EnumProperty({this.name, this.fallback = false});
98+
}

0 commit comments

Comments
 (0)