-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Description
PriorityBinding.InitializeClone has the same off-by-one bug that was fixed for MultiBinding in #3220 / #3221.
The fix for MultiBinding changed i<=_bindingCollection.Count to i<_bindingCollection.Count, but the identical bug in PriorityBinding was not addressed.
Reproduction Steps
var priorityBinding = new PriorityBinding();
priorityBinding.Bindings.Add(new Binding("Path1"));
priorityBinding.Bindings.Add(new Binding("Path2"));
var cloneMethod = typeof(BindingBase).GetMethod("Clone", BindingFlags.Instance | BindingFlags.NonPublic);
var clone = cloneMethod.Invoke(priorityBinding, new object[] { BindingMode.Default }); // throws ArgumentOutOfRangeExceptionExpected behavior
PriorityBinding should be cloned without exception
Actual behavior
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at System.Collections.Generic.List`1.get_Item(Int32 index)
at System.Windows.Data.PriorityBinding.InitializeClone(BindingBase baseClone, BindingMode mode)
at System.Windows.Data.BindingBase.Clone(BindingMode mode)
Regression?
No. This bug has existed since the code was written. The same bug in MultiBinding was fixed in #3221, but PriorityBinding was not included in that fix
Known Workarounds
Clone PriorityBinding manually by creating a new instance and copying properties/bindings
Impact
No response
Configuration
- .NET 10.0 (also reproduces on .NET Framework 4.8)
- Windows 11
- x64
- Not specific to configuration
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels