style: idiomatic cleanups in PhoneNumberUtil.cs - #418
Merged
Conversation
- == null / != null -> is null / is not null throughout, matching the pattern already used in most of this file and PR #409. - Constant-string .Equals(...) calls (REGION_CODE_FOR_NON_GEO_ENTITY, UNKNOWN_REGION, an empty-string mobile-token check, and a NormalizeHelper() result comparison) -> == / !=. - Fixed a stray K&R-brace IsPhoneContextValid to match the file's Allman convention. No behavior change.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (68.18%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #418 +/- ##
==========================================
- Coverage 87.42% 87.34% -0.09%
==========================================
Files 41 41
Lines 3856 3855 -1
Branches 990 992 +2
==========================================
- Hits 3371 3367 -4
- Misses 283 284 +1
- Partials 202 204 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
📊 Benchmark Results
PR branch
PR base
|
FormatInOriginalFormat was missing the null guard on formatRule that upstream Java has before the default-case switch dereferences it (formatRule can still be null here per Java's own comment on this edge case). MaybeStripNationalPrefixAndCarrierCode's numberLength fallback dereferenced `number` directly while the rest of the method already treats it as nullable (`number?.Remove(...)`, `number is not null`), so make that one access consistent with the same guard. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks
3 tasks
This was referenced Aug 28, 2026
Closed
Closed
Merged
This was referenced Sep 7, 2026
Closed
Open
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.
Summary
Part of the ongoing idiomatic-C# cleanup sweep (see #409). Scoped to
PhoneNumberUtil.csonly — the largest file in the repo, so kept conservative: only unambiguous, behavior-preserving wins.== null/!= null->is null/is not nullthroughout (33 sites)..Equals(...)calls ->==/!=(REGION_CODE_FOR_NON_GEO_ENTITY,UNKNOWN_REGION, an empty-string mobile-token check, and aNormalizeHelper()result comparison). LeftPhoneNumber.Equals(...)object-equality calls untouched — those are genuine value equality, not string comparisons.IsPhoneContextValidto match the file's Allman convention.Not fixing bugs, not chasing Java parity gaps (that was #408), not restructuring algorithms or renaming public members.
Test plan
dotnet build csharp/PhoneNumbers.slnx— 0 warnings (TreatWarningsAsErrors)dotnet test csharp/PhoneNumbers.Test/PhoneNumbers.Test.csproj— 414/414 passing on net8.0 and net10.0