YoussefSell.Result.Net 1.0.0

Suggested Alternatives

Result.Net

Additional Details

this package has been deprecated please use this package "Result.Net" instead.

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package YoussefSell.Result.Net --version 1.0.0
NuGet\Install-Package YoussefSell.Result.Net -Version 1.0.0
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="YoussefSell.Result.Net" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YoussefSell.Result.Net --version 1.0.0
#r "nuget: YoussefSell.Result.Net, 1.0.0"
#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.
// Install YoussefSell.Result.Net as a Cake Addin
#addin nuget:?package=YoussefSell.Result.Net&version=1.0.0

// Install YoussefSell.Result.Net as a Cake Tool
#tool nuget:?package=YoussefSell.Result.Net&version=1.0.0

Result.Net

a simple wrapper for an operation result to indicate success or failure, instead of throwing exceptions or return false without explanation.

Simple Usage

// to create success result
var successResult = Result.Success();

// to create a failed result
var failedResult = Result.Failed();

to create a result wrapper for a value you can use Result<<TValue>>

// to create success result with flout value
var successResult = Result.Success<float>(55.5);

// to create a failed result for a float value
var failedResult = Result.Failed<float>();

you can also define a message associated with the result in bout cases (success and failure)

// to create success result with a message
var successResult = Result.Success<float>(55.5)
  .WithMessage("Operation Succeeded");

// to create a failed result with a message
var failedResult = Result.Failed<float>()
  .WithMessage("Operation Failed");

Note if no message is provided the default messages are "Operation Succeeded" for success, and "Operation Failed" for failure. in case of an error, you can specie an error code to describe what happened.

// create a failed result with a message and code
var failedResult = Result.Failed()
  .WithMessage("Othe provided email is not valid")
  .WithCode(ResultCode.InvalidEmail);

Note there is a list of predefined error codes that I use frequently you can find at ResultCode.

you can also provide an ResultError to better define what happened

var failedResult = Result.Failed()
  .WithMessage("Othe provided email is not valid")
  .WithCode("invalid_email")
  .WithError(new []
  {
    new ResultError(
      message: "the email host is not allowed",
      code: "invalid_email_host")
  });

if you want to encapsulate an exception you can do the following

public Result DoSomeWork()
{
  try
  {
    // you code goes here
    return Result.Success();
  }
  catch(Exception ex)
  {
    return Result.Failed()
      .WithMessage("an internal exception has been thrown")
      .WithCode(ResultCode.OperationFailedException)
      .WithError(ex);
  }
}

what about logging! by default, if you created a Failed result a LogTraceCode will be generated, and you can include this tracing code in your logs to track the errors.

public Result DoSomeWork()
{
  try
  {
    // you code goes here
    return Result.Success();
  }
  catch(Exception ex)
  {
    var result = Result.Failed()
      .WithMessage("an internal exception has been thrown")
      .WithCode(ResultCode.OperationFailedException)
      .WithError(ex);
      
    _logger.LogError(ex, "exception {@info}", new 
    {
      LogTraceCode = result.LogTraceCode
      // + your meta data about the error
    });
    
    return result;
  }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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