FlowRight.Core 1.0.0-alpha.13

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

FlowRight

Pre-release Build Status Coverage License

A production-grade Result pattern implementation for .NET that eliminates exception-based control flow while providing comprehensive validation and HTTP integration capabilities.

🎯 Features

  • Exception-Free Error Handling: Explicit success/failure states without throwing exceptions
  • Full JSON Serialization: Seamless serialization/deserialization of both success and failure states
  • Pattern Matching: Functional Match and imperative Switch methods for elegant control flow
  • Validation Builder: Fluent API for building complex validation rules with automatic error aggregation
  • HTTP Integration: Convert HTTP responses to Result types with automatic status code interpretation
  • Zero Dependencies: Core library has no external dependencies
  • Performance Optimized: Zero allocations on success path, minimal overhead compared to exceptions
  • Type-Safe: Full nullable reference type support and strong typing throughout

πŸ“¦ Packages

Package Description Status
FlowRight.Core Core Result pattern implementation ⚑ In Development
FlowRight.Validation Fluent validation builder with Result integration ⚑ In Development
FlowRight.Http HTTP response to Result conversion ⚑ In Development

Note: Packages are currently in active development (alpha releases). Production release planned for Q2 2025.

πŸš€ Quick Start

Installation

# 🚧 Pre-release packages (active development)
# Core Result pattern
dotnet add package FlowRight.Core --prerelease

# Validation support
dotnet add package FlowRight.Validation --prerelease

# HTTP integration
dotnet add package FlowRight.Http --prerelease

⚠️ Development Status: FlowRight is currently in active development. APIs may change before stable release.

Basic Usage

using FlowRight.Core.Results;

// Simple success/failure
Result<int> Divide(int numerator, int denominator)
{
    if (denominator == 0)
        return Result.Failure<int>("Cannot divide by zero");
    
    return Result.Success(numerator / denominator);
}

// Pattern matching
string message = Divide(10, 2).Match(
    onSuccess: value => $"Result: {value}",
    onFailure: error => $"Error: {error}"
);

// Using Switch for side effects
Divide(10, 0).Switch(
    onSuccess: value => Console.WriteLine($"Success: {value}"),
    onFailure: error => Console.WriteLine($"Failed: {error}")
);

Validation Builder

using FlowRight.Validation.Builders;

public Result<User> CreateUser(CreateUserRequest request)
{
    return new ValidationBuilder<User>()
        .RuleFor(x => x.Name, request.Name)
            .NotEmpty()
            .MinimumLength(2)
            .MaximumLength(100)
        .RuleFor(x => x.Email, request.Email)
            .NotEmpty()
            .EmailAddress()
        .RuleFor(x => x.Age, request.Age)
            .GreaterThan(0)
            .LessThan(150)
        .Build(() => new User(request.Name, request.Email, request.Age));
}

HTTP Integration

using FlowRight.Http.Extensions;

public async Task<Result<WeatherData>> GetWeatherAsync(string city)
{
    HttpResponseMessage response = await _httpClient.GetAsync($"/weather/{city}");
    return await response.ToResultFromJsonAsync<WeatherData>();
}

// Automatically handles:
// - 2xx β†’ Success with deserialized data
// - 400 β†’ Validation errors from Problem Details
// - 401/403 β†’ Security failures
// - 404 β†’ Not found
// - 5xx β†’ Server errors

Combining Results

Result<Order> CreateOrder(OrderRequest request)
{
    Result<Customer> customerResult = GetCustomer(request.CustomerId);
    Result<Product> productResult = GetProduct(request.ProductId);
    Result<Address> addressResult = ValidateAddress(request.ShippingAddress);
    
    // Combine multiple results
    Result combined = Result.Combine(customerResult, productResult, addressResult);
    if (combined.IsFailure)
        return Result.Failure<Order>(combined.Error);
    
    // All results are successful, create the order
    return Result.Success(new Order(
        customerResult.Value,
        productResult.Value,
        addressResult.Value
    ));
}

πŸ“š Documentation

πŸ—οΈ Building from Source

Prerequisites

  • .NET 8.0 SDK or later
  • Visual Studio 2022 or VS Code with C# extension

Building

# Clone the repository
git clone https://github.com/georgepharrison/FlowRight.git
cd FlowRight

# Build the solution
dotnet build

# Run tests
dotnet test

