{"id":13629528,"url":"https://github.com/StefH/AnyOf","last_synced_at":"2025-04-17T09:34:27.313Z","repository":{"id":44867281,"uuid":"382850794","full_name":"StefH/AnyOf","owner":"StefH","description":"Use the AnyOf\u003cTFirst, TSecond, ...\u003e type to handle multiple defined types as input parameters or return values for methods.","archived":false,"fork":false,"pushed_at":"2024-09-30T15:50:38.000Z","size":140,"stargazers_count":109,"open_issues_count":2,"forks_count":8,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-10-29T11:12:38.187Z","etag":null,"topics":["anyof","multiple","type","typed","types"],"latest_commit_sha":null,"homepage":"","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/StefH.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},"funding":{"github":["StefH"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":"https://www.paypal.me/stefheyenrath"}},"created_at":"2021-07-04T12:49:51.000Z","updated_at":"2024-10-03T13:09:44.000Z","dependencies_parsed_at":"2024-04-18T23:16:08.870Z","dependency_job_id":null,"html_url":"https://github.com/StefH/AnyOf","commit_stats":{"total_commits":60,"total_committers":3,"mean_commits":20.0,"dds":0.4,"last_synced_commit":"2ab7b9cd168aecd37c7331e3364f5e0e14f4d9c2"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FAnyOf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FAnyOf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FAnyOf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefH%2FAnyOf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefH","download_url":"https://codeload.github.com/StefH/AnyOf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222090821,"owners_count":16929472,"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","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":["anyof","multiple","type","typed","types"],"created_at":"2024-08-01T22:01:12.940Z","updated_at":"2024-11-08T20:31:07.424Z","avatar_url":"https://github.com/StefH.png","language":"C#","readme":"# AnyOf\nUse the `AnyOf\u003cFirst, TSecond, ...\u003e` type to handle multiple defined types as input parameters for methods.\n\nThis project uses code generation to generate up to 10 AnyOf-types:\n\n- `AnyOf\u003cTFirst, TSecond\u003e`\n- `AnyOf\u003cTFirst, TSecond, TThird\u003e`\n- `AnyOf\u003cTFirst, TSecond, TThird, TFourth\u003e`\n- ...\n\n# Install\n## The normal version:\n[![NuGet Badge](https://img.shields.io/nuget/v/AnyOf)](https://www.nuget.org/packages/AnyOf)\n\n## The source-generator version:\n[![NuGet Badge](https://img.shields.io/nuget/v/AnyOf.SourceGenerator)](https://www.nuget.org/packages/AnyOf.SourceGenerator)\n\n## AnyOf.Newtonsoft.Json\nThis package can be used to serialize/deserialize (with Newtonsoft.Json) an object which contains an AnyOf-type.\u003cbr\u003e\nFor more details see [wiki : AnyOf.Newtonsoft.Json](https://github.com/StefH/AnyOf/wiki/AnyOf.Newtonsoft.Json)\n\n[![NuGet Badge](https://img.shields.io/nuget/v/AnyOf.Newtonsoft.Json)](https://www.nuget.org/packages/AnyOf.Newtonsoft.Json)\n\n## AnyOf.System.Text.Json\nThis package can be used to serialize/deserialize (with System.Text.Json) an object which contains an AnyOf-type.\u003cbr\u003e\nFor more details see [wiki : AnyOf.System.Text.Json](https://github.com/StefH/AnyOf/wiki/AnyOf.System.Text.Json)\n\n[![NuGet Badge](https://img.shields.io/nuget/v/AnyOf.System.Text.Json)](https://www.nuget.org/packages/AnyOf.System.Text.Json)\n\n# Usage\n``` c#\nusing System;\nusing AnyOfTypes;\n\nnamespace ConsoleAppConsumer\n{\n    internal class Program\n    {\n        private static void Main(string[] args)\n        {\n            Console.WriteLine(ReturnSomething().CurrentValue);\n\n            X(42);\n            X(\"test\");\n        }\n\n        // This method returns an string, int or bool in a random way.\n        private static AnyOf\u003cstring, int, bool\u003e ReturnSomething()\n        {\n            return new Random().Next(3) switch\n            {\n                1 =\u003e \"test\",\n                2 =\u003e 42,\n                _ =\u003e true,\n            };\n        }\n\n        // This method accepts only an int and a string.\n        private static void X(AnyOf\u003cint, string\u003e value)\n        {\n            Console.WriteLine(\"ToString \" + value.ToString());\n            Console.WriteLine(\"CurrentValue \" + value.CurrentValue);\n            Console.WriteLine(\"IsUndefined \" + value.IsUndefined);\n            Console.WriteLine(\"IsFirst \" + value.IsFirst);\n            Console.WriteLine(\"IsSecond \" + value.IsSecond);\n\n            switch (value.CurrentType)\n            {\n                case AnyOfType.First:\n                    Console.WriteLine(\"AnyOfType = First with value \" + value.First);\n                    break;\n\n                case AnyOfType.Second:\n                    Console.WriteLine(\"AnyOfType = Second with value \" + value.Second);\n                    break;\n\n                default:\n                    Console.WriteLine(\"???\");\n                    break;\n            }\n        }\n    }\n}\n```\n","funding_links":["https://github.com/sponsors/StefH","https://www.paypal.me/stefheyenrath"],"categories":["Source Generators","Do not want to test 112 ( old ISourceGenerator )"],"sub_categories":["Functional Programming","1. [ThisAssembly](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ThisAssembly) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefH%2FAnyOf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStefH%2FAnyOf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStefH%2FAnyOf/lists"}