TS.Result 8.0.7

There is a newer version of this package available.
See the version list below for details.
dotnet add package TS.Result --version 8.0.7
                    
NuGet\Install-Package TS.Result -Version 8.0.7
                    
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="TS.Result" Version="8.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TS.Result" Version="8.0.7" />
                    
Directory.Packages.props
<PackageReference Include="TS.Result" />
                    
Project file
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 TS.Result --version 8.0.7
                    
#r "nuget: TS.Result, 8.0.7"
                    
#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.
#addin nuget:?package=TS.Result&version=8.0.7
                    
Install TS.Result as a Cake Addin
#tool nuget:?package=TS.Result&version=8.0.7
                    
Install TS.Result as a Cake Tool

TS.Result NuGet Package

Overview

The TS.Result package is designed to encapsulate the result of operations in .NET applications, offering a structured way to handle success and failure states with associated data or error messages. It is ideal for improving error handling and response consistency across various application layers.

Features

  • Generic Result Type: Facilitates strong typing of the operation outcome, accommodating any data type.
  • Error Handling: Enables capturing multiple error messages, suitable for scenarios requiring detailed feedback.
  • HTTP Status Code Integration: Aligns operation results with HTTP response standards, enhancing API development.
  • Implicit Conversions: Streamlines result creation from data or errors through implicit conversion operators.

Getting Started

Installation

To integrate TS.Result into your project, install it via the NuGet package manager:

Install-Package TS.Result

Or through the .NET CLI:

dotnet add package TS.Result

Usage

  • For a successful operation, instantiate a Result object with the desired data:
var successResult = new Result<string>("Operation successful.");
  • Alternatively, leverage implicit conversion from data:
Result<string> result = "Operation successful.";
  • For failures, create a Result object with an HTTP status code and error messages:
var errorResult = new Result<string>(400, new List<string> { "Error 1", "Error 2" });
  • Or use implicit conversion from error details:
Result<string> result = (400, new List<string> { "Error 1", "Error 2" });
  • For single error messages:
Result<string> result = (400, "Single error message");
  • For success using Succeed method:
Result<string> result = Result<string>.Succeed("Is successful");
  • For error using Failure method:
  • One error message
Result<string> result = Result<string>.Failure(500,"Is fail!");
  • Multiple error messages
Result<string> result = Result<string>.Failure(500,new List<string>() {"Is fail!","Is not unique!"});
  • One error message return 500 status code
Result<string> result = Result<string>.Failure("Is fail!"); //return 500 status code
  • Multiple error messages return 500 status code
Result<string> result = Result<string>.Failure(new List<string>() {"Is fail!","Is not unique!"}); //return 500 status code
  • Success Result
{
  "data": {
    "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9",
    "refreshToken": "dbfa1ced-6ae1-4120-beea-4d0dbde492e3",
    "refreshTokenExpires": "2024-05-20T03:51:44.4942877Z"
  },
  "errorMessages": null,
  "isSuccessful": true
}
  • Error Result
{
  "Data": null,
  "ErrorMessages": [
    "Username must be at least 3 characters"
  ],
  "IsSuccessful": false
}

Contributing

We welcome contributions! Feel free to open an issue or submit a pull request on our GitHub repository for any suggestions or improvements.

License

TS.Result is licensed under the MIT License. See the LICENSE file in the source repository for full details.

This Markdown formatted README provides a comprehensive guide on how to use the `TS.Result` package, suitable for your project's repository or documentation.

Product 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on TS.Result:

Package Downloads
FlexiReport

A backend library for generating and managing reports in Flexi Report. Supports dynamic SQL queries, database schema retrieval, and seamless integration with the Angular frontend.

MB.Infrastructure

This is a generic Infrastructure for .NET

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.1 732 12/6/2024
8.0.13 301 11/1/2024
8.0.12 99 11/1/2024
8.0.11 110 11/1/2024
8.0.10 100 11/1/2024
8.0.9 95 11/1/2024
8.0.8 151 9/29/2024
8.0.7 101 9/29/2024
8.0.6 1,180 4/20/2024
8.0.5 341 3/3/2024
8.0.4 143 2/28/2024
8.0.3 146 2/28/2024
8.0.2 147 2/25/2024
8.0.1 143 2/25/2024
8.0.0 159 2/25/2024