# Run benchmarks
dotnet run -c Release --project benchmarks/Benchmarks/Benchmarks.csproj

πŸ§ͺ Testing

Integration Testing βœ… Complete

FlowRight includes comprehensive integration tests covering:

  • Complex Object Validation: Real-world e-commerce scenarios with nested objects
  • Result Composition: Multi-step business workflows and async patterns
  • HTTP Integration: Real HTTP responses with status code mapping
  • API Serialization: ASP.NET Core integration with WebApplicationFactory
  • Thread Safety: Concurrent operations and race condition testing

Test Coverage

The project maintains comprehensive test coverage with extensive unit and integration tests, including 500+ integration tests covering real-world scenarios, targeting >95% coverage for production release.

# Run all tests with coverage
dotnet test --collect:"XPlat Code Coverage" --results-directory ./coverage

# Generate coverage report (requires ReportGenerator)
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:coverage/**/coverage.cobertura.xml -targetdir:coverage/report -reporttypes:Html

πŸ“Š Performance

FlowRight is designed for minimal overhead and zero allocations on the success path. After extensive optimization work, we've achieved significant performance improvements:

Core Operations Performance (Optimized)

Operation Time Allocations vs Exceptions
Result.Success() 19.11ns 0 bytes ~10x faster
Result.Failure() 5.46ns <100 bytes ~100x faster
Pattern Match ~78ns 0 bytes No exceptions
Validation (10 rules) ~200ns <500 bytes ~50x faster

Memory Efficiency Targets βœ…

  • Success Path: Zero allocations (0 bytes) βœ…
  • Single Error: <100 bytes (target), 200 bytes (max) βœ…
  • Validation Errors: <500 bytes (target), 1KB (max) βœ…
  • JSON Serialization: <200 bytes (target), 500 bytes (max) βœ…

Performance Documentation

Performance Note: Results measured on .NET 9.0 using BenchmarkDotNet. Your results may vary based on hardware and .NET version.

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Inspired by functional programming patterns in F# and Rust
  • Built on the shoulders of the .NET community
  • Special thanks to all contributors and users

πŸ“ž Support

πŸ—ΊοΈ Roadmap

Version 1.0 (Q2 2025) - Production Ready

Core Library:

  • βœ… Core Result pattern implementation (90.7% coverage)
  • βœ… Pattern matching with Match/Switch methods
  • βœ… JSON serialization support
  • βœ… Implicit operators and conversions

Validation Library:

  • βœ… Fluent validation builder with thread safety (comprehensive coverage)
  • βœ… 35+ validation rules (string, numeric, collection, etc.)
  • βœ… Context-aware validation with async support
  • βœ… Automatic error aggregation
  • βœ… Integration tests with complex object validation

HTTP Integration:

  • βœ… HTTP response to Result conversion with real response testing
  • βœ… Status code mapping (2xx, 400, 401/403, 404, 5xx)
  • βœ… Content type detection and parsing
  • βœ… ValidationProblemDetails support
  • βœ… API serialization integration with ASP.NET Core

Remaining for v1.0:

  • βœ… Comprehensive integration testing (Tasks 56-60 complete)
  • βœ… Thread safety and concurrency testing
  • βœ… Performance benchmarking and optimization
  • βœ… Complete XML documentation
  • 🚧 NuGet package publishing

Version 1.1 (Q3 2025)

  • Additional validation rules based on feedback
  • Performance optimizations
  • Source generators for reduced boilerplate

Version 2.0 (Q4 2025)

  • AsyncResult<T> for async operations
  • Railway-oriented programming extensions
  • F# interop package

See CHANGELOG.md for version history.


Made with ❀️ by the .NET community

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

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on FlowRight.Core:

Package Downloads
FlowRight.Http

HTTP client extensions for seamless Result pattern integration with web API responses. Features automatic status code mapping, JSON deserialization, validation problem handling, and comprehensive error conversion for HTTP operations.

FlowRight.Validation

Fluent validation library with integrated Result pattern support and comprehensive rule-based validation. Features property validators, conditional rules, custom validation logic, and automatic error aggregation for complex domain objects.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.13 27 9/2/2025
1.0.0-alpha.12 30 9/2/2025
1.0.0-alpha.11 32 9/2/2025

Initial preview release of FlowRight Result pattern library. See README.md for usage examples.