Skip to content
Oliver Ehrenmüller edited this page Apr 12, 2019 · 27 revisions

Features

  • Mark a class with AddDeepCopyConstructor-Attribute to create a deep copy constructor.
  • Mark a static method with DeepCopyExtension-Attribute to create a nullable deep copy method that supports inheritance.
  • Mark an existing copy constructor with InjectDeepCopy to insert deep copy instructions before your code. [Details](Custom copy constructor)
  • Mark a property with IgnoreDuringDeepCopy to skip this property.
  • Mark a property with DeepCopyByReference to copy by reference.
  • List<> and Dictionary<,> are supported and described here

Start with DeepCopyExtension

To create a compileable method to be used, you can simple return the parameter:

[DeepCopyExtension]
public static MyType DeepCopy(this MyType myType) => myType;

or throw an exception

[DeepCopyExtension]
public static MyType DeepCopy(this MyType myType) => throw new NotImplementedException();

Not supported

  • Fields
  • References without copy constructor
  • Properties of type System.Object

Clone this wiki locally