Skip to content

feat(these): JSON serialization, ToResult semantics fix, test coverage#40

Merged
senrecep merged 4 commits into
mainfrom
feat/these-json-and-coverage
May 31, 2026
Merged

feat(these): JSON serialization, ToResult semantics fix, test coverage#40
senrecep merged 4 commits into
mainfrom
feat/these-json-and-coverage

Conversation

@senrecep
Copy link
Copy Markdown
Owner

Summary

  • JSON support for These<TError, TValue>: [JsonConstructor] + [JsonPropertyName] + [JsonIgnore] pattern — matches how Result, Maybe, Error, and Any handle STJ serialization. Public properties HasLeft/HasRight/LeftOrDefault/RightOrDefault exposed for round-trip; computed IsLeft/IsRight/IsBoth excluded from JSON.
  • ToResult() strict semantics fix: Both state now correctly returns failure (was silently succeeding before because IsLeft and IsBoth are mutually exclusive flags).
  • Test coverage: TheseJsonTests (7 tests), additional TheseTests for ToResult/ToResultLenient/Partition, MaybeNewFeaturesTests async extensions, FakeDateTimeProviderTests DateOnly/TimeOnly, RuleEngineFromPredicateTests factory overload.
  • Docs/Skills: Updated Readme.MD and .well-known/agent-skills for Maybe, Results, Rules, Time, These packages.

Test plan

  • dotnet build — zero errors, zero warnings
  • dotnet test — 3048 passed, 0 failed
  • TheseJsonTests: serialize shape + round-trip for Left, Right, Both
  • ToResult/ToResultLenient strict vs lenient semantics verified

🤖 Generated with Claude Code

senrecep and others added 3 commits May 31, 2026 14:53
… 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
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@senrecep senrecep merged commit 60c376b into main May 31, 2026
9 checks passed
@senrecep senrecep deleted the feat/these-json-and-coverage branch May 31, 2026 13:39
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.

1 participant