Skip to content

SynchronizedViewList throws on ToList() / when used as IEnumerable #116

@Wortex17

Description

@Wortex17

When creating a ISynchronizedViewList (to have a simple list instead of mapping pairs) to ToList() method throws an exception on .ToList().
This only happens when there's actual items in the list.
This forces us to use the underlying ListView or its Filtered member with a Select() to actually copy or iterate the ViewList.
This makes the ViewList a very unreliable IEnumerable, prompting our team to actually never use it.

var sourceList = new ObservableList<int>();
var listView = sourceList.CreateView(x => x);

//Fill the list
sourceList.Add(42);

//This works
var listViewContents = listView.ToList();
var listViewContentsViaFiltered = listView.Filtered.Select(tuple => tuple.View).ToList();
//This throws
var listViewContentsViaViewList = listView.ToViewList().ToList();

Also see fiddle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions