Repository navigation
fix(winrt): unsealed class returns and static method overloads - #55
Merged
Merged
Conversation
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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
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.GetParentdeclaresDependencyObjectand returns aGrid, which came back withoutIsHitTestVisibleor any otherGridmember. An unsealed declared class now resolves the runtime class, as interface returns already did. Both engines:return_value_from_kind(classic) andcreate_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. SoVisualTreeHelper.FindElementsInHostCoordinates(point, element)could reach theRectoverload.Statics are now grouped by name and the overload is picked per call:
[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.GetParentof a hosted view returns aMicrosoft.UI.Xaml.Controls.Grid.FindElementsInHostCoordinates(Point, UIElement)andFindElementsInHostCoordinates(Rect, UIElement)return the same element counts asFindElementsInHostCoordinatesPointandFindElementsInHostCoordinatesRectcalled by name.FindElementsInHostCoordinates(Point, UIElement).cargo build -p nativescript --release(classic) andcargo check -p runtime --no-default-features --features napi_engineforx86_64-pc-windows-msvc.Tested together with #54, which the canvas addons need to load.