Cloneable icon indicating copy to clipboard operation
Cloneable copied to clipboard

Doesn't support inheritance

Open wihrl opened this issue 4 years ago • 2 comments

Would be nice if this could handle something like:

[Clonable]
class A {
    string Name { get; set; }
}

class B : A {
 ...
}

class C : A {
 ...
}

var c = new C();
c.Clone();

wihrl avatar Feb 04 '21 10:02 wihrl

I'd been thinking about it, but I've been busy at university. If you could implement a PR would be welcome. It does require some more thought because when you clone the child object what should happen to properties and fields of the child if it does not have Cloneable attribute?

mostmand avatar Feb 04 '21 18:02 mostmand

The other challenge is that when you call clone method what type should be returned? The base class or the child class? Because the child class inherits the clone method of its parent.

mostmand avatar Feb 04 '21 19:02 mostmand