LightResults - Operation Result Patterns for .NET

Star Issue Sponsor

LightResults is an extremely light and modern .NET library that provides a simple and flexible implementation of the Result Pattern. The Result Pattern is a way of representing the outcome of an operation, whether it's successful or has encountered an error, in a more explicit and structured manner. This project is heavily inspired by Michael Altmann's excellent work with FluentResults.

test nuget downloads

References

This library targets .NET 8.0, .NET 9.0, and .NET 10.0 with no external runtime dependencies.

Installation

Install the library from NuGet:

dotnet add package LightResults

Dependencies

This library has no dependencies.

Advantages of this library

  • ๐Ÿชถ Lightweight โ€” Only contains what's necessary to implement the Result Pattern.
  • โš™๏ธ Extensible โ€” Simple interfaces and base classes make it easy to adapt.
  • ๐Ÿงฑ Immutable โ€” Results and errors are immutable and cannot be changed after being created.
  • ๐Ÿงต Thread-safe โ€” Error and metadata collections are read-only.
  • โœจ Modern โ€” Built against the latest version of .NET using the most recent best practices.
  • ๐Ÿงช Native โ€” Written, compiled, and tested against the latest versions of .NET.
  • โค๏ธ Compatible โ€” Multi-targeted for current LTS and STS releases.
  • ๐Ÿชš Trimmable โ€” Compatible with ahead-of-time compilation (AOT) as of .NET 7.0.
  • ๐Ÿš€ Performant โ€” Heavily optimized and benchmarked to aim for the highest possible performance.

Extensions

Several extensions are available to simplify implementation that use LightResults.