[XC] better support for nullable props and BPs#28550
Merged
PureWeen merged 1 commit intoinflight/currentfrom Mar 23, 2025
Merged
[XC] better support for nullable props and BPs#28550PureWeen merged 1 commit intoinflight/currentfrom
PureWeen merged 1 commit intoinflight/currentfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request improves support for nullable bindable properties and properties by updating how values are set and unboxed in the IL generation logic. Key changes include:
- Introducing a new local function CanSetValue in SetPropertiesVisitor.cs to encapsulate value setting logic.
- Adjusting the handling of nullable types in the SetValue and CanSetValue routines.
- Updating test cases in Unreported008.xaml.cs and Bz24910.xaml.cs to verify proper handling of nullable types and replacing hard-coded property names with nameof().
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs | Refactors value setting logic with a new local helper and adjusts nullable type handling |
| src/Controls/tests/Xaml.UnitTests/Issues/Unreported008.xaml.cs | Adds a new view to test nullable bindable property behavior |
| src/Controls/tests/Xaml.UnitTests/Issues/Bz24910.xaml.cs | Updates BindableProperty.Create calls to use nameof(), ensuring consistency |
| src/Controls/src/Build.Tasks/VariableDefinitionExtensions.cs | Comments out a branch for unboxing nullable types, likely for future reconsideration |
Files not reviewed (1)
- src/Controls/tests/Xaml.UnitTests/Issues/Unreported008.xaml: Language not supported
Comments suppressed due to low confidence (2)
src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs:1459
- The original code returned the result of an inheritance check for the variable type against bpTypeRef, whereas the new code unconditionally returns false. This change might inadvertently break scenarios where the variable type inherits from bpTypeRef; please verify that the new behavior is intentional.
return false;
src/Controls/src/Build.Tasks/VariableDefinitionExtensions.cs:21
- There is an unused commented code block related to handling System.Nullable`1 types. Consider removing it or adding a clarifying comment if it’s intended to indicate future work to avoid confusion.
// yield return Instruction.Create(OpCodes.Unbox_Any, module.ImportReference(type));
| yield return instruction; | ||
| if (bpTypeRef.IsValueType) | ||
| { | ||
| if ( bpTypeRef.ResolveCached(context.Cache).FullName == "System.Nullable`1" |
Contributor
Author
There was a problem hiding this comment.
this is the main change
792bb9d to
bbd5372
Compare
|
|
||
| static bool CanSetValue(FieldReference bpRef, bool attached, INode node, IXmlLineInfo iXmlLineInfo, ILContext context) | ||
| { | ||
| static bool CanSetValue (TypeReference bpTypeRef, VariableDefinition varValue, ILContext context, IXmlLineInfo iXmlLineInfo) |
Contributor
Author
There was a problem hiding this comment.
extracting the logic in a local method to run it twice, once on the nullable type, once on the inner type
jfversluis
approved these changes
Mar 21, 2025
PureWeen
pushed a commit
that referenced
this pull request
Mar 26, 2025
PureWeen
pushed a commit
that referenced
this pull request
Mar 28, 2025
bhavanesh2001
pushed a commit
to bhavanesh2001/maui
that referenced
this pull request
Apr 11, 2025
PureWeen
pushed a commit
that referenced
this pull request
Apr 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
As requested by @jfversluis: support nullable BPs and props
Issues Fixed
Fixes #28010