-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Oliver Ehrenmüller edited this page Apr 13, 2019
·
27 revisions
- 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
InjectDeepCopyto insert deep copy instructions before your code. Details - Mark a property with
IgnoreDuringDeepCopyto skip this property. - Mark a property with
DeepCopyByReferenceto copy by reference. - Collections of types
IList<>,ISet<>andIDictionary<,>are supported and described here
To create a compileable method you can call simply 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();public static MyType DeepCopy(this MyType myType) {
return myType != null ? new MyType(myType) : null;
}and MyType will automatically receive a deep copy constructor.
- Fields
- Properties of types without copy constructor
- Properties of type
System.Object - Collection parameterized with
System.ObjectlikeIList<object>