style: minor idiomatic cleanups in protobuf-style data model classes - #415
Merged
Conversation
Convert `== null`/`!= null` guard clauses and `x as T; if (x == null)` casts to `is null`/`is not T x` pattern matching in PhoneNumberDesc, NumberFormat, PhoneMetadataCollection, and Phonemetadata. Purely local, behavior-preserving idiom swaps — the Builder/protobuf-mirroring structure of these hand-ported message classes is untouched.
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (33.33%) 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 #415 +/- ##
==========================================
+ Coverage 87.42% 87.43% +0.01%
==========================================
Files 41 41
Lines 3856 3853 -3
Branches 990 991 +1
==========================================
- Hits 3371 3369 -2
+ Misses 283 282 -1
Partials 202 202 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
📊 Benchmark Results
PR branch
PR base
|
This was referenced Aug 26, 2026
This was referenced Aug 28, 2026
Closed
Open
Merged
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 an ongoing sweep applying idiomatic-C# readability cleanups (same spirit as #409) across the codebase.
Phonemetadata.cs,PhoneNumberDesc.cs,NumberFormat.cs, andPhoneMetadataCollection.csare hand-ported equivalents of Java's protobuf-generated message classes —#nullable disable,[GeneratedCode], a rigid Builder pattern. Deliberately left the Builder/protobuf-mirroring structure untouched here (no records, no init-only properties, no restructuring) since that would fight the intentional generated-code parity and make future re-generation/comparison harder.Only trivial, purely local idioms applied:
== null/!= nullguard clauses →is null/is not null(mechanical, ~75 occurrences across the four files)var other = obj as T; if (other == null) return false;→if (obj is not T other) return false;in the fourEquals(object)overrides (same pattern already used forMetadataFilter.Equalsin style: small idiomatic-C# cleanups (no behavior change) #409)No behavior change.
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