ktsu.DeepClone
1.1.16-pre.11
Prefix Reserved
See the version list below for details.
dotnet add package ktsu.DeepClone --version 1.1.16-pre.11
NuGet\Install-Package ktsu.DeepClone -Version 1.1.16-pre.11
<PackageReference Include="ktsu.DeepClone" Version="1.1.16-pre.11" />
paket add ktsu.DeepClone --version 1.1.16-pre.11
#r "nuget: ktsu.DeepClone, 1.1.16-pre.11"
// Install ktsu.DeepClone as a Cake Addin #addin nuget:?package=ktsu.DeepClone&version=1.1.16-pre.11&prerelease // Install ktsu.DeepClone as a Cake Tool #tool nuget:?package=ktsu.DeepClone&version=1.1.16-pre.11&prerelease
ktsu.DeepClone
A lightweight .NET library providing a simple, generic interface for implementing deep cloning functionality in your classes.
Overview
The ktsu.DeepClone
library defines the IDeepCloneable<T>
interface, which allows you to create deep copies of objects. This is particularly useful in scenarios where you need to duplicate an object while ensuring that its references to other objects are also fully cloned, not just copied.
Inspired by and based on the ppy/osu! project's cloning utilities, this library is licensed under the MIT License. See the LICENSE
file for more details.
Features
- Generic Interface: Works with any reference type (
class
). - Deep Cloning: Ensures that the cloned object is a completely independent copy, including all nested references.
- Lightweight and easy to integrate into your project.
Getting Started
Installation
Install the library via NuGet (coming soon):
dotnet add package ktsu.DeepClone
Or, clone the repository and include the source code directly in your project.
Usage
To use ktsu.DeepClone
, implement the IDeepCloneable<T>
interface in your class:
using ktsu.DeepClone;
public class MyClass : IDeepCloneable<MyClass>
{
public int Value { get; set; }
public MyClass NestedObject { get; set; }
public MyClass DeepClone()
{
return new MyClass
{
Value = this.Value,
NestedObject = this.NestedObject?.DeepClone()
};
}
}
You can then create deep copies of your objects:
var original = new MyClass
{
Value = 42,
NestedObject = new MyClass { Value = 84 }
};
var copy = original.DeepClone();
// The copy is a completely independent object
copy.Value = 100;
copy.NestedObject.Value = 200;
// Original remains unchanged
Console.WriteLine(original.Value); // Outputs: 42
Console.WriteLine(original.NestedObject.Value); // Outputs: 84
Contributing
Contributions are welcome! If you have suggestions or feature requests, please feel free to open an issue or submit a pull request.
Development
- Clone the repository:
git clone https://github.com/ktsu-dev/ktsu.DeepClone.git
- Open the project in your preferred IDE.
- Build and run tests to ensure functionality.
License
This library is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
This library is inspired by the ppy/osu! project's cloning utilities. Many thanks to their team for their foundational work and open-source contributions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ktsu.DeepClone:
Package | Downloads |
---|---|
ktsu.Extensions
A utility library of extension methods to enhance the functionality of collections, enumerables, dictionaries, strings, and reflection in .NET |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.16 | 95 | 1/2/2025 |
1.1.16-pre.13 | 2 | 1/8/2025 |
1.1.16-pre.12 | 33 | 1/7/2025 |
1.1.16-pre.11 | 36 | 1/6/2025 |
1.1.16-pre.10 | 53 | 1/4/2025 |
1.1.16-pre.9 | 43 | 1/3/2025 |
1.1.16-pre.8 | 44 | 1/3/2025 |
1.1.16-pre.7 | 45 | 1/3/2025 |
1.1.16-pre.6 | 48 | 1/2/2025 |
1.1.16-pre.5 | 64 | 12/31/2024 |
1.1.16-pre.4 | 42 | 12/29/2024 |
1.1.16-pre.3 | 37 | 12/28/2024 |
1.1.16-pre.2 | 43 | 12/27/2024 |
1.1.16-pre.1 | 43 | 12/27/2024 |
1.1.15-pre.1 | 41 | 12/27/2024 |
1.1.14 | 553 | 12/26/2024 |
1.1.13 | 77 | 12/26/2024 |
1.1.12 | 79 | 12/26/2024 |
1.1.11 | 72 | 12/26/2024 |
1.1.10 | 76 | 12/26/2024 |
1.1.10-pre.1 | 43 | 12/27/2024 |
1.1.9 | 75 | 12/26/2024 |
1.1.8 | 80 | 12/26/2024 |
1.1.7 | 1,182 | 12/23/2024 |
1.1.6 | 69 | 12/23/2024 |
1.1.5 | 541 | 12/22/2024 |
1.1.4 | 162 | 12/22/2024 |
1.1.3 | 946 | 12/12/2024 |
1.1.2 | 642 | 12/4/2024 |
1.1.1 | 555 | 12/2/2024 |
1.1.0 | 89 | 12/2/2024 |
1.0.18 | 87 | 12/2/2024 |
1.0.17 | 440 | 11/30/2024 |
1.0.16 | 390 | 11/26/2024 |
1.0.15 | 318 | 11/20/2024 |
1.0.14 | 857 | 11/13/2024 |
1.0.13 | 944 | 11/1/2024 |
1.0.12 | 1,177 | 10/15/2024 |
1.0.11 | 729 | 10/4/2024 |
1.0.10 | 886 | 9/19/2024 |
1.0.9 | 296 | 9/19/2024 |
1.0.8 | 86 | 9/19/2024 |
1.0.7 | 370 | 9/19/2024 |
1.0.6 | 113 | 9/18/2024 |
1.0.5 | 104 | 9/18/2024 |
1.0.4 | 102 | 9/18/2024 |
1.0.3 | 349 | 9/18/2024 |
1.0.2 | 854 | 9/14/2024 |
1.0.1 | 114 | 9/14/2024 |
## v1.1.16 (patch)
Changes since v1.1.15-pre.1:
- Add scripts for automated metadata generation and versioning ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.1.15-pre.1 (patch)
Changes since v1.1.14:
- Renamed metadata files ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.1.10 (patch)
Changes since v1.1.9:
- Replace LICENSE file with LICENSE.md and update copyright information ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.1.8 (patch)
Changes since v1.1.7:
- Update test method names and replace LICENSE file ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.1.1 (patch)
Changes since v1.1.0:
- Remove unnecessary PackageReference from DeepClone.Test project ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.1.0 (minor)
Changes since 1.0.0:
- Add test project, update README, and remove .gitattributes ([@matt-edmondson](https://github.com/matt-edmondson))
- Migrate ktsu.io to ktsu namespace ([@matt-edmondson](https://github.com/matt-edmondson))
- Update repository URL in README.md ([@matt-edmondson](https://github.com/matt-edmondson))
- Update VERSION ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.0.2 (major)
Changes since 0.0.0.0:
- Initial commit ([@matt-edmondson](https://github.com/matt-edmondson))
- Migrate ktsu.io to ktsu namespace ([@matt-edmondson](https://github.com/matt-edmondson))
- Update DeepClone.csproj ([@matt-edmondson](https://github.com/matt-edmondson))
- Update VERSION ([@matt-edmondson](https://github.com/matt-edmondson))