Skip to content

Commit e77b990

Browse files
committed
fix: fixes after rebase
1 parent 839e402 commit e77b990

File tree

7 files changed

+75
-91
lines changed

7 files changed

+75
-91
lines changed

example/lib/complex_sealed_class_examples.g.dart

Lines changed: 20 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/lib/sealed_class_example.g.dart

Lines changed: 22 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

json_annotation/CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
- Add `JsonSerializable.unionRename`
44
- Add `JsonSerializable.unionDiscriminator`
5-
6-
## 4.9.1-wip
7-
85
- Require Dart 3.8
96

107
## 4.9.0

json_serializable/CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
## 6.10.0
1+
## 6.11.0-wip
22

33
- Add support for deserializing union json to sealed class
44
- Add support for serializing sealed class to union json
55

6-
## 6.9.6-wip
6+
## 6.10.0
77

8-
- Required `analyzer: ^7.4.0`.
9-
- Switch to analyzer element2 model and `build: ^3.0.0-dev`.
108
- Move `package:collection` to a dev dependency.
119
- Use new `null-aware element` feature in generated code.
1210
- Require Dart 3.8

json_serializable/example/sealed_example.g.dart

Lines changed: 16 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

json_serializable/lib/src/generator_helper.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:analyzer/dart/element/element2.dart';
66
import 'package:build/build.dart';
7-
import 'package:collection/collection.dart';
87
import 'package:source_gen/source_gen.dart';
98

109
import '../type_helper.dart';
@@ -56,7 +55,7 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
5655
),
5756
);
5857

59-
if (sealedSupersAndConfigs.firstWhereOrNull((e) => e.config == null)
58+
if (sealedSupersAndConfigs.where((e) => e.config == null).firstOrNull
6059
case final notAnnotated? when sealedSupersAndConfigs.isNotEmpty) {
6160
throw InvalidGenerationSourceError(
6261
'The class `${element.displayName}` is annotated '
@@ -82,9 +81,11 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
8281
);
8382
}
8483

85-
if (sealedSupersAndConfigs.firstWhereOrNull(
86-
(e) => e.config?.unionDiscriminator == config.unionDiscriminator,
87-
)
84+
if (sealedSupersAndConfigs
85+
.where(
86+
(e) => e.config?.unionDiscriminator == config.unionDiscriminator,
87+
)
88+
.firstOrNull
8889
case final conflictingSuper? when element.isSealed) {
8990
throw InvalidGenerationSource(
9091
'The classes `${conflictingSuper.classElement.displayName}` and '
@@ -97,9 +98,9 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
9798
);
9899
}
99100

100-
if (sealedSupersAndConfigs.firstWhereOrNull(
101-
(e) => e.config?.createToJson != config.createToJson,
102-
)
101+
if (sealedSupersAndConfigs
102+
.where((e) => e.config?.createToJson != config.createToJson)
103+
.firstOrNull
103104
case final diffSuper?) {
104105
throw InvalidGenerationSourceError(
105106
'The class `${diffSuper.classElement.displayName}` is sealed but its '
@@ -192,9 +193,9 @@ class GeneratorHelper extends HelperCore with EncodeHelper, DecodeHelper {
192193
..fold(<String>{}, (Set<String> set, fe) {
193194
final jsonKey = nameAccess(fe);
194195

195-
if (sealedSupersAndConfigs.firstWhereOrNull(
196-
(e) => e.config?.unionDiscriminator == jsonKey,
197-
)
196+
if (sealedSupersAndConfigs
197+
.where((e) => e.config?.unionDiscriminator == jsonKey)
198+
.firstOrNull
198199
case final conflict?) {
199200
throw InvalidGenerationSourceError(
200201
'The JSON key `$jsonKey` is conflicting with the discriminator '

json_serializable/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: json_serializable
2-
version: 6.10.0
2+
version: 6.11.0-wip
33
description: >-
44
Automatically generate code for converting to and from JSON by annotating
55
Dart classes.
@@ -15,11 +15,11 @@ topics:
1515
resolution: workspace
1616

1717
dependencies:
18-
analyzer: ^7.4.0
18+
analyzer: '>=7.4.0 <8.0.0'
1919
async: ^2.10.0
2020
build: ^3.0.0
2121
build_config: ^1.1.0
22-
dart_style: '>=2.3.7 <4.0.0'
22+
dart_style: '>=3.1.0 <4.0.0'
2323

2424
# Use a tight version constraint to ensure that a constraint on
2525
# `json_annotation` properly constrains all features it provides.

0 commit comments

Comments
 (0)