Skip to content

IReadOnlySet cannot be mapped to from a HashSet #4359

@Itamaram

Description

@Itamaram

Source/destination types

IReadOnlySet<string> // source
HashSet<string> // destination

Mapping configuration

new MapperConfiguration(_ => { })

Version: x.y.z

12.0.1

Expected behavior

I expect IReadOnlySet<> to be mappable from a HashSet<> (which implements the interface).

Actual behavior

An error is thrown:

Unable to cast object of type 'System.Collections.Generic.List`1[System.String]' to type 'System.Collections.Generic.IReadOnlySet`1[System.String]'.

Steps to reproduce

new Mapper(new MapperConfiguration(_ => { })).Map<IReadOnlySet<string>>(new HashSet<string> { "Foo" });

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions