RzR.MinimalResultMessage 1.0.0

dotnet add package RzR.MinimalResultMessage --version 1.0.0
                    
NuGet\Install-Package RzR.MinimalResultMessage -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="RzR.MinimalResultMessage" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RzR.MinimalResultMessage" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RzR.MinimalResultMessage" />
                    
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 RzR.MinimalResultMessage --version 1.0.0
                    
#r "nuget: RzR.MinimalResultMessage, 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.
#:package RzR.MinimalResultMessage@1.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=RzR.MinimalResultMessage&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RzR.MinimalResultMessage&version=1.0.0
                    
Install as a Cake Tool

The goal of this repository is to give methods and processes one way to report their outcome. It is a structured response and callers don't need a different return shape for every operation.

Every operation returns the same structured, easy-to-parse model. The caller can check whether it succeeded, read the value it produced, and inspect the messages that explain a failure.

This is a deliberately minimal F# take on the author's C# library RzR.ResultMessage. It keeps only the core result model: no message types or action helpers, and a single fluent extension (WithExtension).

What the library offers:

  • MinimalResult<T>: the result of an operation that returns a value. Create it with Success(response), Failure(code, message) or Failure(messages). It exposes IsSuccess, IsFailure, Response (the default value of T on a failure) and Messages.
  • MinimalResult: the non-generic result for operations that return no value. It inherits from MinimalResult<object> and offers Success(), Failure(code, message) and Failure(messages).
  • ResultMessage: one message attached to a result. It has a Code, a Message (may be null) and Extensions (additional data keyed by name, may be null).
  • Additional failure data: pass a dictionary to Failure(code, message, extensions) (stored as a read-only copy), or add one entry at a time with WithExtension(key, value), which works on successes and failures.
  • IMinimalResult and IMinimalResult<T>: interfaces for code that only needs to read a result.
  • Implicit conversions:
    • from T to a successful MinimalResult<T>.
    • from bool to MinimalResult. false gives a failure with code UnSuccessfullyReqExec.
    • from Exception to a failure with code UnhandledException and the exception's Message. A null exception throws ArgumentNullException.
Namespace Types
RzR.MinimalResultMessage MinimalResult<T>, MinimalResult
RzR.MinimalResultMessage.Models ResultMessage
RzR.MinimalResultMessage.Abstractions IMinimalResult, IMinimalResult<T>

Results and messages use reference equality. Two results with the same content are not equal.

The only dependency is FSharp.Core (9.0.100 or newer). Add the library to your project and you can start using it.

Install

dotnet add package RzR.MinimalResultMessage

or, from the Package Manager Console:

Install-Package RzR.MinimalResultMessage

Quick start

C#

using System;
using RzR.MinimalResultMessage;

public static class OrderService
{
    public static MinimalResult<int> ParseQuantity(string input)
    {
        if (int.TryParse(input, out var quantity))
            return quantity; // implicit conversion: success

        return MinimalResult<int>.Failure("InvalidQuantity", $"'{input}' is not a number.");
    }

    public static MinimalResult Save(int quantity)
    {
        try
        {
            // persist the quantity
            return true; // implicit conversion: success
        }
        catch (Exception ex)
        {
            return ex; // implicit conversion: failure with code "UnhandledException"
        }
    }

    public static void Print(MinimalResult<int> result)
    {
        if (result.IsSuccess)
            Console.WriteLine(result.Response);
        else
            foreach (var m in result.Messages)
                Console.WriteLine($"{m.Code}: {m.Message}");
    }
}

F#

In F#, call the conversions explicitly with op_Implicit. A type-annotated binding such as let r : MinimalResult = false also works, but raises warning FS3391.

open System
open RzR.MinimalResultMessage

let parseQuantity (input: string) : MinimalResult<int> =
    match Int32.TryParse input with
    | true, quantity -> MinimalResult<int>.Success quantity
    | _ -> MinimalResult<int>.Failure("InvalidQuantity", $"'{input}' is not a number.")

let save (quantity: int) : MinimalResult =
    try
        // persist the quantity
        MinimalResult.op_Implicit true
    with ex ->
        MinimalResult.op_Implicit ex

let result = parseQuantity "12"
if result.IsSuccess then printfn $"{result.Response}"
else result.Messages |> Seq.iter (fun m -> printfn $"{m.Code}: {m.Message}")
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.  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.  net10.0 was computed.  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. 
.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 is compatible. 
.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.

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
1.0.0 39 10/14/2026

Initial release. See docs/CHANGELOG.md.