ShereSoft.DeepCloning
1.0.2
See the version list below for details.
dotnet add package ShereSoft.DeepCloning --version 1.0.2
NuGet\Install-Package ShereSoft.DeepCloning -Version 1.0.2
<PackageReference Include="ShereSoft.DeepCloning" Version="1.0.2" />
paket add ShereSoft.DeepCloning --version 1.0.2
#r "nuget: ShereSoft.DeepCloning, 1.0.2"
// Install ShereSoft.DeepCloning as a Cake Addin #addin nuget:?package=ShereSoft.DeepCloning&version=1.0.2 // Install ShereSoft.DeepCloning as a Cake Tool #tool nuget:?package=ShereSoft.DeepCloning&version=1.0.2
One of the fastest deep-cloner library provides a set of methods to deep-copy an instance of any object. Implemented in Common Intermediate Language (.NET Assembler) offering performance equivalent to hand-written C# code. Available in multi-targeted libraries. (NOT a .NET Standard library) No dependencies.
- Can deep-clone instances of any object
- One of the fastest libraries in NuGet
- Implemented in Common Intermediate Language (.NET Assembly), compiled for each type at runtime, and cached for subsequent use.
- No use of Reflection for cloning
- Configurable for string handling (deep clone or not) and singleton handling (reuse or clone)
- Thread-safe and lock-free
- Includes extension methods (ObjectExtensions) for conveniently calling from any object instance (Recommended usage)
- Unit Tested
- Multi-targeted (.NET 6, .NET 5, .NET Core 3.1, .NET Framework 4.8, .NET Framework 4.7, .NET Framework 4.6, .NET Framework 4.5, .NET Framework 4.0)
- No external library dependencies
- No external calls
QUICK START
Using the extension methods (included) is recommended.
.DeepClone()
using ShereSoft.Extensions;
:
Customer customer = new Customer();
:
Customer clone = customer.DeepClone();
DeepCloningOptions
.DeepCloneStrings = true
var customer = new Customer();
customer.Name = "John";
var options = new DeepCloningOptions { DeepCloneStrings = true };
Customer clone = customer.DeepClone(options);
Debug.WriteLine(Object.ReferenceEquals(customer, clone)); // False (Default is reuse, NOT deep copy)
Strings are reused by default as they are normally treated as immutable. If your code contains any string manipulation by pointer, use this option to prevent unwanted side effects to the original object.
.DeepCloneSingletons = true
class Customer
{
public static readonly Customer Empty = new Customer(); // Static readonly fields as singletons
:
}
var customer = Customer.Empty;
var options = new DeepCloningOptions { DeepCloneSingletons = true };
Customer clone = customer.DeepClone(options);
Debug.WriteLine(Object.ReferenceEquals(customer, clone)); // False (Default is reuse, NOT deep copy)
"static readonly" fields are assumed to be immutable. If your code is not, which by the way is not the best practice, use this option.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.2
* Fixed issues with copying null elements in collections
* Improved performance by a single delegate, more optimized runtime evaluation, more inlining implementation and more optimized Assembler code
* Added unit tests for the resolved issues
* Reduced the assembly size.
1.0.1
* Added .NET Framework support for 4.0, 4.6, 4.7 and 4.8
* Made cloner creation lock-free
1.0.0
* Can deep-clone instances of any object
* Implemented in Common Intermediate Language (.NET Assembly), compiled for each type at runtime, and cached for subsequent use.
* No use of Reflection for cloning
* Configurable for string handling (deep clone or not) and singleton handling (reuse or clone)
* Thread-safe
* Includes extension methods (ObjectExtensions) for conveniently calling from any object instance (Recommended usage)
* Unit Tested
* Multi-targeted (.NET 6, .NET 5, .NET Core 3.1, .NET Framework 4.5)
* No external library dependencies
* No external calls