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¶
- Open your project in Visual Studio
- Right-click on the project in Solution Explorer
- Select "Manage NuGet Packages"
- Search for "TinyResult"
- 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¶
- Package Not Found
- Ensure you have the correct NuGet source configured
- Check your internet connection
-
Verify the package name is correct
-
Version Conflicts
- Check for version conflicts with other packages
- Update to the latest version of TinyResult
-
Consider using a specific version
-
Build Errors
- Clean and rebuild your solution
- Check for missing references
- Verify your .NET version
Getting Help¶
If you encounter any issues:
- Check the documentation
- Search for existing issues on GitHub
- Create a new issue if needed