RA.Utilities.Core 10.0.0

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

RA.Utilities.Core

NuGet version Codecov GitHub license NuGet Downloads Documentation

RA.Utilities.Core is a lightweight .NET library designed to enhance error handling by providing a functional Result type. It helps you write cleaner, more predictable, and more robust code by avoiding exceptions for expected operational failures.

🚀 Getting Started

Install the package via the .NET CLI:

dotnet add package RA.Utilities.Core

✨ Key Features

Functional Result and Result<T> Types

The library provides two core types for handling outcomes:

  • Result: For operations that succeed or fail without returning a value (e.g., saving to a database).
  • Result<T>: For operations that return a value on success.

These types make the intent of your code explicit by forcing you to handle both success and failure paths, preventing unhandled errors.

public Result<User> FindUser(int userId)
{
    var user = _userRepository.GetById(userId);

    if (user is null)
    {
        return new NotFoundException("User not found."); // Implicit conversion to Failure
    }

    return user; // Implicit conversion to Success
}

The Match method ensures that both success and failure cases are handled:

var result = FindUser(123);

return result.Match(
    onSuccess: user => Ok(user),
    onFailure: exception => NotFound(exception.Message)
);

Railway-Oriented Programming Extensions

Chain multiple fallible operations together using a fluent, readable API. The chain short-circuits on the first failure, passing the error down the line.

  • Map(): Transforms the value inside a successful Result<T>.
  • Bind(): Chains another function that returns a Result.
  • OnSuccess() / OnFailure(): Executes side-effects like logging without altering the result.
public Result<string> GetAdminEmail(int userId)
{
    return FindUser(userId)
        .Bind(user => EnsureIsAdmin(user))
        .Map(adminUser => adminUser.Email)
        .OnSuccess(email => _logger.LogInformation("Admin email found for user {UserId}", userId))
        .OnFailure(ex => _logger.LogError(ex, "Failed to get admin email for user {UserId}", userId));
}

Asynchronous Support

All extension methods have async counterparts (MapAsync, BindAsync, etc.) to integrate seamlessly into asynchronous workflows.

var result = await FindUserAsync(userId)
    .BindAsync(user => ValidatePermissionsAsync(user));

Additional documentation

For more information on how this package fits into the larger RA.Utilities ecosystem, please see the main repository documentation.

Product Compatible and additional computed target framework versions.
.NET 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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RA.Utilities.Core:

Package Downloads
RA.Utilities.Feature

Provides a base implementation for the feature slice/vertical slice architecture pattern, including base handlers, validation behaviors, and exception handling for CQRS.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.100-rc.2 244 11/16/2025
10.0.0 420 11/19/2025
10.0.0-rc.2 159 10/27/2025