microsoft / microsoft/microsoft-ui-xaml
Xaml child collection initialization should use IVector.ReplaceAll instead of Append
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
I am writing a custom collection type that inheirts from `IVector` and `IIterable` to support child collection. (Similar to `Grid.ColumnDefintions` or `LinearGradientBrush.GradientStops`.
But I found during xaml initialization, the elements are added one-by-one with `Append()` instead of `ReplaceAll()` on the `IVector` interface, which is less efficient. Xaml should already know the information of all the child definitions after compiled, so using `ReplaceAll` should be possible and more desirable.
### Why is this important?
The performance impact might not be so obvious on normal conditions but still a win for both semantic clearance and under edge cases where `Append()` might causes extra logic to run.
### Steps to reproduce the bug
1. Create a custom control which accepts children collection
2. Create a custom collection type, inheriting from `IVector` and `IIterable`
3. Add some child in xaml
4. Observe `Append()` is being called for each of the child element.
### Actual behavior
_No response_
### Expected behavior
_No response_
### Screenshots
_No response_
### NuGet package version
2.0.1
### Windows version
Windows 10 (1809): Build 17763
### Additional context
_No response_
Contributor guide
Research direction
Reproduce the custom control and IVector/IIterable collection scenario described in the issue, then trace XAML child-collection initialization to observe whether it calls Append() for each element. Done means initialization uses IVector.ReplaceAll for the compiled child definitions without changing collection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100