Description
Selected API validate input parameters and throw ArgumentOutOfRangeException.
Selected API now validate input parameters and throw ArgumentOutOfRangeException where previous behaviour could lead to faulty state.
Throwing ArgumentOutOfRangeException is inline with the behaviours in .NET Runtime, and provides developers with a better debug experience clearly communicating which argument caused the exception.
Old behavior
The listed API could throw various exceptions (e.g. NullReferenceException, ArgumentException, ArgumentOutOfRangeException, etc.) if invoked with incorrect input arguments.
New behavior
The listed API would throw ArgumentOutOfRangeException if invoked with invalid input arguments.
Reason for change
Throwing ArgumentOutOfRangeException is inline with the behaviours in .NET Runtime, and provides developers with a better debug experience but clearly communicating which argument resulting in a exception.
Recommended action
- Review and, if necessary, update the code to prevent passing input arguments of incorrect type to the listed API.
- Handle
ArgumentOutOfRangeException, if necessary.
Category
- Windows Forms
Version introduced: .NET 5.0 Preview 5
Affected APIs
- ListBox.IntegerCollection
- ListBox.IntegerCollection.Item[int], parameter
index(used to throw NRE or IORE)
- ListBox.IntegerCollection.Item[int], parameter
Version introduced: .NET 5.0 Preview 6
Affected APIs
- TreeNode
- TreeNode.ImageIndex, parameter
value - TreeNode.SelectedImageIndex, parameter
value
- TreeNode.ImageIndex, parameter
Issue metadata
- Issue type: breaking-change
Activity
RussKie commentedon Jun 4, 2020
Just FYI - this issue is missing WinForms label.
RussKie commentedon Oct 21, 2020
I'll have new ones opened for 6.0 😉
Thank you for your help.