Fix: OnIdiom Default Value Handling for ValueType Properties - #28257
Fix: OnIdiom Default Value Handling for ValueType Properties#28257bhavanesh2001 wants to merge 4 commits into
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/rebase |
a6b928b to
4c196fa
Compare
|
I wonder if OnIdiom without a default value shouldn't just crash, or at least warn... |
|
|
||
| [Issue(IssueTracker.Github, 9978, "VisualElement.HeightRequest defaults to 0 instead of -1 when using OnIdiom default value", | ||
| PlatformAffected.All)] | ||
| public partial class Issue9978 : ContentPage |
There was a problem hiding this comment.
I'd need this test in Xaml.UnitTest so we test for all xaml inflators
I don't think it's crashing. But it assigns 0 instead of -1, (for example |
y, it's not crashing. but I wonder if it shouldn't instead of behaving in an unexpected way |
This suggests that defining one platform without a default is allowed — same behavior as OnPlatform. But yeah, I agree with you — probably shouldn’t behave this way. maui/src/Controls/src/Xaml/MarkupExtensions/OnIdiomExtension.cs Lines 34 to 41 in 4f0b3a4 |
|
/rebase |
4c196fa to
94fa331
Compare
|
@StephaneDelcroix I added a unit test. Please take a look. I kept the UItest, let me know if you want it removed. |
| } | ||
|
|
||
| [Test] | ||
| public void OnIdiomReturnsBindablePropertyDefaultWhenNotSet() |
There was a problem hiding this comment.
look at what other tests are doing, in the Issues folder. it needs a xaml and a xaml.cs file. this doesn't test XamlC inflation
There was a problem hiding this comment.
Yeah, sorry about that — I hadn’t opened Xaml.UnitTests until a few hours ago. :)
kubaflo
left a comment
There was a problem hiding this comment.
Could you please apply ai's suggestions?
|
/review -b feature/refactor-copilot-yml |
|
/review -b feature/refactor-copilot-yml |
|
/review -b feature/enhanced-reviewer -p ios |
|
|
kubaflo
left a comment
There was a problem hiding this comment.
Can you please resolve conflicts?
|
Thanks for this contribution, @bhavanesh2001! 🙏 Unfortunately this fix is no longer needed — the same root cause was already resolved on Both issues share the identical root cause: You can confirm on Because the source fix is already in place, I'd suggest closing this PR. The one piece not covered on Thanks again for digging into this! 🚀 |
Description of Change
This PR fixes an issue, where
OnIdiomwithout a default value incorrectly assigns 0 instead of the expected default.Root Cause
Activator.CreateInstance(propertyType)when value is null.Activator.CreateInstance()returns 0.0 , instead of the expected default value (-1) fromBindableProperty.GetDefaultValue().Issues Fixed
Fixes #9978