{"id":19958549,"url":"https://github.com/badeend/any","last_synced_at":"2026-06-13T21:33:29.730Z","repository":{"id":235768382,"uuid":"791208040","full_name":"badeend/Any","owner":"badeend","description":"Holds any value of any type, without boxing small structs (up to 8 bytes).","archived":false,"fork":false,"pushed_at":"2024-05-29T15:31:33.000Z","size":59,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-13T09:54:04.067Z","etag":null,"topics":["csharp","garbage-collection"],"latest_commit_sha":null,"homepage":"https://badeend.github.io/Any/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/badeend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"badeend"}},"created_at":"2024-04-24T09:39:15.000Z","updated_at":"2025-04-03T12:50:21.000Z","dependencies_parsed_at":"2024-05-29T18:21:45.520Z","dependency_job_id":null,"html_url":"https://github.com/badeend/Any","commit_stats":null,"previous_names":["badeend/any"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/badeend/Any","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badeend%2FAny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badeend%2FAny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badeend%2FAny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badeend%2FAny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badeend","download_url":"https://codeload.github.com/badeend/Any/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badeend%2FAny/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34301731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"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":["csharp","garbage-collection"],"created_at":"2024-11-13T01:43:34.769Z","updated_at":"2026-06-13T21:33:29.714Z","avatar_url":"https://github.com/badeend.png","language":"C#","funding_links":["https://github.com/sponsors/badeend"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./docs/images/logo.png\" alt=\"Any\" width=\"200\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cem\u003eHolds any value of any type, without boxing small structs.\u003c/em\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.nuget.org/packages/Badeend.Any\"\u003e\u003cimg src=\"https://img.shields.io/nuget/v/Badeend.Any\" alt=\"Nuget\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n`Any` is a C# struct that can hold any value of any type, similar to the `object` type, but without the overhead of boxing for small value types (up to 8 bytes). This library is designed to offer flexibility and efficiency when dealing with unknown or dynamic data types while minimizing garbage collection (GC) pressure.\n\nAdditionally, it can simplify API design in scenarios where using generics or method overloads is burdensome (or even impossible).\n\n---\n\n**Documentation \u0026 more information at: https://badeend.github.io/Any/**\n\n---\n\n## Installation\n\n[![NuGet Badeend.Any](https://img.shields.io/nuget/v/Badeend.Any?label=Badeend.Any)](https://www.nuget.org/packages/Badeend.Any)\n\n```sh\ndotnet add package Badeend.Any\n```\n\n## Usage\n\nIn its most basic form, it can be as simple as this:\n```cs\nAny a = 42; // Does not allocate.\nAny b = \"Hello world\";\nAny c = DateTime.UtcNow;\n\n// Somewhere down the line:\n\nvar i = (int)a;\nvar s = (string)b;\nvar d = (DateTime)c;\n```\n\nUnlike `object`, two `Any` instances are considered equal when their content is the same:\n```cs\nAny x = 123;\nAny y = 123;\n\n// If you were to use `object`, the following line would fail:\nAssert(x == y); // =\u003e true\n```\n\nMore operations are available as extension methods:\n```cs\n_ = a.As\u003cint\u003e(); // Similar to: `a as int?`\n_ = a.Is\u003cint\u003e(); // Similar to: `a is int`\n_ = a.Cast\u003cint\u003e(); // Similar to: `(int)a`\n```\n\n[Full API reference](https://badeend.github.io/Any/api/Badeend.html)\n\n## When can boxing be avoided?\n\nData can be inlined into the `Any` instance itself for any `struct` type (including user-defined types) that:\n- is 8 bytes in size or less, _and_:\n- does not contain references.\n\nIn practice this turns out to be many of the commonly used .NET built-ins:\n- `bool`\n- `char`\n- `byte`\n- `sbyte`\n- `short`\n- `ushort`\n- `int`\n- `uint`\n- `long`\n- `ulong`\n- `nint` / `IntPtr`\n- `nuint` / `UIntPtr`\n- `float`\n- `double`\n- `DateTime`\n- `TimeSpan`\n- `DateOnly`\n- `TimeOnly`\n- `Index`\n- `Range`\n- all `enum`s\n- `ValueTuple`s such as `(int, int)`\n\n\n### Shameless self-promotion\n\nMay I interest you in one of my other packages?\n\n- **[Badeend.ValueCollections](https://badeend.github.io/ValueCollections/)**: _Low overhead immutable collection types with structural equality._\n- **[Badeend.EnumClass](https://badeend.github.io/EnumClass/)**: _Discriminated unions for C# with exhaustiveness checking._\n- **[Badeend.Result](https://badeend.github.io/Result/)**: _For failures that are not exceptional: `Result\u003cT,E\u003e` for C#._\n- **[Badeend.Any](https://badeend.github.io/Any/)**: _Holds any value of any type, without boxing small structs (up to 8 bytes)._\n- **[Badeend.Nothing](https://github.com/badeend/Nothing)**: _If you want to use `void` as a type parameter, but C# won't let you._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadeend%2Fany","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadeend%2Fany","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadeend%2Fany/lists"}