Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.

Feature request: mapping for get only lists #112

@jorisdebock

Description

@jorisdebock

Could we add a mapping option for get only lists?

It is useful for when an object is doing the list initialization themself and only exposing a getter for the list.
In my case, I am using protobuf/grpc which generates types with only a getter for the list. And filling the list should be done with Add/Addrange, it would be nice if the mapping for this can be generated.

e.g. the following objects

    public class Hello
    {
        public string Message { get; set; }
        public List<string> Names { get; set; }
    }
    public class Hello3
    {
        public string Message { get; set; }
        public List<string> Names { get; } = new List<string>();
    }

   [MappingInterface]
    public interface IGreeterServiceMapper
    {
        Hello3 MapHello3(Hello hello);
    }

current generated result

        public virtual Hello3 MapHello3(Hello hello)
        {
            return new GrpcService1.Hello3()
            {
                Message = hello.Message
            };
        }

would like to have the following code generated

        public virtual Hello3 MapHello3(Hello hello)
        {
            var hello3 = new GrpcService1.Hello3()
            {
                Message = hello.Message
            };
            hello3.Names.AddRange(hello.Names);
            return hello3;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions