Skip to content

OwnedCollection crashes for custom collection types #155

@Jerther

Description

@Jerther

When calling OwnedCollection on a custom collection, I get the following error:

GraphDiff requires the collection to be either IEnumerable or T[]

The custom collection is something like:

class FooCollection : List<Foo>

The error seems to from this code:

CollectionGraphNode
private Type GetCollectionElementType()
{
    if (Accessor.PropertyType.IsArray)
    {
        return Accessor.PropertyType.GetElementType();
    }

    if (Accessor.PropertyType.IsGenericType)
    {
        return Accessor.PropertyType.GetGenericArguments()[0];
    }

    throw new InvalidOperationException("GraphDiff requires the collection to be either IEnumerable<T> or T[]");
}

Is there a workaround for this?

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