Skip to content

Conversation

@Goddchen
Copy link
Contributor

@Goddchen Goddchen commented Mar 6, 2021

Migrating pigeon package to null-safety.

I marked this as a draft because I have trouble getting one test to pass: packages/pigeon/mock_handler_tester/test/widget_test.dart:calling methods with null and I just can't work it out :/ The call throws an AssertionError, which is the expected behavior. Yet the test fails stating that this error was thrown. Can anyone help?

@google-cla
Copy link

google-cla bot commented Mar 6, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@Goddchen
Copy link
Contributor Author

Goddchen commented Mar 6, 2021

@googlebot I signed it!

@mitchross
Copy link

I really need this pacakge too... How do I include this fork in my own project?

@mitchross
Copy link

mitchross commented Mar 9, 2021

@Goddchen here is your error
image
image

@Goddchen
Copy link
Contributor Author

Goddchen commented Mar 9, 2021

thanks @mitchross . I didn't event notice this test failing. It's fixed. But the other one that I mentioned in the PR descriptions still puzzles me.

@Goddchen
Copy link
Contributor Author

Goddchen commented Mar 9, 2021

Also the local_tests CHANNEL:master check fails with the message No dart files found at: /private/var/folders/sr/b58hwhtj0jbcf4r09zmg0wlc0000gn/T/cirrus-ci-build/packages/pigeon/lib. Well... Obviously there are Dart files in that folder?! 🤷‍♂️

@mitchross
Copy link

@Goddchen did lots of digging, the issue isn't the unit test, the issue is the assertion throw "fails" the unit test. The unit test will catch it, but it doesn't matter if you comment out the entire test, the test still fails!

image

@Goddchen
Copy link
Contributor Author

Goddchen commented Mar 9, 2021

@mitchross Yeah, I see that piece of code. What puzzles me really is that if I replace the throwing .send(null) code with just an assert(false); failing assertion. The whole test just runs fine. What's the difference between my assert(...) and the one from the code you just showed? 🤔

@mitchross
Copy link

@mitchross Yeah, I see that piece of code. What puzzles me really is that if I replace the throwing .send(null) code with just an assert(false); failing assertion. The whole test just runs fine. What's the difference between my assert(...) and the one from the code you just showed? 🤔

Do what you suggested, I think this is a bad test setup, with null-safety, it doesn't even make sense anymore.

plus with this todo, id go with your suggestion
image

@Goddchen
Copy link
Contributor Author

Goddchen commented Mar 9, 2021

Fixed it! After giving it a bit more thought, my finding was that the generated code was actually not doing exactly what it was intended to do. It should handle the null case properly - which it does now.

@Goddchen
Copy link
Contributor Author

Goddchen commented Mar 9, 2021

Also the local_tests CHANNEL:master check fails with the message No dart files found at: /private/var/folders/sr/b58hwhtj0jbcf4r09zmg0wlc0000gn/T/cirrus-ci-build/packages/pigeon/lib. Well... Obviously there are Dart files in that folder?! 🤷‍♂️

I still don't get what is wrong with this check... The files are there... What's the problem...

@mitchross
Copy link

Also the local_tests CHANNEL:master check fails with the message No dart files found at: /private/var/folders/sr/b58hwhtj0jbcf4r09zmg0wlc0000gn/T/cirrus-ci-build/packages/pigeon/lib. Well... Obviously there are Dart files in that folder?! 🤷‍♂️

I still don't get what is wrong with this check... The files are there... What's the problem...

The all checks have passed by github, I think you are fine...

Can you also explain the fix a bit more? I went deep into this code and I'm very curious!

mitchross referenced this pull request Mar 10, 2021
- Use generic Map and List instead of specific ArrayList and HashMap
- Allow callback of the flutter api method to be null

This fixes flutter/flutter#66453
This resolves java side of the flutter/flutter#58913
@Goddchen
Copy link
Contributor Author

@gaaclarke Still getting this strange No dart files found at: /private/var/folders/sr/b58hwhtj0jbcf4r09zmg0wlc0000gn/T/cirrus-ci-build/packages/pigeon/lib error on local_tests CHANNEL:master. Can you make any sense out of it? I find it especially strange since the same thing runs just fine in the local_tests CHANNEL:stable check 🤔

@gaaclarke
Copy link
Member

@Goddchen I'm not sure, I thought I saw that before in the past but I can't remember where or why. FWIW in my recent PR I switched the dartanalyzer call to dart analyze. That might fix your issue if you rebase.

@google-cla
Copy link

google-cla bot commented Mar 10, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@Goddchen
Copy link
Contributor Author

