Skip to content

Functional Extensions#6

Merged
feO2x merged 3 commits intomainfrom
5-functional-extensions
Jan 14, 2026
Merged

Functional Extensions#6
feO2x merged 3 commits intomainfrom
5-functional-extensions

Conversation

@feO2x
Copy link
Copy Markdown
Owner

@feO2x feO2x commented Jan 14, 2026

Closes #5

  • introduce functional extensions and corresponding tests
  • remove existing functional methods from Result<T> and Result as they are now available as extension methods

@feO2x feO2x self-assigned this Jan 14, 2026
@feO2x feO2x linked an issue Jan 14, 2026 that may be closed by this pull request
@feO2x feO2x requested a review from Copilot January 14, 2026 22:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces functional extensions for the Light.Results library by extracting existing functional methods from the Result<T> and Result structs into extension methods in a new Light.Results.FunctionalExtensions namespace. The implementation introduces two new interfaces (IResult<TSelf> and IResultWithValue<TSelf, TValue>) that enable generic extension methods while maintaining zero-allocation performance.

Changes:

  • Added functional extension methods (Map, Bind, Tap, TapError, Match, MatchFirst, Switch, SwitchFirst, Else, FailIf, Ensure, MapError) with async variants
  • Removed existing functional methods from Result<T> and Result structs
  • Introduced IResult<TSelf> and IResultWithValue<TSelf, TValue> interfaces to enable generic extension methods
  • Added comprehensive test coverage for all functional extensions

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Light.Results/IResult.cs New interface enabling generic extension methods for both result types
src/Light.Results/IResultWithValue.cs New interface for results carrying success values
src/Light.Results/Result.cs Removed functional methods (Map, Bind, Tap, TapError) and implemented new interfaces
src/Light.Results/FunctionalExtensions/*.cs New extension methods organized by functionality (12 files)
tests/Light.Results.Tests/FunctionalExtensions/*.cs Comprehensive test coverage for all extension methods
src/Light.Results/Light.Results.csproj Added System.Threading.Tasks.Extensions dependency
Directory.Packages.props Added System.Threading.Tasks.Extensions version 4.6.3

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Light.Results/FunctionalExtensions/Tap.cs
Comment thread src/Light.Results/FunctionalExtensions/Map.cs
Comment thread src/Light.Results/FunctionalExtensions/Else.cs
@feO2x feO2x merged commit ee59e55 into main Jan 14, 2026
7 checks passed
@feO2x feO2x deleted the 5-functional-extensions branch January 14, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

# Functional Extensions for Light.Results

2 participants