Skip to content

Fix SelectedItems NotSupportedExceptions with Linq/etc.#234

Open
trigger-segfault wants to merge 1 commit intooozcitak:masterfrom
trigger-segfault:fix-unsupported-ilist
Open

Fix SelectedItems NotSupportedExceptions with Linq/etc.#234
trigger-segfault wants to merge 1 commit intooozcitak:masterfrom
trigger-segfault:fix-unsupported-ilist

Conversation

@trigger-segfault
Copy link
Contributor

This implements previously-NotSupported IList accessors in order to fix issues where methods accepting an IEnumerable will try to optimize if a more useful interface like IList exists. For example, Linq's FirstOrDefault will fail because it can't use the IList.this[int index] accessor. And passing SelectedItems to a List constructor will fail because IList.CopyTo is not supported.

Interface methods implemented:

  • IList<T>.CopyTo
  • IList<T>.IndexOf
  • IList<T>.this[] (getter)

The obsolete notice on IList.IndexOf has been removed, since ImageListViewItem.Index does not return the same value as the index in the selected items collection.

This implements previously-NotSupported IList accessors in order to fix issues where methods accepting an IEnumerable will try to optimize if a more useful interface like IList exists. For example, Linq's FirstOrDefault will fail because it can't use the IList.this[int index] accessor. And passing SelectedItems to a List constructor will fail because IList.CopyTo is not supported.

The obsolete notice on IList.IndexOf has been removed, since ImageListViewItem.Index does not return the same value as the index in the selected items collection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant