Skip to content

Installation

Prerequisites

  • .NET 6.0, 7.0, 8.0, or 9.0
  • Visual Studio 2022 or later (recommended)
  • Visual Studio Code with C# extension (alternative)

Dependencies

TinyResult requires the following dependencies: - System.Text.Json (7.0.3)

Package Installation

NuGet Package Manager

  1. Open your project in Visual Studio
  2. Right-click on the project in Solution Explorer
  3. Select "Manage NuGet Packages"
  4. Search for "TinyResult"
  5. Click "Install"

.NET CLI

dotnet add package TinyResult

PackageReference

Add the following to your project file:

<ItemGroup>
    <PackageReference Include="TinyResult" Version="1.0.0" />
</ItemGroup>

Project Setup

1. Create a New Project

dotnet new console -n MyApp
cd MyApp

2. Add TinyResult Package

dotnet add package TinyResult

3. Add Using Directive

Add the following using directive to your code:

using TinyResult;

Configuration

Basic Configuration

No special configuration is required to start using TinyResult. The library is ready to use after installation.

Optional Configuration

If you want to customize the behavior of TinyResult, you can do so by creating a configuration class:

public class TinyResultConfig
{
    public static void Configure()
    {
        // Configure default error messages
        Result.DefaultErrorMessages = new Dictionary<ErrorCode, string>
        {
            { ErrorCode.Unknown, "An unknown error occurred" },
            { ErrorCode.NotFound, "The requested resource was not found" },
            { ErrorCode.ValidationError, "Validation failed" }
        };

        // Configure logging
        Result.OnError = error => Console.WriteLine($"Error: {error.Message}");
    }
}

Verification

To verify that TinyResult is installed correctly, create a simple test:

using TinyResult;

class Program
{
    static void Main(string[] args)
    {
        var result = Result<int>.Success(42);
        result.Match(
            value => Console.WriteLine($"Success: {value}"),
            error => Console.WriteLine($"Error: {error.Message}")
        );
    }
}

Run the program and you should see the output:

Success: 42

Troubleshooting

Common Issues

  1. Package Not Found
  2. Ensure you have the correct NuGet source configured
  3. Check your internet connection
  4. Verify the package name is correct

  5. Version Conflicts

  6. Check for version conflicts with other packages
  7. Update to the latest version of TinyResult
  8. Consider using a specific version

  9. Build Errors

  10. Clean and rebuild your solution
  11. Check for missing references
  12. Verify your .NET version

Getting Help

If you encounter any issues:

  1. Check the documentation
  2. Search for existing issues on GitHub
  3. Create a new issue if needed

Next Steps