-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetChildrenInTabFocusOrder no longer a member of the generated code #1395
Comments
It's an overridable method on UIElement, which means it is protected. So yeah, the proper way would be to inherit from StackPanel to use it, like one would in C#. Alternatively as a workaround, using |
I really appreciate the feedback. auto autoItems = stackPanelItems.as().GetChildrenInTabFocusOrder(); using winrt c++/windowsappsdk/Xaml, I'm really not sure how to implement the other suggestion of "inherited StackPanel in a similar fashion to the C#".....if anyone had a code sample doing similar, it would be very appreciated, since there are so few decent winrt c++/windowsappsdk/Xaml examples on the web. again many thanks for the feedback. |
So I stumbled across this issue just recently. However I also discovered another issue which I think is related, and even if it is, it might be outside the scope of cppwinrt to fix(if it should be fixed at all). Attempting to call an overridable function from a derived class in Xaml Say you have an IDL like this:
And in your MainWindow xaml you call on MyFancyFunction, something like this:
In 2.0.230706.1 this will compile and work fine. In 2.0.240111.5 it will lead to a compile-error where it could not find the MyFancyFunction as a member of B. Now there's a chance that there are good reasons why this should not be allowed to begin with. I am not very well versed in MIDL 3.0 or C++/Winrt, but I am wondering if this intended. For me it does seem a little counter-intuitive that this should not work. |
This is indeed intended. To quote the WinRT type system:
|
Seems fine to me - FWIW |
First, I'll note that you don't need It's common practice (I'd even say "standard practice") to separate interface from implementation by making the interface public and the implementation non-public. When dealing with virtual functions, it's a common idiom (but not universal) to treat the public interface as stable and non-virtual, and to treat the customizeable/virtual behavior as implementation by making it non-public. This pattern can be especially useful when the overridable bit needs to be surrounded by pre- and post- action. A familiar example of this is XAML's Coming back to your example, you need to decide if you truly need interface IFancyFunction
{
void FancyFunction();
}
[default_interface]
runtimeclass A : IFancyFunction
{
A();
}
[default_interface]
runtimeclass B : IFancyFunction
{
B();
} Finally, if you truly need unsealed runtimeclass A
{
A();
void FancyFunction();
overridable void FancyFunctionOverride();
}
[default_interface]
runtimeclass B : A
{
B();
} (Fun trivia, C++ virtual function behavior can sometimes get non-intuitive in the face of hiding and overloading - https://isocpp.org/wiki/faq/strange-inheritance#protected-virtuals) |
Thanks for the insight @DefaultRyan. |
Version
2.0.240111.5
Summary
after upgrading from 2.0.230706.1 to 2.0.240111.5 , GetChildrenInTabFocusOrder() is no longer a member of the generated code, so the winappsdk/winrt c++ app no longer compiles the exe.
WinUI.zip
Reproducible example
Expected behavior
to still compile existing code under the new release
Actual behavior
GetChildrenInTabFocusOrder is not generated as a member of the class.
Additional comments
app is built successfully with the following:-
app fails to build by upgrading
Microsoft.Windows.CppWinRT
The text was updated successfully, but these errors were encountered: