Repository navigation
[fix] Document IVT matrix sync requirement and external consumers in Friends.csΒ #16527
Description
Tip
Your pull request is ready to create! π β
Everything is OKβthe changes have been pushed to branch fix/issue-16524-f4c357a2cbe01440. Please review the changes, including any protected files, before creating the pull request.
The original pull request description is below.
π€ This is an automated fix generated in response to issue #16524 (Repository Quality Improvement: InternalsVisibleTo Duplication & Maintenance Fragility), addressing Tasks 1, 3, and 4 from the report.
Root cause
InternalsVisibleTo (IVT) grants for the ~18 testhost.* TFM/architecture variants are hand-duplicated verbatim between src/Microsoft.TestPlatform.CoreUtilities/Friends.cs and src/Microsoft.TestPlatform.CrossPlatEngine/Friends.cs, with no comment cross-referencing the two files or the TestHostAllTargetFrameworks property in Directory.Build.props that drives the TFM list. A future TFM change (as happened when net481 was added) requires synchronized manual edits with no build-time check, and a missed entry fails silently with an unhelpful CS0122 far from the root cause.
Separately, src/Microsoft.TestPlatform.ObjectModel/Friends.cs and src/vstest.console/Friends.cs grant IVT access to assemblies that live outside this repository (in-the-box Visual Studio components: Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration, MSAppContainerAdapter, MSPhoneAdapter, Microsoft.VisualStudio.TestWindow.Host). Nothing marks them as external/intentional, so a future dead-code cleanup pass could mistakenly flag and remove them.
Fix
Comment-only changes, no behavior change:
- Task 1 β Added a header comment above the
testhost.*TFM/arch matrix in bothCoreUtilities/Friends.csandCrossPlatEngine/Friends.cs, cross-referencing the sibling file and noting it must stay in sync withTestHostAllTargetFrameworksinDirectory.Build.props(currentlynet462;net8.0;net47;net471;net472;net48;net481, timesx86/arm64/neutral). - Task 4 β Added an inline comment explaining the intentionally asymmetric
testhost.UnitTestsgrant inCoreUtilities/Friends.cs(not present inCrossPlatEngine/Friends.cs): onlyCoreUtilities' internals are unit-tested directly fromtesthost.UnitTests;CrossPlatEngineinternals are exercised viaCrossPlatEngine.UnitTestsinstead. - Task 3 β Annotated the out-of-repo Visual Studio IVT consumers in
ObjectModel/Friends.csandvstest.console/Friends.cswith a one-line comment so they aren't mistaken for dead code by a future cleanup effort (automated or manual).
Task 2 (a unit test asserting IVT/TFM matrix consistency) and Task 5 (exploring a generator/MSBuild-item-based consolidation) are larger, riskier changes left as follow-up per the report's own priority/effort guidance (both rated Medium/Large effort vs. the Small-effort documentation tasks done here).
Test
This is a documentation/comment-only change with no compilable-behavior difference, so no new automated test is applicable β the same reasoning the report itself uses when scoping Task 1/3/4 as documentation-only. Verified via dotnet build -c Release (no warnings/errors introduced) for all four modified projects:
Microsoft.TestPlatform.CoreUtilitiesMicrosoft.TestPlatform.CrossPlatEngineMicrosoft.TestPlatform.ObjectModelvstest.console
Note
GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
fix/issue-16524-f4c357a2cbe01440and are ready to review.
To fix the permissions issue, go to Settings β Actions β General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (42 of 117 lines)
From bf3a8cbb92e4c16d57ed4fbe58171894b84f1119 Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 8c8561a58644a504b2b8a0a6e60142e7761b0cd7
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Mon, 28 Sep 2026 12:57:10 +0000
Subject: [PATCH] Document IVT matrix sync requirement and external consumers
in Friends.cs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Addresses Tasks 1, 3, and 4 from issue #16524 (InternalsVisibleTo
duplication & maintenance fragility quality-improvement report).
- CoreUtilities/Friends.cs and CrossPlatEngine/Friends.cs now carry a
header comment above the testhost.* TFM/arch matrix cross-referencing
the sibling file and TestHostAllTargetFrameworks in
Directory.Build.props, so a future TFM change is a documented,
discoverable two-file edit.
- The asymmetric testhost.UnitTests grant in CoreUtilities/Friends.cs
(absent from CrossPlatEngine/Friends.cs) is now explained inline.
- ObjectModel/Friends.cs and vstest.console/Friends.cs annotate the
IVT entries that reference out-of-repo Visual Studio consumers
(VSTestIntegration, MSAppContainerAdapter, MSPhoneAdapter,
TestWindow.Host) so future cleanup passes don't mistake them for
dead code.
No behavior change; comment-only edits verified with Release builds of
CoreUtilities, CrossPlatEngine, ObjectModel, and vstest.console.
π€ Automated fix for #16524.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
src/Microsoft.TestPlatform.CoreUtilities/Friends.cs | 8 ++++++++
src/Microsoft.TestPlatform.CrossPlatEngine/Friends.cs | 5 +++++
src/Microsoft.TestPlatform.ObjectModel/Friends.cs | 6 ++++++
src/vstest.console/Friends.cs | 2 ++
4 files changed, 21 insertions(+)
diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Friends.cs b/src/Microsoft.TestPlatform.CoreUtilities/Friends.cs
index 542dbfe..f4bb431 100644
--- a/src/Microsoft.TestPlatform.CoreUtilities/Fr
... (truncated)Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
github.comsouthcentralus0.in.applicationinsights.azure.com
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "github.com"
- "southcentralus0.in.applicationinsights.azure.com"See Network Configuration for more information.
π Triaged by Issue Repro Triage & Auto-Fix π
Activity