EffectiveResult 1.1.4
dotnet add package EffectiveResult --version 1.1.4
NuGet\Install-Package EffectiveResult -Version 1.1.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EffectiveResult" Version="1.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EffectiveResult" Version="1.1.4" />
<PackageReference Include="EffectiveResult" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EffectiveResult --version 1.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EffectiveResult, 1.1.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EffectiveResult@1.1.4
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EffectiveResult&version=1.1.4
#tool nuget:?package=EffectiveResult&version=1.1.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Effective Result
Implementation of the result monad pattern for an alternative way of handling errors. Focused on ease of use with Fluent API and support for LINQ-like chaining. Support (de)serialization by System.Text.Json.
Roadmap of library
- Base Result model implementation
- Helpful extension methods for result manipulation
- Support channing by
Thenmethods - Add support of async implementations for methods
Then,Try,Matchand etc - System.Text.Json (de)serialization implementation
- Update Readme with extended wiki with all current features: Then methods, Async support, channing usages and etc.
- Add support of value-tuple result with extensions (ValueResult)
- Support FluentValidation
- Support FluentAssertions
- Support TUnit assertions
Library usage examples
Result model
// Just result
Result successRes = Result.Ok();
bool isSuccess = successRes.IsSuccess;
bool isFailed = successRes.IsFailed;
// Error from message
Result failedRes1 = Result.Fail("Ooops!");
// Error from exception
Result failedRes2 = Result.Fail(new Exception("Bad situation!"));
Result with value
Result<int> successValuedRes = Result.Ok(5);
// Error from message
Result<int> failedValueRes1 = Result.Fail<int>("Ooops!");
// Error from exception
Result<int> failedValueRes2 = Result.Fail<int>(new Exception("Bad situation!"));
Result class methods
Result<int> countResult = Result.Ok(1000);
// Throw, if failed
int myValue1 = countResult.Value;
// Not throw, but can return default value of type
int myValue2 = countResult.ValueOrDefault;
// Get value or return other value
int myValue3 = countResult.GetValueOrDefault(100);
// Get value or construct and return other value
int myValue4 = countResult.GetValueOrDefault(() => 2);
Work with errors
// Base type of errors
var errorWithMessage = new ResultError("Bad 1");
var errorWithException = new ResultError(new Exception("Sorry, but..."));
var errorWithMessageAndException = new ResultError("Bad 2", new Exception("Sorry, but..."));
var errorWithCaused = new ResultError("Bad 2", new Exception("Sorry, but..."), [errorWithMessage]);
// Errors using
Result fail = Result.Fail(new ArgumentException("myVariable"));
// Get errors of result
IReadOnlyCollection<ResultError> errors = fail.Errors;
bool hasSpecificError = fail.TryGetException<ArgumentException>(out ArgumentException typedException);
// Get all exception of ResultError, if contains
IEnumerable<Exception> exceptions = fail.GetExceptions();
// Get all typed exception of ResultError, if contains
IEnumerable<ArgumentException> exceptionsTyped = fail.GetExceptions<ArgumentException>();
// Get all filtered exception of ResultError, if contains
IEnumerable<Exception> exceptionsFiltered = fail.GetExceptions(x => x.Message == "Oops!");
// Get first exception of ResultError, if contains
bool contains1 = fail.TryGetException(out Exception? exception);
// Get first typed exception of ResultError, if contains
bool contains2 = fail.TryGetException(out ArgumentException? argumentEx);
// Get first filtered exception of ResultError, if contains
bool contains3 = fail.TryGetException(out Exception? filtered, x => x.Message == "Oops!");
Useful static methods
// Conditional
Result cond1 = Result.OkIf(1 == 2, "Error message");
Result cond2 = Result.FailIf(2 == 1, new Exception("Oh..."));
/// Try and return
// Return failed result with error, variable will be false
Result wasSuccess = Result.Try(() => throw new Exception("No no no"));
// Return success result with value
Result<int> valuedResult = Result.Try(() => 100);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.1.4 | 216 | 4/27/2026 | |
| 1.1.3 | 167 | 1/28/2026 | |
| 1.1.2 | 139 | 1/24/2026 | |
| 1.1.1 | 361 | 12/7/2025 | |
| 1.1.0 | 463 | 11/19/2025 | |
| 1.0.0 | 188 | 11/8/2025 | |
| 1.0.0-alpha-4 | 169 | 11/1/2025 | |
| 1.0.0-alpha-3 | 164 | 11/1/2025 | |
| 1.0.0-alpha-2 | 273 | 10/18/2024 | |
| 1.0.0-alpha | 236 | 8/31/2024 |
Add new Try/TryAsync method with ability to return Result/Result_T like Then/ThenAsync