Skip to content

Add InternalAPI tracking to all projects with PublicAPI#9752

Merged
Evangelink merged 7 commits into
mainfrom
dev/add-internalapi-tracking
Jul 9, 2026
Merged

Add InternalAPI tracking to all projects with PublicAPI#9752
Evangelink merged 7 commits into
mainfrom
dev/add-internalapi-tracking

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

Adds InternalAPI tracking 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 how PublicAPI.Shipped.txt / PublicAPI.Unshipped.txt work today.

What changed

  • New InternalAPI files for all 25 projects with a PublicAPI folder, 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.
  • Wired into each .csproj as AdditionalFiles, with the same Condition expressions as the corresponding PublicAPI entries.
  • Baselined the current internal API surface into InternalAPI.Shipped.txt (leaving Unshipped empty), 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.ps1 now processes InternalAPI files in addition to PublicAPI (parameterized prefix; also fixes a PublicApiPublicAPI glob casing bug).
  • .editorconfig enables the internal-API analyzer diagnostics (RS0051–RS0061), which is what makes this tracking active.

Verification

Authoritative --no-incremental / /t:Rebuild builds 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.16299 TFM 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

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>
Copilot AI review requested due to automatic review settings July 8, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PublicApiPublicAPI 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 -Include array pattern ("PublicAPI.Shipped.txt", "InternalAPI.Shipped.txt") correctly invokes Set-AsShipped once per matching file with the right prefix.
  • No issues with cross-TFM correctness, naming conventions, or scope creep.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 431.7 AIC · ⌖ 8.36 AIC · ⊞ 7.3K ·

Comment thread src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Shipped.txt Outdated
Comment thread .editorconfig
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>
Copilot AI review requested due to automatic review settings July 8, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 97/99 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 221.4 AIC · ⌖ 7.47 AIC · ⊞ 7.3K ·

Comment thread .editorconfig
…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>
Copilot AI review requested due to automatic review settings July 8, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 97/99 changed files
  • Comments generated: 0 new
  • Review effort level: Low

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 136.9 AIC · ⌖ 7.15 AIC · ⊞ 7.3K ·

Comment thread src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Shipped.txt Outdated
…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>
Copilot AI review requested due to automatic review settings July 8, 2026 21:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 98/100 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 335.7 AIC · ⌖ 7.69 AIC · ⊞ 7.3K ·

Comment thread src/Platform/Microsoft.Testing.Platform/InternalAPI/InternalAPI.Shipped.txt Outdated
…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>
Copilot AI review requested due to automatic review settings July 8, 2026 21:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 99/101 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🔍 Build Failure Analysis

Summary — All 151 build errors are RS0051 (Internal API analyzer: "Symbol is not part of the declared API") in MSTest.TestAdapter.csproj, caused by a merge conflict with main — the PR's InternalAPI.Shipped.txt baseline was generated from an older main that didn't yet contain the Native MTP integration types.

Root cause: PR branch is stale — missing new TestingPlatformAdapter symbols from main

The PR was branched from commit 1300ae0 (Jul 8, 14:52). After branching, several PRs landed on main that added new internal types to src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/:

PR Commit Added
#9743 18c741f Phases 3–5: MSTestFilterContext, MSTestRunContext, MSTestDiscoveryContext, MSTestFilterContextBase
#9748 279d3b8 Phase 6a: MSTestFrameworkHandle, MSTestRunSettings, MSTestRunSettingsConfigurationProvider, MSTestRunSettingsEnvironmentVariableProvider, MSTestRunSettingsCommandLineOptionsProvider, MSTestTestRunParametersCommandLineOptionsProvider, MSTestTestCaseFilterCommandLineOptionsProvider, IMSTestTrxReportCapability, MSTestTestFramework
#9749 cf0dea9 Follow-up simplification to the above

When CI merges the PR head (d2d9f5f) into latest main (52192c9), the merged code includes both:

  1. ✅ The InternalAPI tracking infrastructure (from this PR)
  2. ❌ The new TestingPlatformAdapter symbols (from main) — which are not declared in InternalAPI.Shipped.txt or InternalAPI.Unshipped.txt

This triggers 151 RS0051 errors for undeclared internal API symbols.

Affected types (12 types + their members = 151 errors total):

  • IMSTestTrxReportCapability
  • MSTestFilterContextBase
  • MSTestRunContext
  • MSTestDiscoveryContext
  • MSTestFrameworkHandle
  • MSTestRunSettings
  • MSTestRunSettingsConfigurationProvider
  • MSTestRunSettingsEnvironmentVariableProvider
  • MSTestRunSettingsCommandLineOptionsProvider
  • MSTestTestCaseFilterCommandLineOptionsProvider
  • MSTestTestRunParametersCommandLineOptionsProvider
  • MSTestTestFramework

