{"id":21864781,"url":"https://github.com/fluxera/fluxera.results","last_synced_at":"2025-03-21T21:11:36.730Z","repository":{"id":216799382,"uuid":"742129276","full_name":"fluxera/Fluxera.Results","owner":"fluxera","description":"A result object implementation.","archived":false,"fork":false,"pushed_at":"2024-05-31T09:50:18.000Z","size":108,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-31T10:49:12.623Z","etag":null,"topics":["ddd","dotnet","dotnet-core","dotnetcore","result","result-type","results"],"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/fluxera.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}},"created_at":"2024-01-11T20:23:48.000Z","updated_at":"2024-06-21T05:44:49.462Z","dependencies_parsed_at":"2024-01-18T14:09:06.626Z","dependency_job_id":"6d3cf950-1b89-44bf-a9b3-f44f8c454e83","html_url":"https://github.com/fluxera/Fluxera.Results","commit_stats":null,"previous_names":["mgernand/results","fluxera/fluxera.results"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluxera%2FFluxera.Results","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluxera%2FFluxera.Results/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluxera%2FFluxera.Results/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluxera%2FFluxera.Results/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluxera","download_url":"https://codeload.github.com/fluxera/Fluxera.Results/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244868763,"owners_count":20523590,"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":["ddd","dotnet","dotnet-core","dotnetcore","result","result-type","results"],"created_at":"2024-11-28T04:12:23.619Z","updated_at":"2025-03-21T21:11:36.710Z","avatar_url":"https://github.com/fluxera.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://dev.azure.com/fluxera/Foundation/_apis/build/status%2FGitHub%2Ffluxera.Fluxera.Results?branchName=main)](https://dev.azure.com/fluxera/Foundation/_build/latest?definitionId=96\u0026branchName=main)\n\n# Results\n\nA result object implementation. Return result objects from operations\nto indicate success or failure instead of throwing exceptions.\n\n## Features\n\n- Default result implementations with and without a result value.\n    - ```Result```\n    - ```Result\u003cint\u003e```\n- Supports multiple error messages.\n- Supports optional multiple success messages.\n- Supports custom error and success implementations.\n- Provides [FluentAssertions](https://fluentassertions.com/) extensions for simpler unit testing.\n- Provides extensions to transform results to ```IActionResult``` instances for ASP.NET controllers.\n- Provides extensions to transform results to ```IResult``` instances to be used with Minimal APIs.\n\n## Usage\n\n### Create Results\n\nTo create result instances use the static helper methods found in the ```Result``` class.\n\n```C#\n// Create a successful result without a value.\nResult result = Result.Ok();\n\n// Create a successful result with a value.\nResult\u003cint\u003e result = Result.Ok(42);\n\n// Create a failed result without a value.\nResult result = Result.Fail(\"An error occurred.\");\nResult result = Result.Fail(new Error(\"An error occurred));\n\n// Create a failed result for a result that can have a value.\nResult\u003cint\u003e result = Result.Fail\u003cint\u003e(\"An error occurred.\");\nResult\u003cint\u003e result = Result.Fail\u003cint\u003e(new Error(\"An error occurred));\n```\n\nThe result type ```Result``` is typically used by operations that have no return value.\n\n```C#\npublic Result PerformOperation() \n{\n    if(this.State == State.Failed) \n    {\n        return Result.Fail(\"The operation failed.\");\n    }\n\n    return Result.Ok();\n}\n```\n\nThe result type ```Result\u003cT\u003e``` is typically used by operations that have a return value.\n\n```C#\npublic Result\u003cint\u003e PerformOperation() \n{\n    if(this.State == State.Failed) \n    {\n        return Result.Fail\u003cint\u003e(\"The operation failed.\");\n    }\n\n    return Result.Ok(42);\n}\n```\n\n### Process Results\n\nTo process the result of an operation you can check if the operation was \nsuccessful or failed by accessing the ```IsSuccessful``` or ```IsFailed```\nproperties.\n\n```C#\n// Handle the return value of a result without a value.\nResult result = PerformOperation();\n\n// Print all error messages, if the result is failed.\nif(result.IsFailed) \n{\n    foreach(IError error in result.Errors) \n    {\n        Console.WriteLine(error.Message);\n    }\n}\n\n// Print all success messages, if the result is successful.\nif(result.IsSuccessful) \n{\n    foreach(ISuccess success in result.Successes) \n    {\n        Console.WriteLine(success.Message);\n    }\n}\n\n// Handle the return value of a result with a value.\nResult\u003cint\u003e result = PerformOperation();\n\n// Get the value if the result is successful or will throw if the result is failed.\nint value = result.Value;\n\n// Get the value oif the result is successful or will return the default of the value.\nint value = result.GetValueOrDefault();\n```\n\n## References\n\n[Michael Altmann](https://github.com/altmann)\n\n[FluentResults](https://github.com/altmann/FluentResults)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluxera%2Ffluxera.results","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluxera%2Ffluxera.results","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluxera%2Ffluxera.results/lists"}