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.

main nuget downloads

References

This library targets .NET Standard 2.0, .NET 6.0, .NET 7.0, and .NET 8.0.

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 — The Error list and Metadata dictionary use Immutable classes for thread-safety.
  • ✨ 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 — Available for dozens of versions of .NET as a .NET Standard 2.0 library.
  • 🪚 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.