-
Notifications
You must be signed in to change notification settings - Fork 185
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 nullable types #790
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
@johynpapin Hello? Any updates on this? |
@yingshaoxo Hello ! I'm waiting for answers from a maintainer, we have to be patient. 😄 |
@johynpapin It looks like the CI failed. Could you help to update your code so that it could pass the CI checking? Thank you, P/s I'm not a maintainer |
The CI failure is an existing issue. We fixed it in master branch, if you could merge master or rebase the branch it should be fixed. (I will be reviewing this soon, sorry for the delay.) |
Hello, I performed a rebase from master 😄 |
@thanhdatvo I made sure that no change is visible if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks @johynpapin.
Answering your questions:
Why is ArgumentError.checkNotNull(value, 'value') used in $_setFloat for example, in generated_message.dart?
The library is still used by non-null-safe Dart, so we need to handle the cases where a non-nullable parameter is passed null
. We have some tests that run with non-null-safe Dart, see e.g. #791 for some recent work on this.
Is it a good idea to modify generated_message.dart and field_set.dart?
This is fine, but GeneratedMessage
members will be usable on messages compiled with or without this feature, so we should make sure they work as expected when called on a message that is compiled without this feature. I added some inline comments on this.
Is it a good idea to add an option to the generator?
Yes!
For tests, is it better to copy the current tests, modifying them to check for nullable types, or is it better to add new tests just for that?
I don't know how to best test this feature yet, I'll need to think more about this. Let me know if you have any ideas.
I think some new tests will be needed as none of the existing tests will be calling the new GeneratedMessage
methods.
Is this feature desired in this package?
Yes, I think this is probably the most frequently requested feature.
fi, value, 'repeating field (use get + .add())')); | ||
} | ||
if (value == null) { | ||
_clearField(tagNumber); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will remove required
fields from the field set, right? I think that's probably OK (removing required fields is already allowed with clearField
), but the documentation says "sets a non-repeated nullable field", and my understanding is only optional fields are nullable.
I think we need two documentation, one for this member with implementation details, one for the GeneratedMessage.setFieldNullable
with how the member is supposed to be used. This should say it will just clear the field (same as _clearField
). GeneratedMessage.setFieldNullable
should clarify what happens when you pass null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I hadn't noticed that!
I'll add some documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed the changes in the documention, I'm not sure if it's right. 😄
@osa1 Thank you for all the answers and the review! 🙏 I'll think about the tests. |
Any update? |
@bjernie Not really, I've been pretty busy lately. But I intend to finish this! 😉 |
How's this going, @johynpapin? Any ways we could be of assistance? |
Hello @craiglabenz! I've finished the small changes mentioned above, but what's mainly missing are tests. I still don't really know how to properly test these changes, I need to read the ones already written. I'll try to do that before the end of this weekend. 😄 |
8dc3cbd
to
1009692
Compare
Hi. Is there any update? |
please rebase this on the latest! |
Hi @kevmoo! First thing I will do tomorrow. |
@kevmoo please check if it is good to go. We won't wanna fall behind master again 😅. |
I think @osa1 needs to help here. |
@osa1 Please have a look as this is much needed feature for sound null safety. |
I'm on leave right now and won't be able to review this any time soon.
This PR is for convenience only. The library is already sound-null-safe, otherwise you wouldn't be able to use it with Dart 3. |
Agreed. The library is Sound null safe but we have to use checks which is kinda annoying. |
@osa1 Any update on this ? |
Any update on this ? |
@kevmoo while osa1 on the leave, can't you review and merge it finally? |
sorry @rostopira – thanks for your patience I don't own or maintain this code. I can't add to the maintenance burden without the owner approving! |
Hi everyone, any update on this? @osa1, are you back from leave? |
Do you have any updates yet? |
We currently don't have any engineering capacity to do a proper review of this PR. @osa1 is an engineer with most context, but he is occupied by more pressing things. Eventually he will get to it, but we are not going to promise any concrete ETA on when this happens. I understand that it might be rather frustrating to have PR languishing in limbo for a while, but unfortunately we are stretched very thin. |
I gave up waiting for it to get merged, I just depend on |
I get it but it is sitting here for a year now. Personally, I am waiting for this PR since its inception. Can you at least try to prioritize this please? I don't see anyone relying on this package when there are wait times this long for a simple but much needed feature to get merged. |
Hello everyone! I just resolved the conflicts, if a rebase is preferred I can do one. 😄 I just wanted to say that I personally don't mind things taking time. I haven't been very reactive on this PR either. 😅 EDIT: By the way, I am in the process of deleting the @johynpapin github account. I will be using @chitochi instead. I hope it will not break too many things in this PR. 😅 |
…tion to hazzers. Signed-off-by: Chito <[email protected]>
Signed-off-by: Chito <[email protected]>
Signed-off-by: Chito <[email protected]>
note that right now, this test is failing
Signed-off-by: Chito <[email protected]>
f8c18bb
to
aa7210e
Compare
Is there any update? |
Hello, are there any plans to get this merged? |
Is there hope for this to work with proto2 aswell? |
any update on this ? |
Hello everyone! 👋
The purpose of this PR is to support nullable types (#523). This allows to use generated messages in this way:
The main advantage of this solution over hazzers is to take advantage of null safety.
Currently, this PR generates nullable types if the field is a message, or if the field is
optional
in the proto3 sense. Hazzers are still generated. To generate nullable types, you must use thenullable
option, which is set tofalse
by default.I'm sure this PR is not mergeable in its current state (no test added), but I'm opening it to be helped and to ask questions. Don't hesitate to tell me if I'm going in the wrong direction!
ArgumentError.checkNotNull(value, 'value')
used in$_setFloat
for example, ingenerated_message.dart
?generated_message.dart
andfield_set.dart
?Thank you very much in advance!