OnDetachedFromLogicalTreeCore enumerates children of the current control, but doesn't account for the collection of children changing during enumeration.
To Reproduce
Start Control Gallery
Switch to the TabControl tab
Enable "Set TabItem.ContentTemplate"
Close Control Gallery
System.ArgumentOutOfRangeException
HResult=0x80131502
Message=Index was out of range. Must be non-negative and less than the size of the collection. Arg_ParamName_Name
Source=System.Private.CoreLib
StackTrace:
at System.ThrowHelper.ThrowArgumentOutOfRange_IndexException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Avalonia.Collections.AvaloniaList`1.get_Item(Int32 index) in Avalonia\src\Avalonia.Base\Collections\AvaloniaList.cs:line 148
at Avalonia.StyledElement.OnDetachedFromLogicalTreeCore(LogicalTreeAttachmentEventArgs e) in Avalonia\src\Avalonia.Base\StyledElement.cs:line 932
at Avalonia.StyledElement.OnDetachedFromLogicalTreeCore(LogicalTreeAttachmentEventArgs e) in Avalonia\src\Avalonia.Base\StyledElement.cs:line 934
...
Expected behavior
OnDetachedFromLogicalTreeCore should account for the possibility of its children changing during enumeration.
OnDetachedFromLogicalTreeCore
enumerates children of the current control, but doesn't account for the collection of children changing during enumeration.To Reproduce
Expected behavior
OnDetachedFromLogicalTreeCore
should account for the possibility of its children changing during enumeration.Environment