-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
2.4.3 - Breaking Changes + Issues #986
Comments
The json rename sounds more like a bug fix than a breaking change to me. I'll investigate the other issue though |
Hmm. Even if you were to argue that it's a bug fix and not an introduced bug. It's still a breaking change since it's breaking the pre-existing working code. P.s. I don't mind updating it on my end if you decide it should stay like this starting with 2.4.3. I do expect however you'll receive more issues reported on it. |
Updating to 2.4.3 broke our existing Freezed with Hive.
Generated Hive TypeAdapters in
to
Importing the new Adapters fixed the issue, but quite tedious. |
_$CartImpl isn't meant to be used. Its name shouldn't matter for you. So it's a breach of contract if renaming that class broke your code. Sounds like you used something which you shouldn't have (or hive did in this case). |
@AlexDochioiu I checked your code but it works for me. I'll leave this open to discuss the possibly breaking nature of this change – even if it's meant to be bugfixes. If you think this should be a 3.0.0 version, please 👍 the issue |
@rrousselGit For me it would make sense to be a 3.0.0 as long as you can remove 2.4.3 from pub.dev (so that people don't get auto-updated to this version using a simple upgrade command). If you plan to keep 2.4.3 (or if it cannot be removed from pub.dev), then I guess there's no real benefit to upgrade the major version anymore. |
I have a few days left to pull down the version. Hive's case is problematic, but that's because the use-case didn't respect privacy rules (using stuff that is internal to Freezed). Whereas while the $ -> _$ thing is bothering, it was a bug. And bugfixes shouldn't count as breaking changes. |
Was it really a bug though? I'd argue the old behaviour was the better/correct one. While dart uses the leading underscore to define visibility, it's also still part of the class/property/etc name. And the language doesn't mind if you define two different classes/variables/etc as The following scenario (for example) works with 2.4.2 but wouldn't work with 2.4.3 since the from json method would have the same name. import 'package:freezed_annotation/freezed_annotation.dart';
part 'test.freezed.dart';
part 'test.g.dart';
@freezed
class Test with _$Test {
const Test._();
const factory Test(String entry) = _Test1;
factory Test.fromJson(Map<String, dynamic> json) => _$TestFromJson(json);
}
@freezed
class _Test with _$_Test {
const _Test._();
const factory _Test(String entry) = _Test2;
factory _Test.fromJson(Map<String, dynamic> json) => _$_TestFromJson(json);
} As for the other part. I think a breaking change should only be defined based on whether it starts breaking the build phase. I think the cause of the change (improvement/bug fixing/etc) is irrelevant for the definition. |
P.s. I hope I don't come too harsh. In all honesty I personally think freezed is in top 3 best and most important libraries for flutter/dart (especially as someone migrating over from kotlin). So really appreciate your work with it. |
It is a bug. There have been numerous bug reports about this. Writing $ does not respect Dart naming conventions and triggers warnings If you look at other code generators, they correctly change _foo into _$foo instead of _$_foo. And generally speaking, bug fixes don't count as breaking changes. |
The change of 2.4.3 does more harm than good. When |
A relative minor issue with this change is that the snippets break after this change. |
I bumped into this issue as well now and I think doing this as a major version change would have been a better experience as a user of the package. The main reason is that when I bump packages and only touch the minor and patch versions I expect things to continue working. Having a section in the docs about using Freezed with private classes would probably have saved me some time here as well. The docs was the first place I stared looking when getting the error. |
Breaking Change (1):
For private classes, the name of the FromJson changed
Take this class for example:
The underscore after the
$
is now missing.`
Breaking Change (2):
Cannot generate toJson anymore. This used to work with 2.4.2.
P.s. If you run the code below with 2.4.2, you'll need to fix the fromJson methods (mentioned in first issue)
P.s. this is a slightly shorter/simplified version of my actual code.
The text was updated successfully, but these errors were encountered: