feat: null and numbers for IReference<T> parameters and results - #17
Merged
Merged
Conversation
IReference<T> parameters didn't accept null: null and undefined weren't passed as a null reference, and numbers were passed as the boxed IPropertyValue rather than its IReference<T> interface. APIs that treat a missing value as "leave unchanged", such as ScrollViewer.ChangeView, got 0 instead. null and undefined now pass a null reference. Numbers are boxed with the typed Create* call and queried for the IReference<T> IID, and an existing boxed value (NSWinRT.interop.reference) is passed through the same way. IReference<T> results and property values come back as the number (or struct) they hold, or null. Both the classic and the Node-API engines handle it.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
WinRT parameters and results typed
IReference<T>(nullable values such asIReference<Double>) now take and return plain JS numbers andnull.Problem
nullwasn't passed as a null reference. APIs that read a nullIReference<T>as "leave this unchanged" got 0 instead. For example,ScrollViewer.ChangeView(null, offset, null)set the zoom to its 0.1 minimum instead of only scrolling.IPropertyValue, not as theIReference<T>interface the parameter's type asks for.IReference<T>results came back as wrapped objects, not as the value they hold.Change
nullandundefinedpass a null reference. A number is boxed with the typedCreate*call and queried for the parameter'sIReference<T>IID (generic type arguments substituted). An existing boxed value, such as one fromNSWinRT.interop.reference, is passed the same way. The queried interface is held until the call returns.IReference<T>are read throughget_Valueand returned as the number (or struct) they hold. A null reference returnsnull.Tests
cargo test -p runtime --lib --release:ireference_parameters_and_resultscoversDecimalFormatter.ParseDouble/ParseInt(a number, andnullfor unparsable text) and theContactDateDay/Month/Yearproperties (unset readsnull; set, negative, cleared withnull/undefined, and set fromNSWinRT.interop.reference). It passes.main(therun_on_ui_thread,ui_dispatcherand a few XAML interop tests).cargo check -p runtime --no-default-features --features napi_enginebuilds.