{"id":19389522,"url":"https://github.com/linksplatform/disposables","last_synced_at":"2026-02-27T04:33:18.510Z","repository":{"id":35012333,"uuid":"196433487","full_name":"linksplatform/Disposables","owner":"linksplatform","description":"LinksPlatform's Platform.Disposables Class Library","archived":false,"fork":false,"pushed_at":"2025-09-14T12:21:34.000Z","size":2633,"stargazers_count":1,"open_issues_count":25,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T09:56:16.348Z","etag":null,"topics":["class-library","csharp","dotnet-framework","dotnet-standard","linksplatform"],"latest_commit_sha":null,"homepage":"https://linksplatform.github.io/Disposables","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linksplatform.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":"2019-07-11T16:54:18.000Z","updated_at":"2025-07-19T15:47:59.000Z","dependencies_parsed_at":"2024-03-17T21:28:28.500Z","dependency_job_id":"c35966af-76fe-473a-852b-6b8236c5a4df","html_url":"https://github.com/linksplatform/Disposables","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/linksplatform/Disposables","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDisposables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDisposables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDisposables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDisposables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linksplatform","download_url":"https://codeload.github.com/linksplatform/Disposables/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linksplatform%2FDisposables/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29884747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T23:51:21.483Z","status":"online","status_checked_at":"2026-02-27T02:00:06.759Z","response_time":57,"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":["class-library","csharp","dotnet-framework","dotnet-standard","linksplatform"],"created_at":"2024-11-10T10:16:28.476Z","updated_at":"2026-02-27T04:33:18.484Z","avatar_url":"https://github.com/linksplatform.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NuGet Version and Downloads count](https://img.shields.io/nuget/v/Platform.Disposables?label=nuget\u0026style=flat)](https://www.nuget.org/packages/Platform.Disposables)\n[![Actions Status](https://github.com/linksplatform/Disposables/workflows/csharp/badge.svg)](https://github.com/linksplatform/Disposables/actions?workflow=csharp)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/8fba2263c6a34204afc56553293d8225)](https://app.codacy.com/gh/linksplatform/Disposables?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=linksplatform/Disposables\u0026utm_campaign=Badge_Grade_Settings)\n[![CodeFactor](https://www.codefactor.io/repository/github/linksplatform/disposables/badge)](https://www.codefactor.io/repository/github/linksplatform/disposables)\n\n# [Disposables](https://github.com/linksplatform/Disposables) ([русская версия](README.ru.md))\n\nThis library helps to make objects disposable in a fast, short, easy and safe way. Say goodbye to memory leaks one at time :)\n\n`Platform.Disposables.DisposableBase` abstract class tries to dispose the object at both on instance destruction and `OnProcessExit` whatever comes first even if `Dispose` method was not called anywhere by user. And takes care your disposal logic executes only once by default, and if you really need it, you can allow multiple calls and attempts to dispose, by overriding corresponding properties.\n\nThe `Platform.Disposables.IDisposable` interface extends the `System.IDisposable` with `IsDisposed` property and `Destruct` method. The `Destruct` method is designed to never throw exceptions, that makes it safe to use in class destructors. All ignored exceptions are available at `Platform.Disposables.IgnoredDisposables` if you need to debug them.\n\nNamespace: [Platform.Disposables](https://linksplatform.github.io/Disposables/csharp/api/Platform.Disposables.html)\n\nForked from: [Konard/LinksPlatform/Platform/Platform.Helpers/Disposables](https://github.com/Konard/LinksPlatform/tree/708f6143645333781adae0cad7ae998fefcd6317/Platform/Platform.Helpers/Disposables)\n\nPackage at NuGet: [Platform.Disposables](https://www.nuget.org/packages/Platform.Disposables)\n\n## Examples\n\nIf you can use inheritance in your class. For example if you don't have other base class inherited.\n\n```C#\nusing Platform.Disposables;\n\nnamespace Examples\n{\n    public class DisposableBaseUsageExample : DisposableBase\n    {\n        protected override void Dispose(bool manual, bool wasDisposed)\n        {\n            // Put your dispose logic in this method\n\n            if (!wasDisposed) \n            {\n                // First call from Dispose or Destructor\n            }\n            else \n            {\n                // (IsDisposed == true) here, Dispose called twise, or Dispose and Destructor were called\n\n                if (manual)\n                {\n                    // Call from IDisposable.Dispose()\n                }\n                else\n                {\n                    // Call from Destructor\n                }\n            }\n        }\n    }\n}\n```\n\nIf you cannot use inheritance in your class. For example if you have other base class inherited.\n\n```C#\nusing Platform.Disposables;\n\nnamespace Examples\n{\n    public class DisposableUsageExample : System.IDisposable\n    {\n        private readonly Disposable _disposable;\n\n        public DisposableUsageExample() =\u003e _disposable = new Disposable(Disposed);\n\n        public void Dispose() =\u003e _disposable.Dispose();\n\n        ~DisposableUsageExample() =\u003e _disposable.Destruct();\n\n        private void Disposed(bool manual, bool wasDisposed)\n        {\n            // Dispose logic\n        }\n    }\n}\n```\n\nIf you do not have access to the internal structure of the object's class. You can use a disposable object container. The container is convertible back to the passed object at any time.\n\n```C#\nusing Platform.Disposables;\n\nnamespace Examples\n{\n    public class Examples\n    {\n        public static void UseAndDispose()\n        {\n            var array = new int[] { 1, 2, 3 };\n            Disposable\u003cint[]\u003e disposableArray = (array, () =\u003e array = null);\n            WorkWithObjectAndDispose(disposableArray);\n            // Here array == null\n        }\n\n        private static void WorkWithObjectAndDispose(Disposable\u003cint[]\u003e disposableArray)\n        {\n            using (disposableArray)\n            {\n                int[] array = disposableArray;\n\n                // Use your object here\n\n            } // Here there is call to () =\u003e array = null\n        }\n    }\n}\n```\n\n## [Documentation](https://linksplatform.github.io/Disposables)\n*   Interface [IDisposable](https://linksplatform.github.io/Disposables/csharp/api/Platform.Disposables.IDisposable.html).\n*   Abstract class [DisposableBase](https://linksplatform.github.io/Disposables/csharp/api/Platform.Disposables.DisposableBase.html).\n*   Class [Disposable](https://linksplatform.github.io/Disposables/csharp/api/Platform.Disposables.Disposable.html).\n*   Class [Disposable\\\u003cT\\\u003e](https://linksplatform.github.io/Disposables/csharp/api/Platform.Disposables.Disposable-1.html).\n\n[PDF file](https://linksplatform.github.io/Disposables/csharp/Platform.Disposables.pdf) with code for e-readers.\n\n## Depend on\n*   [Platform.Exceptions](https://github.com/linksplatform/Exceptions)\n\n## Dependent libraries\n*   [Platform.Collections](https://github.com/linksplatform/Collections)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinksplatform%2Fdisposables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinksplatform%2Fdisposables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinksplatform%2Fdisposables/lists"}