Skip to content

feat: null and numbers for IReference<T> parameters and results - #17

Merged
triniwiz merged 1 commit into
mainfrom
feat/nullable-references
Sep 29, 2026
Merged

triniwiz merged 1 commit into
mainfrom
feat/nullable-references

Conversation

@triniwiz

Copy link
Copy Markdown
Member

WinRT parameters and results typed IReference<T> (nullable values such as IReference<Double>) now take and return plain JS numbers and null.

Problem

  • null wasn't passed as a null reference. APIs that read a null IReference<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.
  • Numbers were passed as the boxed IPropertyValue, not as the IReference<T> interface the parameter's type asks for.
  • IReference<T> results came back as wrapped objects, not as the value they hold.

Change

  • Parameters: null and undefined pass a null reference. A number is boxed with the typed Create* call and queried for the parameter's IReference<T> IID (generic type arguments substituted). An existing boxed value, such as one from NSWinRT.interop.reference, is passed the same way. The queried interface is held until the call returns.
  • Results: method results and property getters typed IReference<T> are read through get_Value and returned as the number (or struct) they hold. A null reference returns null.
  • Engines: both the classic engine and the Node-API engine use it.

Tests

cargo test -p runtime --lib --release:

  • New test: ireference_parameters_and_results covers DecimalFormatter.ParseDouble/ParseInt (a number, and null for unparsable text) and the ContactDate Day/Month/Year properties (unset reads null; set, negative, cleared with null/undefined, and set from NSWinRT.interop.reference). It passes.
  • Whole suite: 148 passed and 11 failed. The same 11 fail on main (the run_on_ui_thread, ui_dispatcher and a few XAML interop tests).

cargo check -p runtime --no-default-features --features napi_engine builds.

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.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b8bec858-4bff-4689-8144-b19dbbf0f42c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@triniwiz
triniwiz merged commit d8f9e23 into main Sep 29, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant