C#

C#

Made by DeepSource

ICloneable does not define a spec for Clone() and hence should not be implemented CS-R1104

Anti-pattern
Critical

ICloneable allows you to define methods that help in cloning the instances of your class. However, the specification does not define whether this clone operation is a shallow clone or a deep clone. If it is a deep clone, it may end up recursively referencing other objects in the object graph. Moreover, if a class implements ICloneable, there may be a need for all its subtypes to implement it too. It is therefore recommended that you define your own method that aids in cloning.

Bad Practice

class C : ICloneable
{
    public object Clone()
    {
        // ...
    }
}

Recommended

class C
{
    // Custom implementation
    public object Clone()
    {
        // ...
    }
}

Reference