-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Setter showing a Build Error when using XAML OnPlatform Markup Extension #12064
Comments
Don't understand this. This is now flagged as Closed - Duplicate. Does this mean the reported issue is closed? Without a reply or solution? Not sure what the added area/Xaml </> and area/tooling means. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
This issue still exists. If you use |
Could you provide a sample project to repro this issue? Also other more info? Thanks. |
I have created a small sample project available at https://github.com/GDT48/SetterError |
@GDT48 looks like the repo is private. |
Thanks, my apologies. I have now made public. |
The test project targets iOS (and thus builds for it, even on Windows), but OnPlatform just specifies values for Android and WinUI, not iOS. Adding iOS to OnPlatform, or adding a Default value, looks to make it work. |
Hi Bret,
Thanks for getting back to me.
I tried adding iOS=#FFfafafe, but still get the error – note get only one error message rather than 2.
I tried adding default, this builds without issue. Does not need iOS.
For completeness I also tried Value="{OnIdiom Tablet=#FFfafafe, Desktop=#FFfdfdfe}". This, without default, builds without issue which makes sense because you don’t build for a specific Idiom.
This suggests, for OnPlatform, you always need Default. Maybe if you referenced all possible properties you may not need Default – I tried MacCatalyst, which also gave an error without default – but I did not try all options.
Suggest also looking at the documentation to better explain the need for a default with OnPlatform.
Regards,
Glenn
From: Bret Johnson ***@***.***>
Sent: 24 August 2023 21:19
To: dotnet/maui ***@***.***>
Cc: GDT48 ***@***.***>; Mention ***@***.***>
Subject: Re: [dotnet/maui] Setter showing a Build Error when using XAML OnPlatform Markup Extension (Issue #12064)
This works if there's a Default value present in OnPlatform, so that's a workaround. I believe we just need to update the error message to be more specific on what's missing.
—
Reply to this email directly, view it on GitHub <#12064 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AOOXYQDUAWSBSZFRGGXBUX3XW6ZJXANCNFSM6AAAAAAS5ZC2CU> .
You are receiving this because you were mentioned. <https://github.com/notifications/beacon/AOOXYQBYFD5FMFSUDLJ7YP3XW6ZJXA5CNFSM6AAAAAAS5ZC2CWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTE345KY.gif> Message ID: ***@***.*** ***@***.***> >
|
Update: I looked more at OnPlatform functionality in Xamarin.Forms and confirmed that when the platform doesn't match, there should just be no property set, not an error. So while setting a default is a workaround, we really should fix this. Looking at that now. |
When OnPlatforfm is used for a Setter value, and there's no match for the current platform, fix so that the property isn't set (same behavior as Xamarin.Forms). Previously, XamlC would report a "Missing Value For Setter" error when this happens and non-compiled XAML would crash with an NRE. This PR contains fixes for both, ensuring the XAML compiler doesn't show an error, then ensuring it doesn't crash at runtime. Fixes #12064
Another update: With this issue, when XAML is compiled it results in the "Missing Value For Setter" XamlC error, but when XAML compilation is turned off, the result is a runtime NullReferenceException crash. So that's all the more reason to fix it, which my PR here #17061 does. |
Try removing the ResourceDictionary tags in App.XML and see if that fixes your issue. I have a similar issue were debug mode runs just fine but in release build I get missing key errors and removing the ResourceDictionary tags solved my issue. |
* Fix OnPlatform + Setter when no match for current platform When OnPlatforfm is used for a Setter value, and there's no match for the current platform, fix so that the property isn't set (same behavior as Xamarin.Forms). Previously, XamlC would report a "Missing Value For Setter" error when this happens and non-compiled XAML would crash with an NRE. This PR contains fixes for both, ensuring the XAML compiler doesn't show an error, then ensuring it doesn't crash at runtime. Fixes #12064 * Swtich to device tests for OnPlatform * Remove test screenshot, no longer used
This issue has been moved from a ticket on Developer Community.
[severity:I'm unable to use this version]
If I try to use an On Platform XAML Markup Extension and Build the project I get an error, "Missing Value For Setter". This does not stop the project running in debug mode, where the error disappears from the list.
However this does stop Publishing because the project will not Build (Failed to create App archive 'ProjectPlannerMAUI'. Please ensure your project builds before archiving it.).
The following shows a snippet where the first Setter is OK but the second Setter gives an error:
Error Position 43:18. Missing Value for Setter ProjectPlannerMAUI C:\VSProjects\ProjectPlannerMAUI\ProjectPlannerMAUI\App.xaml 43
Original Comments
Feedback Bot on 11/30/2022, 06:35 PM:
(private comment, text removed)
Glenn Taylor on 12/2/2022, 06:23 AM:
(private comment, text removed)
Original Solutions
(no solutions)
The text was updated successfully, but these errors were encountered: