Add InternalAPI tracking to all projects with PublicAPI#9752
Conversation
Introduce InternalAPI.Shipped.txt / InternalAPI.Unshipped.txt files (mirroring the existing PublicAPI folder layout, including framework-specific subfolders) for every source project that already tracks its public API surface, and wire them into each project as AdditionalFiles so the Roslyn public/internal API analyzers (RS0051-RS0061) validate the internal surface too. - Baseline the current internal API surface into InternalAPI.Shipped.txt (Unshipped left empty), matching the repo's post-release PublicAPI state. - Update eng/mark-shipped.ps1 to also process InternalAPI files. - .editorconfig enables the internal-API analyzer diagnostics (RS0051-RS0061). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Note
🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.
Review Summary
Clean, well-structured infrastructure PR. All 22 review dimensions assessed — no blocking issues found.
Key Findings
| Dimension | Assessment |
|---|---|
| Completeness | ✅ All 25 projects with PublicAPI tracking now have matching InternalAPI tracking. Folder structures (TFM subfolders, root-level files) mirror exactly. |
.editorconfig |
✅ RS0051–RS0061 correctly enabled. RS0057 (oblivious types) reasonably suppressed for polyfill/compiler-generated code. |
eng/mark-shipped.ps1 |
✅ Correctly parameterized via $Prefix. The PublicApi → PublicAPI casing fix resolves a latent bug on case-sensitive filesystems (Linux + PowerShell 7). The regex '\.Shipped\.txt$' correctly extracts the prefix. |
.csproj wiring |
✅ AdditionalFiles entries use the same Condition expressions as their corresponding PublicAPI entries. MSBuild/VSTestBridge correctly reference root-level files; other projects use InternalAPI/ subfolders. |
| InternalAPI content | ✅ Shipped files are populated; Unshipped files all contain only #nullable enable. TPEXP/MSTESTEXP prefixed entries are correctly placed for internal (not public) members. Compiler-emitted polyfill types (EmbeddedAttribute, CompilerLoweringPreserveAttribute, etc.) are expected per the analyzer's code-fix output. |
| Backward Compatibility | ✅ No public API surface changes. New analyzer warnings (RS0051+) are additive and enforcement-only for maintainers. |
Notes
- The
Write-Host "Processing $shippedFilePath"improvement gives better diagnostic output (shows full path including prefix) — nice QoL improvement. - The
Get-ChildItem -Includearray pattern ("PublicAPI.Shipped.txt", "InternalAPI.Shipped.txt") correctly invokesSet-AsShippedonce per matching file with the right prefix. - No issues with cross-TFM correctness, naming conventions, or scope creep.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 431.7 AIC · ⌖ 8.36 AIC · ⊞ 7.3K · ◷
CI surfaced RS0051 failures because generated code was baked into the InternalAPI files: BuildInfo version constants embed the build version (e.g. "1.0.0-ci" on CI vs "2.4.0-dev" locally), plus RESX-generated resource accessors and *.g.cs content-file sources. - .editorconfig: disable the internal API analyzers (RS0051-RS0061) for generated code (*.g.cs and artifacts/obj/**/*.cs). - Regenerate InternalAPI baselines without the version-stamped / generated symbols, while keeping real auto-generated-marked API (Polyfills attributes). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 221.4 AIC · ⌖ 7.47 AIC · ⊞ 7.3K · ◷
…TestBridge The regenerated InternalAPI.Shipped.txt baselines for these three extensions were missing the shared polyfill symbols (EmbeddedAttribute, CompilerLoweringPreserveAttribute, Polyfills.Polyfill OS helpers, HashHelpers), causing RS0051 build failures. Added them in canonical sorted order to match the other tracked projects. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 136.9 AIC · ⌖ 7.15 AIC · ⊞ 7.3K · ◷
…nal API ProtocolVersion = PlatformVersion.Version inlines the build-time version stamp, which differs by environment (2.4.0-dev locally vs 2.4.0-ci on CI). Tracking its literal value in InternalAPI.Shipped.txt made the internal API analyzer non-deterministic and failed CI (Linux Debug) with RS0051. Suppress RS0051 at the declaration and drop the version-valued baseline entry, consistent with the PR's exclusion of version-stamped constants. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 335.7 AIC · ⌖ 7.69 AIC · ⊞ 7.3K · ◷
…onst The raw string literal const embeds the source file's line endings (CRLF on Windows where the baseline was generated, LF on Linux CI), so its compile-time value is non-deterministic across platforms and failed CI (Linux Debug) with RS0051. Suppress RS0051 at the declaration and drop the CRLF-valued baseline entry, matching the ProtocolVersion fix. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🔍 Build Failure AnalysisSummary — All 151 build errors are Root cause: PR branch is stale — missing new TestingPlatformAdapter symbols from mainThe PR was branched from commit
When CI merges the PR head (
This triggers 151 Affected types (12 types + their members = 151 errors total):
Proposed fixRebase the PR onto current git fetch origin main
git rebase origin/main
# Regenerate the InternalAPI baseline for the TestAdapter
dotnet format analyzers --diagnostics RS0051 --include-generated \
--project src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csprojThis will add the newly-introduced symbols to
Build overview
All MSBuild errors (151 — all RS0051)
All files are under 🤖 Generated by the Build Failure Analysis workflow using (a href="(dev.azure.com/redacted) · commit d2d9f5f
|
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 321.4 AIC · ⌖ 7.02 AIC · ⊞ 7.3K · ◷
Merging current main brought in the Phase 6a native MTP adapter (dotnet/testfx#9748) TestingPlatformAdapter types, whose internal API was not in the baseline, causing 75 RS0051 errors per TFM in the PR merge build. Added the 75 entries to MSTest.TestAdapter's InternalAPI.Shipped.txt in canonical sorted order. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…RS0051 Microsoft.Testing.Platform's BaseSerializer.ReadFields and WriteListPayload<T> (added by #9774) were never added to InternalAPI.Unshipped.txt, so once #9752 enabled RS0051 internal-API enforcement both landed on main and left main red. This foundational project's failure cascades and blocks the whole build, so track the two methods in the base InternalAPI.Unshipped.txt (the diagnostic fires on netstandard2.0 too, so it belongs in the base file, not net/). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ternalAPI With Microsoft.Testing.Platform now building, MSTest.TestAdapter compiles and surfaces its own RS0051 failures for the internal PlatformServicesConfigurationAdapter type (added while InternalAPI tracking was being rolled out in #9752). Declare the type, its constructor and indexer in the non-UWP InternalAPI.Unshipped.txt so the adapter builds. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
Adds
InternalAPItracking to every source project that already tracks a public API surface, so the Roslyn public/internal API analyzers (RS0051–RS0061) validate the internal surface too — mirroring howPublicAPI.Shipped.txt/PublicAPI.Unshipped.txtwork today.What changed
InternalAPIfiles for all 25 projects with aPublicAPIfolder, mirroring the exact layout — including framework-specific subfolders (net/,net9.0/,net462/,net8.0-windows*,uwp/,uap10.0.16299/, …) and root-level files for the two projects (MSBuild,VSTestBridge) that keep API files at project root..csprojasAdditionalFiles, with the sameConditionexpressions as the corresponding PublicAPI entries.InternalAPI.Shipped.txt(leavingUnshippedempty), matching the repo's post-release PublicAPI state. Entries were generated with the analyzer's own code fix (dotnet format analyzers --diagnostics RS0051 --include-generated), which also captures RESX-generated resource classes and compiler-emitted attributes.eng/mark-shipped.ps1now processesInternalAPIfiles in addition toPublicAPI(parameterized prefix; also fixes aPublicApi→PublicAPIglob casing bug)..editorconfigenables the internal-API analyzer diagnostics (RS0051–RS0061), which is what makes this tracking active.Verification
Authoritative
--no-incremental//t:Rebuildbuilds across all reachable TFMs (netstandard2.0, net8.0, net9.0, net462, net8.0-windows, net9.0-windows) for all 25 projects report 0 RS0051. PublicAPI files are untouched.Note
The
uap10.0.16299TFM cannot be compiled in every environment (needs the UWP/Windows XAML workload); its internal deltas were populated from build output and verified not to regress the shared-folder ModernUwp (net9.0-windows) leg.Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com