maui icon indicating copy to clipboard operation
maui copied to clipboard

Fix OnPlatform + Setter when no match for current platform

Open BretJohnson opened this issue 2 years ago • 7 comments

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

BretJohnson avatar Aug 29 '23 14:08 BretJohnson

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

mattleibow avatar Sep 05 '23 20:09 mattleibow

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?

BretJohnson avatar Sep 05 '23 21:09 BretJohnson

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

mattleibow avatar Sep 06 '23 13:09 mattleibow

You may just be able to add to that test... It seems to have a bunch of things you are doing.

mattleibow avatar Sep 06 '23 13:09 mattleibow

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.

BretJohnson avatar Oct 02 '23 17:10 BretJohnson

This is ready to merge, from my perspective, once @StephaneDelcroix approves (or suggests additional test cases).

BretJohnson avatar Oct 03 '23 00:10 BretJohnson

@StephaneDelcroix ping on this; can you take a look; thanks

BretJohnson avatar Oct 11 '23 14:10 BretJohnson