Proposed fix

Rebase the PR onto current main and regenerate the baseline:

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

This will add the newly-introduced symbols to src/Adapter/MSTest.TestAdapter/InternalAPI/InternalAPI.Shipped.txt (since the intent is to baseline the current surface).

Note: The same rebase should be verified against the UWP-specific InternalAPI/uwp/InternalAPI.Shipped.txt if those TFMs include the new TestingPlatformAdapter types.


Build overview
  • Build status: FAILED
  • Duration: 200.1s
  • MSBuild: 18.8.0-preview-26302-115
  • Projects: 49 total; 3 failed (Build.proj, NonWindowsTests.slnf, MSTest.TestAdapter.csproj)
  • Errors: 151 (all RS0051)
  • Warnings: 0
  • Configuration: Debug, Linux (non-Windows TFMs only)
  • Failed target: CoreCompile (Csc task) in MSTest.TestAdapter.csproj
All MSBuild errors (151 — all RS0051)
Code File Line Symbol (abbreviated)
RS0051 IMSTestTrxReportCapability.cs 14 IMSTestTrxReportCapability
RS0051 IMSTestTrxReportCapability.cs 16 IMSTestTrxReportCapability.IsTrxEnabled
RS0051 MSTestFilterContext.cs 27 MSTestFilterContextBase
RS0051 MSTestFilterContext.cs 32 MSTestFilterContextBase..ctor(...)
RS0051 MSTestFilterContext.cs 51 MSTestFilterContextBase.RunSettings
RS0051 MSTestFilterContext.cs 72 MSTestFilterContextBase.GetTestCaseFilter(...)
RS0051 MSTestFilterContext.cs 192 MSTestRunContext
RS0051 MSTestFilterContext.cs 194 MSTestRunContext..ctor(...)
RS0051 MSTestFilterContext.cs 201–211 MSTestRunContext properties
RS0051 MSTestFilterContext.cs 218–220 MSTestDiscoveryContext
RS0051 MSTestFrameworkHandle.cs 20–33 MSTestFrameworkHandle + members
RS0051 MSTestRunSettings.cs 25–60 MSTestRunSettings + members
RS0051 MSTestRunSettingsConfigurationProvider.cs 19–35 MSTestRunSettingsConfigurationProvider + members
RS0051 MSTestRunSettingsEnvironmentVariableProvider.cs 21–103 MSTestRunSettingsEnvironmentVariableProvider + members
RS0051 MSTestRunSettingsCommandLineOptionsProvider.cs 21–31 MSTestRunSettingsCommandLineOptionsProvider + members
RS0051 MSTestTestCaseFilterCommandLineOptionsProvider.cs 17–21 MSTestTestCaseFilterCommandLineOptionsProvider + members
RS0051 MSTestTestRunParametersCommandLineOptionsProvider.cs 18–27 MSTestTestRunParametersCommandLineOptionsProvider + members
RS0051 MSTestTestFramework.cs 41 MSTestTestFramework

All files are under src/Adapter/MSTest.TestAdapter/TestingPlatformAdapter/ — these exist in main but not in the PR branch.


🤖 Generated by the Build Failure Analysis workflow using (a href="(dev.azure.com/redacted) · commit d2d9f5f

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 321.4 AIC · ⌖ 7.02 AIC · ⊞ 7.3K · [◷]( · )

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated content by GitHub Copilot. Generated by the Build Failure Analysis workflow. · 321.4 AIC · ⌖ 7.02 AIC · ⊞ 7.3K ·

Copilot AI added 2 commits July 9, 2026 00:48
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>
Copilot AI review requested due to automatic review settings July 8, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 99/101 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@Evangelink
Evangelink enabled auto-merge (squash) July 9, 2026 09:20
@Evangelink
Evangelink disabled auto-merge July 9, 2026 09:20
@Evangelink
Evangelink enabled auto-merge (squash) July 9, 2026 09:20
@Evangelink
Evangelink merged commit 1e92d89 into main Jul 9, 2026
89 checks passed
@Evangelink
Evangelink deleted the dev/add-internalapi-tracking branch July 9, 2026 09:21
Evangelink added a commit that referenced this pull request Jul 9, 2026
…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>
Evangelink added a commit that referenced this pull request Jul 9, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants