Skip to content

Uable to map IEnumerable<T> #11

@TonySkorik

Description

@TonySkorik

Describe the bug
When mapping a complex type and the target property type is not an array, mapping fails without a message.

To Reproduce
Steps to reproduce the behavior:
Source type:

public class V1CreateManySyncTasksRequest
{
    public SyncTask[] Tasks { set; get; }

    public class SyncTask
    {
        public int Priority { get; set; }
    }
}

Target type:

public class CreateManyTasksModel
{
    public IEnumerable<CreateTaskModel> Tasks { set; get; }

    public class CreateTaskModel
    {
        public int Priority { get; set; }
    }
}

Generated result:

public CreateManyTasksModel Map(V1CreateManySyncTasksRequest request)
{
    return new CreateManyTasksModel()
        { };
}

Expected behavior
Expected the generated code to be:

return new CreateManyTasksModel()
{
    Tasks = request.Tasks.Select(
            tmpTasks => new CreateManyTasksModel.CreateTaskModel()
            {
                Priority = tmpTasks.Priority,
                BuyerId = tmpTasks.BuyerId,
                OrderIds = tmpTasks.OrderIds,
            })
        .ToList(),
};

Desktop (please complete the following information):

  • OS: OSx
  • Rider version and build number :
JetBrains Rider 2021.2.2
Build #RD-212.5284.64, built on October 9, 2021
Runtime version: 11.0.12+7-b1504.28 x86_64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
macOS 12.0.1
.NET 5.0.7
GC: G1 Young Generation, G1 Old Generation
Memory: 1500M
Cores: 12

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions