-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Obsolete setting mainpage via application #23692
Conversation
get | ||
{ | ||
if (Windows.Count == 0) | ||
return _singleWindowMainPage; | ||
|
||
return Windows[0].Page; | ||
} | ||
[Obsolete("This property is deprecated. Initialize your application by overriding Application.CreateWindow rather than setting MainPage. To modify the root page in an active application, use Windows[0].Page for applications with a single window. For applications with multiple windows, use Application.Windows to identify and update the root page on the correct window. Additionally, each element features a Window property, accessible when it's part of the current window.")] |
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.
Thinking out loud - this will cause a warning (or possibly error) in 100% of MAUI applications ever written, no? Is it that bad to keep this? Maybe an analyzer could be used to flag it and rewrite the code for those interested? (And ignored by those who don't.)
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.
Yea, I just worry about also dragging the past along with us and not overall widening the pit of success
From a library author perspective using these APIs is really bad. For example, none of this code from our toolkit will work for multi-window https://github.com/CommunityToolkit/Maui/blob/cc1fb686815587076bbad45a1903f3ec3039315d/src/CommunityToolkit.Maui/PopupService.cs#L17
We probably see an issue a month for android where users need to override CreateWindow
I also worry about new users using MainPage
and ignoring the analyzer suggestions.
The fix here is basically to do a solution search for
MainPage and replace it with Windows[0].Page
I get it because how widespread it is that users will all see warnings, but, it just seems to put MAUI in general on a path to longer term refinement/success.
I could see us maybe Obsoleting the set and just using an analyzer on the get
perhaps?
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.
Existing non-trivial apps already have various workarounds. There are still various gotchas in APIs. It's been getting better but it's not like there are no sharp edges.
Given that MAUI is relatively young, personally, I would be more radical, especially if it can lead to people not hitting bugs in the future (which translates to not losing more resources).
Analyzer might be nice in the sense: fix it for me fast.
Description of Change
maui/src/Core/src/Platform/iOS/UIApplicationExtensions.cs
Line 77 in fe224da
Issues Fixed
Fixes #23518