{"id":24686885,"url":"https://github.com/ricardotondello/functional.toolkit.optiontype","last_synced_at":"2025-10-08T15:31:57.605Z","repository":{"id":163861550,"uuid":"639301018","full_name":"ricardotondello/Functional.Toolkit.OptionType","owner":"ricardotondello","description":"Functional.Toolkit.OptionType is a lightweight library that provides an implementation of the Option type in C#. The Option type is a functional programming concept that represents a value that may or may not be present.  This can help reduce the number of null checks in your code, making it more robust and easier to reason about.","archived":false,"fork":false,"pushed_at":"2025-01-16T15:32:19.000Z","size":365,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T16:58:57.688Z","etag":null,"topics":["csharp","dotnet","dotnetcore","extensions","option-type"],"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/ricardotondello.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":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-11T07:30:59.000Z","updated_at":"2024-10-05T10:16:57.000Z","dependencies_parsed_at":"2024-08-05T10:16:56.233Z","dependency_job_id":null,"html_url":"https://github.com/ricardotondello/Functional.Toolkit.OptionType","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctional.Toolkit.OptionType","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctional.Toolkit.OptionType/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctional.Toolkit.OptionType/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricardotondello%2FFunctional.Toolkit.OptionType/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ricardotondello","download_url":"https://codeload.github.com/ricardotondello/Functional.Toolkit.OptionType/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235726370,"owners_count":19035840,"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":["csharp","dotnet","dotnetcore","extensions","option-type"],"created_at":"2025-01-26T16:17:00.939Z","updated_at":"2025-10-08T15:31:52.312Z","avatar_url":"https://github.com/ricardotondello.png","language":"C#","funding_links":["https://www.buymeacoffee.com/ricardotondello"],"categories":[],"sub_categories":[],"readme":"# 🚀 Functional.Toolkit.OptionType\n\n[![Build](https://github.com/ricardotondello/Functional.Toolkit.OptionType/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/ricardotondello/Functional.Toolkit.OptionType/actions/workflows/dotnet.yml)\n[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=ricardotondello_Functional.Toolkit.OptionType\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ricardotondello_Functional.Toolkit.OptionType)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ricardotondello_Functional.Toolkit.OptionType\u0026metric=coverage)](https://sonarcloud.io/component_measures?id=ricardotondello_Functional.Toolkit.OptionType\u0026metric=coverage)\n[![NuGet latest version](https://badgen.net/nuget/v/Functional.Toolkit.OptionType/latest)](https://nuget.org/packages/Functional.Toolkit.OptionType)\n[![NuGet downloads](https://img.shields.io/nuget/dt/Functional.Toolkit.OptionType)](https://www.nuget.org/packages/Functional.Toolkit.OptionType)\n\n\nFunctional.Toolkit.OptionType is a lightweight library that provides an implementation of the Option type in C#.\nThe Option type is a functional programming concept that represents a value that may or may not be present. \nThis can help reduce the number of null checks in your code, making it more robust and easier to reason about.\n\n_Here its just a few examples, check all the available extensions in the [OptionExtensions.cs](https://github.com/ricardotondello/Functional.Toolkit.OptionType/blob/main/src/Functional.Toolkit.OptionType/OptionExtensions.cs) file_\n\n## Usage\n\n```csharp\n//Object Initialization\n\nvar option1 = Option.From((ClassForTest)null); //will automatically determine if its None or Some based on the generic type\nvar option2 = Option.From(new ClassForTest());\nvar option3 = Option.None\u003cClassForTest\u003e();\nvar option4 = Option.Some(new ClassForTest());\n...\n\n//Sync\nvar maybeClass = await MaybeGetClass();\n\nmaybeClass\n    .WhenSome(value =\u003e\n    {\n        Console.WriteLine($\"Proceed doing something with the value: {value.Name}\");\n        //It could be whatever you want, here you have the value of the type of the Option\n        //Example:\n        //Call another methods, write in the DB, Publish to a Service Bus, infinity...\n    })\n    .WhenNone(() =\u003e\n    {\n        Console.WriteLine(\"Proceed as a fallback without the value\");\n        //since the Option is None the value couldn't be found.\n        //Example:\n        //Write logs, alerts, whatever.\n    })\n    .WhenAny(maybeValue =\u003e\n    {\n        Console.WriteLine(\"Despite having a value or not this will be execute and you can decide what to do.\");\n        Console.WriteLine($\"Does my object has a value? {maybeValue.HasValue}\");\n    });\n\n\n//Async\nvar maybeClassTask = MaybeGetClass();\n\nvar result = await maybeClassTask\n    .WhenSomeAsync(value =\u003e \n    { \n        Console.WriteLine($\"Proceed doing something with the value: {value.Name}\");\n        return Task.CompletedTask;\n    })\n    .WhenNoneAsync(() =\u003e\n    {\n        Console.WriteLine(\"Proceed as a fallback without the value\");\n        return Task.CompletedTask;\n    }).WhenAnyAsync(maybeValue =\u003e\n    {\n        Console.WriteLine($\"Does my object has a value? {maybeValue.HasValue}\");\n    });\n```\n\n## Contributing\n\nContributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub.\nIf you would like to contribute code, please fork the repository and submit a pull request.\n\n## License\n\nFunctional.Toolkit.OptionType is licensed under the MIT License. \nSee [LICENSE](https://github.com/ricardotondello/Functional.Toolkit.OptionType/blob/main/LICENSE) for more information.\n\n## Support\n\n\u003ca href=\"https://www.buymeacoffee.com/ricardotondello\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricardotondello%2Ffunctional.toolkit.optiontype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fricardotondello%2Ffunctional.toolkit.optiontype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricardotondello%2Ffunctional.toolkit.optiontype/lists"}