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
I think this needs to be a XAML test as well so that we can ensure the XamlC and XamlG code is the same.
Maybe this file: https://github.com/dotnet/maui/blob/main/src/Controls/tests/Xaml.UnitTests/OnPlatformTests.cs
What do you mean by a XAML test? You mean a non compiled XAML test in addition to the compiled XAML test that's there currently?
Oops, I linked the wrong file, but there are 2 types of xaml tests - and this is the one that I was actually talking about: https://github.com/dotnet/maui/blob/main/src/Controls/tests/Xaml.UnitTests/OnPlatform.xaml.cs
You may just be able to add to that test... It seems to have a bunch of things you are doing.
You may just be able to add to that test... It seems to have a bunch of things you are doing.
I updated, moving all my tests there, which also covers testing compiled and non-compiled XAML.
This is ready to merge, from my perspective, once @StephaneDelcroix approves (or suggests additional test cases).
@StephaneDelcroix ping on this; can you take a look; thanks