microsoft / microsoft/WindowsAppSDK
WASDK LaunchActivatedEventArgs cannot be directly converted into WinRT LaunchActivatedEventArgs
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
```WASDK LaunchActivatedEventArgs``` cannot be directly converted into ```WinRT LaunchActivatedEventArgs```
##### ---------------------------
```WASDK LaunchActivatedEventArgs``` 不能直接转换成 ```WinRT LaunchActivatedEventArgs```
---------------------------
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with WASDK's AppInstance.GetActivatedEventArgs and the WinRT LaunchActivatedEventArgs projection, then trace how AppActivationArguments.Data is surfaced to .NET. Compare the returned ABI object with the LaunchActivatedEventArgs.FromAbi(inspectable.ThisPtr) workaround. Done means .NET CsWinRT recognizes the launch data as WinRT LaunchActivatedEventArgs without manual ABI conversion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- api, desktop
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100