Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SelectedItems NotSupportedExceptions with Linq/etc. #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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