microsoft / microsoft/microsoft-ui-xaml
In C++ `FindName` wont reload an object that has been `UnloadObject`ed
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
This doesn't happen in C#
This also happens if we replace the call to `UnloadObject` with `myStackPanel.Children().ReplaceAll({});`. This is similar to https://github.com/microsoft/microsoft-ui-xaml/issues/10176
### Steps to reproduce the bug
```xaml
Click Me
```
```cpp
void MainWindow::myButton_Click(IInspectable const&, RoutedEventArgs const&)
{
UnloadObject(myButton());
winrt::check_bool(!myButton());
auto r = myStackPanel().FindName(L"myButton");
winrt::check_bool(!r); // wrong
winrt::check_bool(!myButton()); // wrong
}
```
```c#
private void myButton_Click(object sender, RoutedEventArgs e)
{
UnloadObject(myButton);
Debug.Assert(myButton == null);
var r = myStackPanel.FindName("myButton");
Debug.Assert(r != null); // good
Debug.Assert(myButton != null); // good
}
```
### NuGet package version
WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003
### Windows version
Windows 11 (21H2): Build 22000
### Additional context
_No response_
Contributor guide
Research direction
Start by reproducing the C++ sample using UnloadObject(myButton()) and myStackPanel().FindName(L"myButton"), then compare it with the C# behavior shown in the issue. Investigate the UnloadObject and FindName paths, including the ReplaceAll variant; done means the C++ lookup and generated myButton reference behave as expected after unloading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100