Skip to content

fix(winrt): unsealed class returns and static method overloads - #55

Merged
triniwiz merged 1 commit into
mainfrom
fix/winrt-runtime-class-and-static-overloads
Nov 20, 2026
Merged

triniwiz merged 1 commit into
mainfrom
fix/winrt-runtime-class-and-static-overloads

Conversation

@triniwiz

@triniwiz triniwiz commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Two projection fixes in calls to WinRT statics and their return values.

Unsealed class returns

A method whose declared return type is a class others can derive from came back as a wrapper of the declared class. The runtime class was never asked for. VisualTreeHelper.GetParent declares DependencyObject and returns a Grid, which came back without IsHitTestVisible or any other Grid member. An unsealed declared class now resolves the runtime class, as interface returns already did. Both engines: return_value_from_kind (classic) and create_instance_proxy (Node-API).

Static overloads

Statics had no overload selection. The constructor held one function per name, bound to whichever overload came first in metadata, and [Overload] names were not exposed for statics. So VisualTreeHelper.FindElementsInHostCoordinates(point, element) could reach the Rect overload.

Statics are now grouped by name and the overload is picked per call:

  1. by argument count (trailing out parameters may be left off);
  2. then by the struct whose fields an object argument has, preferring the most fields matched;
  3. then [DefaultOverload], then metadata order.

Their [Overload] names (FindElementsInHostCoordinatesPoint, ...Rect) are exposed too, as for instance methods. The Node-API engine's instance and constructor overloads use the same selection (class_helpers::pick_overload).

Verified

On Windows 11, in the NativeScript canvas demo with this build:

  • VisualTreeHelper.GetParent of a hosted view returns a Microsoft.UI.Xaml.Controls.Grid.
  • FindElementsInHostCoordinates(Point, UIElement) and FindElementsInHostCoordinates(Rect, UIElement) return the same element counts as FindElementsInHostCoordinatesPoint and FindElementsInHostCoordinatesRect called by name.
  • The canvas spec suite passes, including the HTML-in-Canvas hit tests, which call FindElementsInHostCoordinates(Point, UIElement).
  • cargo build -p nativescript --release (classic) and cargo check -p runtime --no-default-features --features napi_engine for x86_64-pc-windows-msvc.

Tested together with #54, which the canvas addons need to load.

A method that declares a class others can derive from returned a
wrapper of the declared class, never asking for the runtime class:
VisualTreeHelper.GetParent declares DependencyObject and returns a
Grid, which came back without IsHitTestVisible or any Grid member. An
unsealed declared class now resolves the runtime class, as interface
returns already did, in both engines.

Static methods had no overload selection: the constructor held one
function per name, bound to whichever overload came first in metadata,
and [Overload] names were not exposed for statics.
VisualTreeHelper.FindElementsInHostCoordinates(Point, UIElement) called
the Rect overload. Statics are now grouped by name and picked per call:
by argument count (out parameters may be left off), then by the struct
whose fields an object argument has, then [DefaultOverload]. Their
[Overload] names are exposed too. The Node-API engine's instance and
constructor overloads use the same selection.
@coderabbitai

coderabbitai Bot commented Nov 20, 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 19d6af20-ca96-47e4-93c2-b3d020774f77

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@triniwiz
triniwiz merged commit ae04cc1 into main Nov 20, 2026
3 checks passed
@triniwiz
triniwiz deleted the fix/winrt-runtime-class-and-static-overloads branch November 20, 2026 10:59
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