Repository navigation
Make With extension methods and let Func map to another type [major] - #85
Merged
Merged
Conversation
DelegateTransform.With(...) failed with CS0234 from any other ktsu.* namespace, where the simple name resolves to the namespace ktsu.DelegateTransform rather than the class. Make the three With overloads extension methods so callers write input.With(...), which never names the type and chains fluently as the docs describe. Replace With<T>(T, Func<T, T>) with With<T, TResult>(T, Func<T, TResult>) so the README's mapping example compiles. Keeping both would make every lambda call ambiguous (CS0121); TResult infers to T for same-type functions, so existing Func calls bind to the new overload. Add ConsumerNamespaceTests in ktsu.Consumer, which compiles the README examples from outside the library's namespace so the clash cannot return, and update the README and CLAUDE.md to the extension form. Fixes #76 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CTnJ1xEhZzPB9o25LiPf2C
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
DelegateTransform.With(...)didn't compile from any otherktsu.*namespace. There the simple nameDelegateTransformresolves to the namespacektsu.DelegateTransform, not the class, so the call fails with CS0234. The README's mapping example didn't compile anywhere either. This PR implements the maintainer decision on the issue.Withoverloads now takethis T input. Callers writeinput.With(...), which never names the type, and chaining works as the docs describe.With<T>(T, Func<T, T>)is replaced byWith<T, TResult>(T, Func<T, TResult>).TResultinfers toTfor same-type functions, so existingFunccall sites bind to the new overload unchanged.ConsumerNamespaceTests.cslives inktsu.Consumerand compiles the README examples: ActionRef, Func, FuncRef, fluent chaining, mapping tostring, and the null check on the new overload.This is a breaking API change: the
Func<T, T>overload is removed and the methods gainthis. It ships as major, per the decision on the issue.Verification
Withonint/string/Person).dotnet testpasses 12/12 (6 existing, 6 new).dotnet build -c Releasepasses across every target framework (net10.0 through net6.0 and netstandard2.1).Fixes #76
🤖 Generated with Claude Code
https://claude.ai/code/session_01CTnJ1xEhZzPB9o25LiPf2C
Generated by Claude Code