Dang, I think it just messed up 🙈 I pulled the master changes instead of rebasing. Can you hint me on how to fix this mess? Sorry 😞

@gaaclarke
Copy link
Member

git reset --hard <hash before your merge, d61a774?>
git rebase -i <upstream remote>/master
git push -f <remote for your changes>

@Goddchen Goddchen force-pushed the pigeon-null-safety branch from 3da75ed to d61a774 Compare March 10, 2021 19:47
@Goddchen
Copy link
Contributor Author

git reset --hard <hash before your merge, d61a774?>
git rebase -i <upstream remote>/master
git push -f <remote for your changes>

I guess it worked 🥳 And I guess from your prompt reply that you see this too often 😉 Thanks

@Goddchen Goddchen marked this pull request as ready for review March 10, 2021 21:17
@Goddchen
Copy link
Contributor Author

@gaaclarke We're up-to-date and running again 👍

@mitchross
Copy link

@jmagman could we get this merged?

@gaaclarke
Copy link
Member

gaaclarke commented Mar 15, 2021

@mitchross In order to get it merged Goddchen has to request a code review from someone on the Flutter team (it'd likely be deferred to me). Then they need to go through the review process. I just happened to glance at the code the other day and didn't actually review it. I'm waiting for @Goddchen to be ready.

@Goddchen Goddchen requested a review from gaaclarke March 15, 2021 17:33
@Goddchen
Copy link
Contributor Author

I didn't know that I had to do anything. I used the "re-request review" button at the top now, was that correct? 🤔

@gaaclarke
Copy link
Member

Yep, thanks @Goddchen. This is a big review, I'll try to get to it soon. I'm balancing a few different priorities. If a couple weeks pass you won't be bothering me if you ping me.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Goddchen, looks like you accidentally added some changes for files outside of pigeon.

@Goddchen
Copy link
Contributor Author

I'll try to refrain from landing more changes to pigeon while we wait for this to land. What is your schedule like for addressing the feedback? If you don't have a lot of time, I could just push some changes to this PR if that's fine with you.

Nice review @gaaclarke ! I'll get over the points one by one in the coming days. But feel free to jump in and help if you find the time - I don't mind!

@Goddchen
Copy link
Contributor Author

image

I guess those changed files outside the pigeon folder come from there commits. I have to admit: I have no clue how those commit ended in this PR 🤔 Nor do I have a clue on how to remove those? 🤷‍♂️ I guess it has something to do with properly rebasing or something like that? Do you have an idea @gaaclarke ?

@gaaclarke gaaclarke force-pushed the pigeon-null-safety branch from 44988cd to 726882b Compare March 19, 2021 17:15
@gaaclarke
Copy link
Member

I got rid of the other file edits by squashing your commits and force pushing. There was something weird going on with the PR. When I squash commits I don't expect to get conflicts, but I did. I'll try rebasing it on master next so are ready to merge, the squashing should have made this easier. Watch out, I'll have to force push again after this.

@gaaclarke gaaclarke force-pushed the pigeon-null-safety branch from 726882b to e91bc55 Compare March 19, 2021 17:21
Goddchen and others added 2 commits March 19, 2021 11:02
[pigeon] upgrade version

Fix 2 tests

Properly generate null-safe Dart code

Fix now unused code

JavaOptions.className is mandatory

generate null-safe code during mock_handler_tester

no need to run tests without sound null safety

Fix analyzer issues in generated Dart code

Fix more analyzer issues

Try to fix format of generated Dart code

Try to fix more format issues

Adjust test to new generated code format

Fix formatting

Create null-safe pigeons during local tests

Create null-safe pigeons during local tests

Use ! instead of ??

Make PigeonOptions.input required
@gaaclarke gaaclarke force-pushed the pigeon-null-safety branch from c0047b3 to fb33ad7 Compare March 19, 2021 18:02
@gaaclarke
Copy link
Member

(I had to rebase one last time to to resolve conflicts from a PR that just landed, hopefully that is the last time.)

@gaaclarke
Copy link
Member

Ok, getting closer. I'm going to grab lunch. I think there is a bit of documentation that has to happen before I publish this as well. I'll just write that up in a different PR once this lands. I think I can get it in by EOD.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for the contribution! I'll clean up the rest of the documentation and stuff in another PR before I publish it.

One thing that would have been helpful if if you tried to keep the migration to null safety and your changes to the output as separate PRs. It was a bit of work to detangle them.

Take care dude!

@gaaclarke gaaclarke merged commit 6a92ec5 into flutter:master Mar 19, 2021
austinstoker pushed a commit to austinstoker/packages that referenced this pull request Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants