feat(these): JSON serialization, ToResult semantics fix, test coverage#40
Merged
Conversation
… docs/skills - maybe: add TapNone extension tests (Task/ValueTask, sync+async) - these: add ToResultLenient(IsRight/IsLeft) and Partition(empty) tests - time: add UtcNowDate/UtcNowTime tests (#if NET6_0_OR_GREATER) - rules: add FromPredicateAsync with errorFactory test - These/Readme.MD: write full readme (Left/Right/Both, bridge, Partition) - Maybe/Results/Rules/Time Readme.MD: document new APIs - csharpessentials-these/SKILL.md: new skill file - csharpessentials-maybe/results/rules/time SKILL.md: add new API sections Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ToResult: handle IsBoth as failure (Both was incorrectly returning success because IsLeft and IsBoth are mutually exclusive in the struct) - ToResultLenient: simplify guard from `IsLeft && !IsBoth` to `IsLeft` (equivalent since IsLeft and IsBoth are mutually exclusive by design) - TheseTests: add ToResult_Should_ReturnFailure_When_IsBoth test - TheseTests: fix CA1304/CA1305/CA1311 warnings (ToUpper/ToString with CultureInfo.InvariantCulture) - MaybeNewFeaturesTests: add missing negative tests for ValueTask TapNoneAsync extension methods (HasValue path) - FakeDateTimeProviderTests: align test names to _When_ convention Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add [JsonConstructor] private constructor with matching parameter names for STJ deserialization (hasLeft/hasRight/leftOrDefault/rightOrDefault) - Expose HasLeft, HasRight, LeftOrDefault, RightOrDefault as public properties with [JsonPropertyName] for clean JSON keys (isLeft/isRight/left/right) - Mark computed IsLeft, IsRight, IsBoth with [JsonIgnore] — derived from HasLeft/HasRight - Add TheseJsonTests covering serialize and round-trip for Left, Right, Both states Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
These<TError, TValue>:[JsonConstructor]+[JsonPropertyName]+[JsonIgnore]pattern — matches howResult,Maybe,Error, andAnyhandle STJ serialization. Public propertiesHasLeft/HasRight/LeftOrDefault/RightOrDefaultexposed for round-trip; computedIsLeft/IsRight/IsBothexcluded from JSON.ToResult()strict semantics fix:Bothstate now correctly returns failure (was silently succeeding before becauseIsLeftandIsBothare mutually exclusive flags).TheseJsonTests(7 tests), additionalTheseTestsforToResult/ToResultLenient/Partition,MaybeNewFeaturesTestsasync extensions,FakeDateTimeProviderTestsDateOnly/TimeOnly,RuleEngineFromPredicateTestsfactory overload.Readme.MDand.well-known/agent-skillsfor Maybe, Results, Rules, Time, These packages.Test plan
dotnet build— zero errors, zero warningsdotnet test— 3048 passed, 0 failedTheseJsonTests: serialize shape + round-trip for Left, Right, BothToResult/ToResultLenientstrict vs lenient semantics verified🤖 Generated with Claude Code