Repository navigation
fix: struct values for IReference<T> parameters - #25
Merged
Merged
Conversation
IReference<T> parameters of a struct type, such as AppWindowTitleBar's IReference<Windows.UI.Color> colors, couldn't be set. PropertyValue only boxes primitives, so a plain { A, R, G, B } object failed with E_FAIL, and a struct value such as ColorHelper.FromArgb's had its field buffer passed as a COM object and crashed.
A struct is now laid out as for a struct parameter and held by an agile IReference<T> that answers the parameter's IID and copies the bytes out of get_Value. TimeSpan and DateTime still go through PropertyValue, which also takes a number for them. 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 configuration
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.
Lets JS set
IReference<T>parameters whoseTis a struct, such asAppWindowTitleBar'sIReference<Windows.UI.Color>colors.The bug
box_as_ireferenceonly boxed values thatPropertyValuecan create (primitives,TimeSpan,DateTime,Guid):bar.BackgroundColor = { A: 255, R: 32, G: 32, B: 32 }) wasn't boxed, so the setter failed withE_FAIL.bar.BackgroundColor = Windows.UI.ColorHelper.FromArgb(...)) had its field buffer passed as a COM object, and the process crashed.That meant NativeScript core couldn't color a window's title bar to follow the app's light or dark appearance on Windows App SDK 1.6, which has no
PreferredTheme.The fix
When
Tis a struct, the value (a plain object or a struct value) is laid out as for a struct parameter and held by a small agileIReference<T>. That object answers the parameter's IID (computed from its closed generic name) and copies the bytes out ofget_Value.null/undefinedstill pass a null reference.TimeSpanandDateTimestill go throughPropertyValue, which also accepts a number for them. Both the classic and the Node-API engines handle it.Testing
interop_test::ireference_struct_parameterscoversStorageProviderQuotaUI.QuotaUsedColor(IReference<Color>) set from a plain object, fromColorHelper.FromArgb, and cleared withnull, plusShareUIOptions.SelectionRect(IReference<Rect>). It passes, and so does the existingireference_parameters_and_results.cargo check -p runtime --no-default-features --features napi_enginebuilds.