Cloneable icon indicating copy to clipboard operation
Cloneable copied to clipboard

Support constructors?

Open MihailsKuzmins opened this issue 4 years ago • 2 comments

I have this model

class Foo
{
    public Foo(int prop)
    {
        Prop = prop;
    }

    public int Prop {get;}
    public string Str {get;set;}
}

the generated method calls a default constructor which does not exist

P.S. If it is OK, I could try to prepare a PR for this issue. This issue does not sound impossible

MihailsKuzmins avatar Oct 08 '21 14:10 MihailsKuzmins

Yeah a PR would be more than welcome. I think it's not impossible, but a bit more difficult to implement than current features. Although, what if the logic in the constructor was more than just setting a property and required some calculation on the input argument?

mostmand avatar Oct 11 '21 08:10 mostmand

@mostmand I think we need to check names of the constructor parameters. If all parameters match property names everything is fine. If not, copying cannot be implemented (or a method Copy will accept unresolved parameters) Does something like this sound good?

MihailsKuzmins avatar Oct 11 '21 18:10 MihailsKuzmins