Skip to content

fix: preserve raw input for all-zero NANPA formatting - #517

Closed
wmundev wants to merge 1 commit into
mainfrom
fix/nanpa-raw-input-formatting-20261105
Closed

wmundev wants to merge 1 commit into
mainfrom
fix/nanpa-raw-input-formatting-20261105

Conversation

@wmundev

@wmundev wmundev commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Formatting an all-zero NANPA number for a call from another NANPA region now preserves its retained raw input, matching Java and the existing netstandard2.0 implementation. The modern span shortcut previously bypassed Format(NATIONAL)'s raw-input fallback, reformatted the zeros, and could append an extension that the fallback omits.

For example, parse 000-000-0000 with ParseAndKeepRawInput(..., "US"), then call FormatOutOfCountryCallingNumber(number, "US"): the old modern implementation returned 1 000 000 0000; Java and this fix return 1 000-000-0000.

Severity: P3, high confidence. This affects all-zero/invalid numbers accepted by parsing or constructed with the builder. The fix adds the missing fallback to the NANPA span shortcut and retains the current normal-number path. No public API, metadata, regex, dependency, or Java source changes.

Java parity evidence:

  • Java baseline: 33be5664343676b27761213d8f5500d682568ea7. formatOutOfCountryCallingNumber calls format(number, NATIONAL) for NANPA calls; format preserves raw input for zero national numbers. The existing upstream testFormatUSNumber covers this fallback.
  • Freshly compiled unchanged Java passed 20 focused checks: builder and parsed zero numbers, US/Bahamas origin, extension handling, 150/10,000-character raw strings, empty-raw and ordinary-number controls.
  • Differential corpus: 1,109 cases and 112,009 result entries per implementation across formatting overloads, custom patterns, carrier/mobile/out-of-country/original/alpha formatting, type/validity/possibility, area/destination codes, and truncation. Modern C# fixes all 12 affected entries; no previously matching entry changes to a mismatch. All three hash-verified C# target assemblies agree.
  • 111,963/112,009 entries agree with Java. The remaining 46 pre-existing differences are explicitly set zero-country-code presence semantics (setCountryCode(0) is present in Java, HasCountryCode is false in C#); deferred under the one-fix limit. This is not a whole-library parity claim.
  • Shipped metadata versions differ (C# 9.0.42 / Java 9.0.41). Comparisons instead consume the identical synthetic fixture, blob 14fdad223881d77c7679cbf6e6e0eecc52e036f5, through the original builders. No metadata contents were manually inspected or edited.

Validation:

  • Six new regressions failed before the fix on each modern TFM; full solution now passes 1,186 tests (542 library + 51 extensions per net8/net10), zero failures/skips.
  • All-TFM build: zero warnings/errors, including modern trim/AOT analyzers.
  • Release package validation against the published baseline passes. A clean compilation at the same external path reproduces the SHA256 of all three packaged library DLLs.
  • External BenchmarkDotNet 0.15.8 harness directly exercises the affected method (in-process, three warmups/five requested iterations, one launch each): normal 743.1 → 754.7 ns / 160 B; retained-raw zero 220.1 → 28.8 ns / 56 B; zero without raw 221.7 → 244.0 ns / 56 B. Samples include outlier removal; zero-without-raw is approximately 10% slower in this sample. No general throughput or no-regression claim; CI benchmarks remain to run.
  • Diff whitespace check recognizes the test file's existing CRLF convention. No Linux execution, runtime trim/AOT publishing, complete Java JUnit suite, concurrency proof, or exhaustive production-metadata comparison.

C# review baseline: 2a0bb649a22a518ee74133fdbcebcf39f8ebbbd4. Both baseline histories were unchanged since the preceding successful review; open upstream PRs were checked for duplicates.

@wmundev wmundev added the bug label Nov 5, 2026
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.08%. Comparing base (2a0bb64) to head (669c81b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #517   +/-   ##
=======================================
  Coverage   88.07%   88.08%           
=======================================
  Files          43       43           
  Lines        3891     3893    +2     
  Branches      993      994    +1     
=======================================
+ Hits         3427     3429    +2     
  Misses        264      264           
  Partials      200      200           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wmundev wmundev closed this Nov 5, 2026
@wmundev
wmundev deleted the fix/nanpa-raw-input-formatting-20261105 branch November 5, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant