Skip to content

test: route generic Parse(string) calls through StringOverloads, and guard it - #144

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
test/string-overloads-in-generic-sweeps
Oct 18, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
test/string-overloads-in-generic-sweeps

Conversation

@CaffeinatedCoder

@CaffeinatedCoder CaffeinatedCoder commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Closes #142

Builds on #143 (merged), whose StringOverloads it moves.

Problem

In generic code constrained on IRangeFactory, IValueSetFactory or ISpanParsable<TSelf> itself, TValue.Parse(text, provider) with a string argument binds to the span overload. Overload resolution removes the base IParsable<TSelf> candidate once the derived interface's span candidate applies, and the implicit string-to-span conversion makes it apply. 33 calls in ten test classes, conventions and integration, meant the string overload, so no generic sweep ever called a type's own Parse(string)/TryParse(string). Two of those classes landed on main after #142 was filed (CultureEntryPointProbeTests, LiteralCorpusProbeTests).

Change

  • StringOverloads moves from the conventions project to test/oracles/StringOverloads.cs and is linked into the conventions and integration projects, as Candidates.cs is. Every reported call now goes through it.
  • New StringOverloadConventionTests: it compiles every test project's sources with Roslyn (references: the framework plus this project's output), binds every Parse/TryParse invocation, and fails on one that reaches ISpanParsable<T>'s span overload with a string argument. It judges what the compiler chose, not the spelling, so a call on a concrete type (Int32Set.Parse(text, …)) isn't flagged. It runs in about 2 s.
  • New seed string-parse-localizes-decimal-separator, which breaks only DecimalRange.Parse(string).
  • docs/testing.md and docs/oracles.md describe the guard.

Tests

  • The guard is proven. Before the rewrite it listed all 33 calls. After it, putting back one call (TRange.Parse(literal, provider) in LiteralProviderContractTests) fails it, naming that file and line.
  • The reach is proven. With the new seed applied, LiteralProviderContractTests and CultureEntryPointProbeTests fail. On the parent commit, in a throwaway worktree, both pass with the seed applied (56/56), so they missed it before.
  • With the string overloads actually called now, the older sweeps find no disagreement. Today every string overload delegates to the same parser as its span sibling.
  • dotnet test test/CodoMetis.ValueRanges.Conventions.Tests: 299 passed. ShapeMatrixParityTests and LiteralCorpusProbeTests pass against a live server (55/55).
  • dotnet run tools/oracles.cs seeds: every seed caught, 55 (seed, oracle) pairs.

🤖 Generated with Claude Code

…guard it

Under a constraint deriving from ISpanParsable<TSelf> (IRangeFactory, IValueSetFactory, or
ISpanParsable itself), TValue.Parse(text, provider) with a string argument binds to the
span overload: overload resolution removes the base IParsable candidate once the derived
span candidate applies. 33 calls in ten test classes, conventions and integration, meant
the string overload and never called it.

- StringOverloads moves to test/oracles/ and is linked into the conventions and
  integration projects, as Candidates.cs is; every reported call goes through it.
- StringOverloadConventionTests binds every Parse/TryParse invocation in every test
  project with Roslyn and fails on one that reaches ISpanParsable's span overload with a
  string. Proven by reintroducing one call.
- Seed string-parse-localizes-decimal-separator breaks only DecimalRange.Parse(string):
  LiteralProviderContractTests and CultureEntryPointProbeTests catch it now and passed
  with it before this change.

Closes #142

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added tests Adds or changes tests only (oracles, harnesses); no library code package/nodatime Affects CodoMetis.ValueRanges.NodaTime area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges stacked Base is another open PR; merge in order, CI does not run until it targets main labels Oct 18, 2026
Base automatically changed from test/sibling-parity-sweeps to main October 18, 2026 05:41
@CaffeinatedCoder CaffeinatedCoder removed the stacked Base is another open PR; merge in order, CI does not run until it targets main label Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit fe80c9b into main Oct 18, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the test/string-overloads-in-generic-sweeps branch October 18, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges package/nodatime Affects CodoMetis.ValueRanges.NodaTime tests Adds or changes tests only (oracles, harnesses); no library code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic sweeps call the span overload when they mean Parse(string): ISpanParsable hides IParsable in overload resolution

1 participant