-
-
Notifications
You must be signed in to change notification settings - Fork 32
An empty fields bug fix #92
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
Conversation
|
What is the use case for storing a class with no fields? Wouldn't that basically be an enum? As for the second case where you don't have the fields in the constructor that also seems like something you should use an enum for. |
|
Also if you want this merged it needs a test |
|
In this usecase, I have a class UserPreferences, that has last sorting method used as a field, which has an object that is inherited from an abstract sort class. One of its implementations is a class EmptySort, which means that they are not sorted. It doesn't have any fields, but it can't be an enum because all other types of sort have fields that are not same for all of them (its a more complex sorting algorithm). I would say, each inheritance tree that have one non abstract class that is free of constructir fields currently have a bug with hive_ce. I migrated from hive, and I didn't notice this bug there in production (but maybe it was there the whole time). When I looked at the implementations, only their write method was generated differently - they didn't writeByte(0), they wrote the private fields out to the writer. Sorry for not writing a test, I wanted but couldn't find a place for this one. It would be great if you can do it. |
|
It looks like there aren't actually any existing tests for the type adapter code generation, but the existing tests should help you formulate one for this PR. You can add a test to |
|
Was there something wrong with the Hive PR solution of removing the if statement for not having fields? It looks like that code should work. |
|
It should work as well. That PR doesn't have a test, and is not merged there as well though. |
|
If that solution works I prefer it since all generated adapters are the same with that change |
|
Also with that change I think we can get away with not adding a test |
|
I decided to take your change since the other one creates analysis issues |
|
Yeah, I guess it is better because the approach that is meant for non-empty fields will create closing |
|
Also the fact that there is already an if condition means that the creator thought it through, just forgot to either remove |
|
Removing the length byte would probably break things |
|
Released in version |
|
Whoops forgot to give you credit hold on |
|
There we go. Thank you for the contribution! |
|
Thank you for the credit @Rexios80! |
|
It makes me feel good when other maintainers do it for me, so I like to pass on the good vibes. |
Currently, when a class doesn't have Hive Fields, it writes a byte in write method, but doesn't read it in the read method, which breaks the reading of the classes after that one.
I didn't write any tests for this, but I tried it in my project, and it works.
P.S. That bug is also present if there are HiveFields, but they are not in the constructor, like this:
In the screenshots above, the change is generated by this fix commit.