{"id":32958254,"url":"https://github.com/lofcz/FastCloner","last_synced_at":"2025-11-16T17:02:02.633Z","repository":{"id":271398373,"uuid":"913311293","full_name":"lofcz/FastCloner","owner":"lofcz","description":"The deep cloning library for .NET – zero-config, works out of the box.","archived":false,"fork":false,"pushed_at":"2025-11-14T19:39:19.000Z","size":474,"stargazers_count":167,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"next","last_synced_at":"2025-11-14T21:24:59.709Z","etag":null,"topics":["cloner","deep-clone","deep-cloning","deep-copy","deepclone","deepcopy","duplication"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"adimosh/DeepCloner","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lofcz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-07T12:46:49.000Z","updated_at":"2025-11-14T19:39:22.000Z","dependencies_parsed_at":"2025-01-07T22:33:09.388Z","dependency_job_id":"6ad934a5-8a4c-4dfe-a434-6b2ffc762797","html_url":"https://github.com/lofcz/FastCloner","commit_stats":null,"previous_names":["lofcz/deepcloner","lofcz/fastcloner"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/lofcz/FastCloner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lofcz%2FFastCloner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lofcz%2FFastCloner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lofcz%2FFastCloner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lofcz%2FFastCloner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lofcz","download_url":"https://codeload.github.com/lofcz/FastCloner/tar.gz/refs/heads/next","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lofcz%2FFastCloner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284742551,"owners_count":27056072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloner","deep-clone","deep-cloning","deep-copy","deepclone","deepcopy","duplication"],"created_at":"2025-11-12T23:00:34.017Z","updated_at":"2025-11-16T17:02:02.623Z","avatar_url":"https://github.com/lofcz.png","language":"C#","funding_links":[],"categories":["Tools","Identifiers"],"sub_categories":["GUI - other"],"readme":"[![FastCloner](https://shields.io/nuget/v/FastCloner?v=302\u0026icon=nuget\u0026label=FastCloner)](https://www.nuget.org/packages/FastCloner)\n[![FastCloner.Contrib](https://shields.io/nuget/v/FastCloner.Contrib?v=302\u0026icon=nuget\u0026label=FastCloner.Contrib)](https://www.nuget.org/packages/FastCloner.Contrib)\n\n# FastCloner\n\n\u003cimg align=\"left\" width=\"128\" height=\"128\" alt=\"Te Reo Icon\" src=\"https://github.com/user-attachments/assets/54f5be37-543a-411d-b6e6-90a77414926c\" /\u003e\nFast deep cloning library, supporting anything from \u003ccode\u003e.NET 4.6\u003c/code\u003e to modern \u003ccode\u003e.NET 10+\u003c/code\u003e with no dependencies. Implements both deep and shallow cloning. Extensively tested, focused on performance and stability even on complicated object graphs. FastCloner is designed to work with as few gotchas as possible out of the box. The mapping is zero-config by default. Clone your objects and be done with it \u003cem\u003efast\u003c/em\u003e. FastCloner builds upon \u003ca href=\"https://github.com/force-net/DeepCloner\"\u003eDeepClone\u003c/a\u003e.\n\n\u003cbr/\u003e\u003cbr/\u003e\n\n## Getting Started\n\nInstall the package via NuGet:\n\n```powershell\ndotnet add package FastCloner\n```\n\nClone your objects:\n\n```csharp\nusing FastCloner.Code;\nvar clone = FastCloner.FastCloner.DeepClone(new { Hello = \"world\", MyList = new List\u003cint\u003e { 1 } });\n```\n\n⭐ **That's it!** _For convenience, please add the following method to your project. We intentionally don't ship this extension to make switching from/to FastCloner easier:_\n\n```cs\n[return: NotNullIfNotNull(nameof(obj))]\npublic static T? DeepClone\u003cT\u003e(this T? obj)\n{\n    return FastCloner.FastCloner.DeepClone(obj);\n}\n```\n\n## Advanced usage\n\n_The following examples assume you've copied the extension method above._\n\nSometimes, you might want to exclude certain fields (including event synthesized) and properties from cloning:\n```csharp\nprivate class TestPropsWithIgnored\n{\n    [FastClonerIgnore] // \u003c-- decorate with [FastClonerIgnore] or [NonSerialized]\n    public string B { get; set; } = \"My string\";\n\n    public int A { get; set; } = 10;\n}\n\nTestPropsWithIgnored original = new TestPropsWithIgnored { A = 42, B = \"Test value\" };\nTestPropsWithIgnored clone = original.DeepClone(); // clone.B is null (default value of a given type)\n```\n\nYou might also need to exclude certain types from being cloned ever. To do that, put offending types on a blacklist:\n```cs\nFastCloner.FastCloner.IgnoreType(typeof(PropertyChangedEventHandler)); // or FastCloner.FastCloner.IgnoreTypes([ .. ])\n```\n\nIf needed, the types can be removed from the blacklist later:\n```cs\n// note: doing this invalidates precompiled expressions and clears the cache,\n// performance will be negatively affected until the cache is repopulated\nFastCloner.FastCloner.ClearIgnoredTypes();\n```\n\nApart from deep cloning, FastCloner supports shallow cloning and deep cloning _to_ target:\n\n```csharp\n// the list is shared between the two instances\nvar clone = FastCloner.FastCloner.ShallowClone(new { Hello = \"world\", MyList = new List\u003cint\u003e { 1 } });\n```\n\n## Limitations\n\nFastCloner uses caching by default, which makes evaluating properties harder. Cloning unmanaged resources, such as `IntPtr`s may result in side-effects, as there is no metadata for the length of buffers such pointers often point to. `ReadOnly` and `Immutable` collections are tested to behave well if they follow basic conventions. Many other features, such as cloning `Dictionary`ies properly while keeping hashcodes, `INotifyPropertyChanged`, `delegate`s, `event`s, `HttpRequest`s / responses, and others are supported. FastCloner supports cloning deeply nested objects where recursion isn't possible by switching to a slightly slower iterative approach when needed. The threshold for this can be configured by changing `FastCloner.MaxRecursionDepth`. If something doesn't work out of the box, let me know in the [issues](https://github.com/lofcz/FastCloner/issues), the repository is actively maintained.\n\nCache can be invalidated to reduce the memory footprint, if needed:\n\n```csharp\nFastCloner.FastCloner.ClearCache();\n```\n\n## Performance\n\nFastCloner aims to _work correctly_ and meet reasonable expectations by default while being fast. Benchmarking results are available [here](https://github.com/lofcz/FastCloner/tree/next/FastCloner.Benchmark), check them out! By default, FastCloner relies on heavily cached reflection to work. An incremental source generator is currently in development as an opt-in alternative for performance-critical scenarios.\n\n## Contributing\n\nIf you are looking to add new functionality, please open an issue first to verify your intent is aligned with the scope of the project. The library is covered by over [500 tests](https://github.com/lofcz/FastCloner/tree/next/FastCloner.Tests), please run them against your work before proposing changes. When reporting issues, providing a minimal reproduction we can plug in as a new test greatly reduces turnaround time.\n\n## License\n\nThis library is licensed under the [MIT](https://github.com/lofcz/FastCloner/blob/next/LICENSE) license. 💜\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flofcz%2FFastCloner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flofcz%2FFastCloner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flofcz%2FFastCloner/lists"}