New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for json_serializable 5.0.0 #474
Comments
I tested with those updated dependencies: analyzer: ^2.0.0
json_serializable: ^5.0.0
json_annotation: ^4.1.0 test are failing because json_serializable generates faulty export.g.dart// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'export.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$_Export _$$_ExportFromJson(Map<String, dynamic> json) => _$_Export(
json['a'] as int,
);
Map<String, dynamic> _$$_ExportToJson(_$_Export instance) => <String, dynamic>{
'a': instance.a,
};
The function name I'm not sure if this is an issue with json_serializable or analyzer. This needs more investigation. |
@SunlightBro I don't think this is a faulty behavior, since the changelog contains:
this seems to be intentional: google/json_serializable.dart@c72dd11 although I don't quite understand the reason for that change, since it was somehow related to |
Ok I created a PR, So Don't see a better way then just to add some //ignore: invalid_annotation_target And I don't really like that. |
@SunlightBro maybe I'm wrong, but there is no real reason to use JsonKey from json_annotation to begin with.. freezed could provide it's own (Freezed)JsonKey (maybe subclass/implements the original?). If i understand it correctly, json_serializable always ignored the annotations on parameters, and only detected the ones in the code which freezed generates? So users would use freezed annotations and freezed generates the correct JsonKey annotations. 🤔 |
Yes but currently it's implemented using the annotations from json_annotation.
cannot be named the same. |
I will discuss with the meta team to see if the lint can be disabled when an annotation is applied on a Freezed constructor. |
@rrousselGit any ideas for an interim solution? |
Is this resolved yet?
|
Closing since json_serializable 5.0.0 is supported |
@rrousselGit so the proposed solution is including ignores everywhere? So let's put it like this: if we upgrade to |
@creativecreatorormaybenot i guess technically your build breaks due to the json_serializable update, which is a major version change and hence breaks compatibility by definition 🤔 |
This issue was about supporting the version 5.0.0, which is now done. The warnings needs to be tackled separately. |
But for now, I would suggest disabling the |
@rrousselGit sounds good 👍 Is there an issue for tracking the warnings here? Or just https://github.com/dart-lang/linter/issues/2778? |
There is #488 But do note that considering the amount of work necessary to fix the warning, I probably won't work on it. |
@rrousselGit
I had to go back to json_serializable 4.1.3. |
@rrousselGit I had to go back to freezed: 0.14.2 and json_serializable 4.1.3. |
@rrousselGit |
Sounds like you used either upgraded freezed without upgrading json_serializable, or did the opposite. |
@rrousselGit |
With the publication of json_serializable 5.0.0 yesterday, is it planned to update freezed to use this release?
json_serializable >=5.0.0 depends on analyzer ^2.0.0 and freezed 0.14.2 depends on analyzer ^1.5.0, json_serializable >=5.0.0 is incompatible with freezed 0.14.2
The text was updated successfully, but these errors were encountered: