Skip to content
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

Make IAppLinks.RegisterLink etc awaitable to allow catching exceptions #852

Closed

Conversation

dominik-weber
Copy link

Description of Change

With the current implementation the app crashes when the thumbnail url can't be loaded on iOS. This change makes the RegisterLink etc. methods awaitable (return Task) so the dev can catch exceptions and avoid unhandled exception crashes.

Bugs Fixed

API Changes

Changed:

  • void IAppLinks.RegisterLink => Task IAppLinks.RegisterLink
  • void IAppLinks.DeregisterLink => Task IAppLinks.DeregisterLink

Behavioral Changes

None

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

@dnfclas
Copy link

dnfclas commented Apr 1, 2017

@dominik-weber,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla2.dotnetfoundation.org.

It will cover your contributions to all .NET Foundation-managed open source projects.
Thanks,
.NET Foundation Pull Request Bot

@dnfclas
Copy link

dnfclas commented Apr 1, 2017

@dominik-weber, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, .NET Foundation Pull Request Bot

{
RemoveFromIndexItemAsync(appLink.AppLinkUri.ToString());
return Task.FromResult<object>(null);
Copy link

Choose a reason for hiding this comment

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

null ?

Copy link
Author

Choose a reason for hiding this comment

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

It doesn't matter what result we use, we just need a completed Task to convert this synchronous method to an async one. The object is actually converted from Task<whatever> to Task so the result of the task is ignored anyway.
The same task/result is used here: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Core/NavigationProxy.cs#L201

Copy link
Author

Choose a reason for hiding this comment

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

If there is an existing guideline or practice how this should be handled in the Forms repo please let me know and I'll change it.

@samhouts samhouts requested a review from rmarinho April 3, 2017 16:14
@rmarinho
Copy link
Member

rmarinho commented Apr 4, 2017

Hum, this is a breaking change.. .. not sure we can accept this.

@dominik-weber
Copy link
Author

@rmarinho I can't see where this should break any apps - especially since the currrent implementation just crashes when the image can't be loaded. Could you please explain?

@rmarinho
Copy link
Member

rmarinho commented Apr 4, 2017

@dominik-weber if anyone is implementing the IAppLinks interface they will have to change the code.

Can we try fix the image loading only ?

@rmarinho
Copy link
Member

rmarinho commented May 4, 2017

Closing for now. I will revise this and try to fix the loading image issue

@rmarinho rmarinho closed this May 4, 2017
@rmarinho rmarinho reopened this Jun 21, 2017
@dnfclas
Copy link

dnfclas commented Jun 21, 2017

@dominik-weber,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

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.

None yet

4 participants