Skip to content

Check the public surface survives hostile input - #379

Merged
twcclegg merged 2 commits into
mainfrom
test/robustness
Aug 5, 2026
Merged

Check the public surface survives hostile input#379
twcclegg merged 2 commits into
mainfrom
test/robustness

Conversation

@twcclegg

@twcclegg twcclegg commented Aug 5, 2026

Copy link
Copy Markdown
Owner

The ported tests cover valid input, matching the Java originals. Nothing covers hostile input — and
this session found two crash bugs of that shape by accident: an unbounded stackalloc in the public
Normalize* methods (uncatchable StackOverflowException), and KeyNotFoundException geocoding an
Ascension Island number.

~30 inputs (lone surrogates, astral pairs, RTL overrides, NUL, non-ASCII digit scripts, characters
whose numeric value isn't a decimal digit, malformed RFC3966, 10k-char strings) go through Parse,
the normalizers, IsViablePhoneNumber, ExtractPossibleNumber, FindNumbers and
AsYouTypeFormatter, asserting nothing escapes but NumberParseException. Plus odd region codes and
a guard for the 200k-char case.

EveryRegionSurvivesTheReadOnlySurface runs geocoder, carrier, timezone and short-number lookups over
an example number from every region — the shape that would have caught the AC bug.

[Fact] over an array rather than [Theory]/[MemberData], because xunit serialises theory
arguments for discovery and lone surrogates don't survive it.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.01%. Comparing base (ab514e1) to head (b5e7e67).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #379   +/-   ##
=======================================
  Coverage   98.01%   98.01%           
=======================================
  Files          39       39           
  Lines       52818    52818           
  Branches     1105     1105           
=======================================
  Hits        51770    51770           
  Misses        795      795           
  Partials      253      253           

☔ 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.

Comment thread csharp/PhoneNumbers.Test/TestPublicApiRobustness.cs Dismissed
Comment thread csharp/PhoneNumbers.Test/TestPublicApiRobustness.cs Dismissed
@twcclegg
twcclegg merged commit 2466184 into main Aug 5, 2026
6 checks passed
@twcclegg
twcclegg deleted the test/robustness branch August 5, 2026 22:30
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.

2 participants