Bug 30998 - Forms.Init takes FileActivatedEventArgs class instead of IFileActivatedEventArgs interface
Summary: Forms.Init takes FileActivatedEventArgs class instead of IFileActivatedEventA...
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.4.2
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-06-10 17:04 UTC by Adam Kemp
Modified: 2016-04-09 23:43 UTC (History)
4 users (show)

Tags: AC
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Adam Kemp 2015-06-10 17:04:57 UTC
In Windows Store Apps there are different ways that an app could be launched, which are exposed as different overrides on the Application class. OnActivated is the general purpose one, but you can also override OnFileActivated and others. Each one has a different variant of the event args. All of those are sealed classes with no constructors, and they all implement the IActivatedEventArgs interface. That interface has all the information that Forms.Init needs, but since Forms.Init takes the class type instead of the interface type it is impossible to call it from one of the more specific launch overrides. That blocks some use cases.

According to this book (https://books.google.com/books?id=6zoFCAAAQBAJ&pg=PA172&lpg=PA172&dq=windows.ui.xaml.application+life+cycle+onactivated+vs+onfileactivated&source=bl&ots=iPeP3APHZZ&sig=S7-TKf4hEwbaeNjM2oDybXihRlQ&hl=en&sa=X&ved=0CDoQ6AEwBGoVChMIldHshYKGxgIVixKsCh1IogB1#v=onepage&q=onactivated&f=false), for OnFileActivated and some other special cases _only_ the specific override is called (not OnActivated), which means it is impossible to properly initialize Forms in that case.

The Forms.Init method should take the interface type so that you can call it from any of the other overrides. This would be a very simple change (just adding a new overload and calling the new method from the old method).
Comment 1 Jason Smith [MSFT] 2016-04-09 23:43:13 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team