FlowRight.Core
1.0.0-alpha.13
dotnet add package FlowRight.Core --version 1.0.0-alpha.13
NuGet\Install-Package FlowRight.Core -Version 1.0.0-alpha.13
<PackageReference Include="FlowRight.Core" Version="1.0.0-alpha.13" />
<PackageVersion Include="FlowRight.Core" Version="1.0.0-alpha.13" />
<PackageReference Include="FlowRight.Core" />
paket add FlowRight.Core --version 1.0.0-alpha.13
#r "nuget: FlowRight.Core, 1.0.0-alpha.13"
#:package FlowRight.Core@1.0.0-alpha.13
#addin nuget:?package=FlowRight.Core&version=1.0.0-alpha.13&prerelease
#tool nuget:?package=FlowRight.Core&version=1.0.0-alpha.13&prerelease
FlowRight
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 imperativeSwitch
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
- π CLAUDE.md - Development guidelines and coding standards
- π TASKS.md - Development progress and task tracking
- π Getting Started Guide - Complete guide for new users
- π API Reference - Interactive DocFX-generated API documentation
- π Migration Guide - Migrating from exception-based error handling
- β Best Practices - Production patterns and architectural guidance
- π Performance Benchmarks - Comprehensive performance analysis and optimization results
ποΈ 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
- π OPTIMIZATION_RESULTS.md - Detailed optimization analysis and before/after comparisons
- π Benchmark Suite - Comprehensive BenchmarkDotNet test suite
- π Exception Comparison - Result pattern vs traditional exception handling
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
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Stack Overflow: Tag your questions with
flowright
πΊοΈ 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 | Versions 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. |
-
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.