Skip to content

fix: Float64Range/Float32Range.FormatValue read an empty format as no format (#655) - #657

Merged
CaffeinatedCoder merged 3 commits into
mainfrom
fix/655-float-empty-format
Nov 30, 2026
Merged

CaffeinatedCoder merged 3 commits into
mainfrom
fix/655-float-empty-format

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #655

Problem

Float64Range.FormatValue and Float32Range.FormatValue tested format is null, where their set siblings (Float64Set, Float32Set) and every other type read an empty format as none. So Float64Range.FormatValue(1.5, "", de-DE) wrote 1,5, and FormatValue(1e300, "", invariant) wrote 1E+300 where float8out writes 1e+300. Nothing threw. The literal (ToString, interpolation, JSON, EF text) was never affected, because it turns "" into null before it calls FormatValue. Only a direct FormatValue call was.

SpanFormatContractTests (#41, PR #654) found it by comparing TryFormatValue with FormatValue. The existing oracle missed it because it checked only the invariant provider and the range bounds, values on which .NET's text and float8out agree.

Change

  • Float64Range.cs, Float32Range.cs: string.IsNullOrEmpty(format), as the sets have it.
  • LiteralProviderContractTests.EveryFormatValue_ReadsAnEmptyFormat_AsItsDefault now sweeps the five providers as well as the invariant one, and the set probes (2^-25, 1e300, 0.1f, 1e6f) as well as the range bounds.
  • Fragment changes/655.md under Breaking: ChangelogConventionTests refuses a Changed answers section in a major, and pr-hygiene.sh puts a silent fix into a major under Breaking. Migration section "Check FormatValue on the float ranges with an empty format", with a bullet in the v10.x list.

Tests

  • Fix reverted: EveryFormatValue_ReadsAnEmptyFormat_AsItsDefault fails for both float ranges under de-DE, sv-SE, fa-IR and ar-SA (null -> '-1.5', "" -> '-1,5'). With the fix it passes.
  • Seed float-range-reads-an-empty-format-as-explicit (oracle LiteralProviderContractTests), generated from the committed tree. OracleSeedTests is green.
  • Conventions 469/469 locally.

10.x: the same code is on release/10.x (Float64Range.cs:329, Float32Range.cs:330). Under the silent rule a port ships as a 10.x minor with a Changed answers row. Whether to port is steering's call; this PR doesn't include one.

🤖 Generated with Claude Code

CaffeinatedCoder and others added 2 commits November 30, 2026 19:50
…s no format (#655)

Both tested format is null, where their set siblings and every other type read an
empty format as none, so FormatValue(1.5, "", de-DE) wrote 1,5 and
FormatValue(1e300, "", invariant) wrote 1E+300. The literal never reached it.

EveryFormatValue_ReadsAnEmptyFormat_AsItsDefault now sweeps the five providers and the
set probes as well as the range bounds; without the fix it fails for both types.

Found-By: SpanFormatContractTests (#41), comparing TryFormatValue with FormatValue
Defect-Class: clone divergence between sibling FormatValue overrides

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Nov 30, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference breaking Changes an answer or a signature — needs a major labels Nov 30, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 8f453ed into main Nov 30, 2026
16 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/655-float-empty-format branch November 30, 2026 18:56
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 breaking Changes an answer or a signature — needs a major bug Something isn't working found-by/oracle Found by the generated-oracle machinery (claims × API surfaces) package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Float64Range/Float32Range.FormatValue read an empty format as an explicit one

1 participant