Repository navigation
test: route generic Parse(string) calls through StringOverloads, and guard it - #144
Merged
Merged
Conversation
…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]>
…-in-generic-sweeps
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.
Closes #142
Builds on #143 (merged), whose
StringOverloadsit moves.Problem
In generic code constrained on
IRangeFactory,IValueSetFactoryorISpanParsable<TSelf>itself,TValue.Parse(text, provider)with astringargument binds to the span overload. Overload resolution removes the baseIParsable<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 ownParse(string)/TryParse(string). Two of those classes landed onmainafter #142 was filed (CultureEntryPointProbeTests,LiteralCorpusProbeTests).Change
StringOverloadsmoves from the conventions project totest/oracles/StringOverloads.csand is linked into the conventions and integration projects, asCandidates.csis. Every reported call now goes through it.StringOverloadConventionTests: it compiles every test project's sources with Roslyn (references: the framework plus this project's output), binds everyParse/TryParseinvocation, and fails on one that reachesISpanParsable<T>'s span overload with astringargument. 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.string-parse-localizes-decimal-separator, which breaks onlyDecimalRange.Parse(string).docs/testing.mdanddocs/oracles.mddescribe the guard.Tests
TRange.Parse(literal, provider)inLiteralProviderContractTests) fails it, naming that file and line.LiteralProviderContractTestsandCultureEntryPointProbeTestsfail. On the parent commit, in a throwaway worktree, both pass with the seed applied (56/56), so they missed it before.dotnet test test/CodoMetis.ValueRanges.Conventions.Tests: 299 passed.ShapeMatrixParityTestsandLiteralCorpusProbeTestspass against a live server (55/55).dotnet run tools/oracles.cs seeds: every seed caught, 55 (seed, oracle) pairs.🤖 Generated with Claude Code