Skip to content

test: exclude the ported protobuf-style Builder classes from coverage - #410

Merged
twcclegg merged 2 commits into
mainfrom
test/exclude-builder-boilerplate-from-coverage
Aug 24, 2026
Merged

test: exclude the ported protobuf-style Builder classes from coverage#410
twcclegg merged 2 commits into
mainfrom
test/exclude-builder-boilerplate-from-coverage

Conversation

@twcclegg

Copy link
Copy Markdown
Owner

Summary

PhoneMetadata/Builder, PhoneNumber/Builder, NumberFormat/Builder, PhoneNumberDesc/Builder, and PhoneMetadataCollection/Builder are dozens of near-identical Get/Set/Has/Clear blocks per field (1400+ lines for PhoneMetadata/Builder alone), so their sheer size swamped the project coverage percentage without the per-field wiring itself carrying real verification value.

Their one piece of actual behavior — MergeFrom/Build/BuildPartial — is already exercised by TestBuildMetadataFromXml.cs, the only place these builders run outside the build-time metadata pipeline (the default load path reads pre-built binaries, not XML, so the rest of the suite never touches them). Excluding them locally: overall line-rate went from 0.8144 to 0.8856, confirming they were the drag rather than a real gap.

Verified empirically against coverlet's actual filter matching rather than assumed — [Module]Type.Builder and [Module]Type/Builder both silently matched nothing; [PhoneNumbers]*Builder is what actually excludes the five nested types (confirmed via a before/after class-list diff) without touching the outer message classes.

Test plan

  • dotnet build csharp — clean, 0 warnings/errors, all TFMs
  • dotnet test csharp/PhoneNumbers.slnx -p:TargetFrameworks=net10.0 — 432/432 passing
  • Verified via a before/after cobertura class-list diff that exactly the 5 intended *Builder types are excluded and nothing else (PhoneMetadata, PhoneNumberUtil, etc. unaffected)

PhoneMetadata/Builder, PhoneNumber/Builder, NumberFormat/Builder,
PhoneNumberDesc/Builder, and PhoneMetadataCollection/Builder are dozens of
near-identical Get/Set/Has/Clear blocks per field (1400+ lines for
PhoneMetadata/Builder alone), so their sheer size swamped the project
coverage percentage without the per-field wiring carrying any real
verification value.

Their one piece of actual behavior - MergeFrom/Build/BuildPartial - is
already exercised by TestBuildMetadataFromXml.cs, the only place these
builders run outside the build-time metadata pipeline (the default load
path reads pre-built binaries, not XML, so the rest of the suite never
touches them). Excluding them locally: overall line-rate went from 0.8144
to 0.8856, confirming they were the drag rather than a real gap.

Verified empirically against coverlet's actual filter matching rather than
assumed - [Module]Type.Builder and [Module]Type/Builder both silently
matched nothing; [PhoneNumbers]*Builder is what actually excludes the five
nested types (confirmed via a before/after class-list diff) without
touching the outer message classes.
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.79%. Comparing base (a40ff86) to head (9cea772).

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #410       +/-   ##
===========================================
+ Coverage   77.26%   87.79%   +10.53%     
===========================================
  Files          39       39               
  Lines        4548     3810      -738     
  Branches     1129      971      -158     
===========================================
- Hits         3514     3345      -169     
+ Misses        783      274      -509     
+ Partials      251      191       -60     

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

The "*Builder" wildcard matched any type in the assembly whose name
simply ends in "Builder", not just the five intended nested builders -
a future genuinely-tested class named e.g. RequestBuilder would have
been silently swept into the same exclusion with no CI signal.

Verified empirically rather than assumed: coverlet's XPlat data
collector doesn't match an exact CLR ("Outer+Builder") or
cobertura-report ("Outer/Builder") qualified nested-type name in this
setup - only a wildcard does, confirmed by actually collecting
coverage and checking coverage.cobertura.xml, since a wrong filter
here fails silently (no build/test error, the type is just quietly
back in the coverage count). Landed on "Outer*Builder" per type:
narrower than the blanket wildcard, and confirmed via the same method
to exclude exactly the five intended types (plus the pre-existing
CountryCodeToRegionCodeMap exclusion) while leaving their enclosing
outer types counted, matching pre-change totals exactly
(7151/8078 lines covered/valid, net10.0).
@twcclegg

Copy link
Copy Markdown
Owner Author

Fixed: scoped the exclusion to the five intended types (Outer*Builder per type) instead of a blanket *Builder. Note for future reference: coverlet's XPlat collector doesn't match an exact Outer+Builder/Outer/Builder qualified nested-type name here — only the wildcard form works, verified by actually collecting coverage and inspecting coverage.cobertura.xml (a wrong filter fails silently, no build/test error). Confirmed identical totals to the original wildcard (7151/8078 lines, net10.0).

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.

1 participant