microsoft / microsoft/microsoft-ui-xaml
AppWindow does not support IWeakReferenceSource
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
This is mainly for C++WinRT.
### Why is this important?
This will make getting a weak_ref of AppWindow crash
```cpp
auto ref = winrt::make_weak(AppWindow());
```
As a result, using `winrt::auto_revoke` on any `AppWindow` events will crash tpp
```cpp
auto revoker = appWindow.Changed(winrt::auto_revoke, [](auto&&... args){ });
```
Meanwhile this usage is [clearly documented](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.windowing.appwindow.changed?view=windows-app-sdk-1.8#microsoft-ui-windowing-appwindow-changed)
### Steps to reproduce the bug
As above
### Actual behavior
Crash
### Expected behavior
Works
### Screenshots
_No response_
### NuGet package version
WinUI 3 - Windows App SDK 1.8.2: 1.8.251003001
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
_No response_
Contributor guide
Research direction
Start with the AppWindow implementation and reproduce the failure using winrt::make_weak(AppWindow()) and the winrt::auto_revoke event example from the issue. Done means both weak-reference creation and AppWindow event revocation work without crashing for C++/WinRT users.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100