-
Notifications
You must be signed in to change notification settings - Fork 414
Description
Describe the bug
WASDK LaunchActivatedEventArgs cannot be directly converted into WinRT LaunchActivatedEventArgs
---------------------------
WASDK LaunchActivatedEventArgs 不能直接转换成 WinRT LaunchActivatedEventArgs
Image
As shown in the diagram, when Wasdk's AppInstance.GetActivatedEventArgs obtains the launch parameters, it first calls WinRT's AppInstance.GetActivatedEventArgs. Only when the WinRT method returns null does it customarily call other custom implementations of WASDK, which include WASDK’s own implementation of LaunchActivatedEventArgs. When this method finally returns, it returns Wasdk’s custom LaunchActivatedEventArgs rather than WinRT’s LaunchActivatedEventArgs. On the .NET side, because CsWinRT cannot recognize WASDK’s custom LaunchActivatedEventArgs, the data in AppActivationArguments.Data is displayed as type WinRT.IInspectable. To get the instance, you need to use LaunchActivatedEventArgs.FromAbi(inspectable.ThisPtr). In the future, could the WASDK team address this issue and possibly add an additional layer of wrapping in the internal implementation so that it pretends to return WinRT’s LaunchActivatedEventArgs, allowing .NET’s CsWinRT to recognize it correctly?
---------------------------
如图所示,Wasdk 的 AppInstance.GetActivatedEventArgs 获取启动参数时,首先会调用 WinRT 的 AppInstance.GetActivatedEventArgs。WinRT 的方法返回为空时,才自定义调用 WASDK 的其他自定义实现,其中包含 WASDK 自己实现的 LaunchActivatedEventArgs。最终该方法返回时,由于返回的是 Wasdk 自定义的 LaunchActivatedEventArgs,而不是 WinRT 的 LaunchActivatedEventArgs。在 .NET 这边,由于 CsWinRT 识别不到 WASDK 自定义的 LaunchActivatedEventArgs,故 AppActivationArguments.Data 中的 data 显示成 WinRT.IInspectable 类型,需要通过 LaunchActivatedEventArgs.FromAbi(inspectable.ThisPtr) 来获取实例。未来 WASDK 团队能否解决一下这个问题,内部实现时返回能否多做一层包装,假装返回 WinRT 的 LaunchActivatedEventArgs,从而让 .NET 的 CsWinRT 正常识别到。
Steps to reproduce the bug
See description
Expected behavior
See description
Screenshots
See description
NuGet package version
Windows App SDK 1.8.5: 1.8.260209005
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 24H2 LTSC (26100, June Update)
IDE
Visual Studio 2022
Additional context
None