Skip to content

Remove unnecessary binding redirects from app.configs#15786

Closed
nohwnd wants to merge 1 commit into
mainfrom
remove-binding-redirects
Closed

Remove unnecessary binding redirects from app.configs#15786
nohwnd wants to merge 1 commit into
mainfrom
remove-binding-redirects

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented May 14, 2026

Remove all binding redirects from testhost.x86, datacollector, and vstest.console app.configs. These were redirects for ObjectModel (old v11-14 adapter compat), VS-only DLLs (TestWindow.Interfaces, UnitTestFramework), System polyfills (Memory, Buffers, CompilerServices.Unsafe, Collections.Immutable, Reflection.Metadata, FileSystemGlobbing), and DLLs that don't even ship (DiagnosticSource, Encodings.Web — see #15765 for the damage those caused).

Updated verify-binding-redirects.ps1 to enforce zero redirects going forward — it now fails if any <dependentAssembly>\ elements are found, instead of trying to keep them in sync.

Remove all dependentAssembly binding redirects from the three net462
host app.configs (testhost.x86, datacollector, vstest.console).

Binding redirects are a legacy .NET Framework mechanism that papers over
version mismatches instead of fixing them, and actively cause harm when
they get out of sync with the shipped DLLs (see #15765).

Removed redirects:
- ObjectModel (old adapter compat v11-14, no longer needed)
- TestWindow.Interfaces, UnitTestFramework (VS-only, don't ship)
- FileSystemGlobbing, CompilerServices.Unsafe, Collections.Immutable,
  Reflection.Metadata, Memory, Buffers (System polyfills)
- DiagnosticSource, Text.Encodings.Web (don't ship, were harmful)

Updated verify-binding-redirects.ps1 to enforce zero redirects and
fail if any are re-introduced.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 14:58
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 14, 2026

Love how optimistically this is described :D let's see it crumble :D

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes all assembly binding redirects from the .NET Framework app.config files for vstest.console, testhost.x86, and datacollector, and updates the packaging verification script to enforce a “no binding redirects” policy going forward (motivated by #15765).

Changes:

  • Removed all <dependentAssembly> / <bindingRedirect> entries from the three shipped app.config files.
  • Simplified eng/verify-binding-redirects.ps1 to fail when binding redirects are present (rather than trying to sync redirect versions from extracted packages).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/vstest.console/app.config Removes all binding redirects from the vstest.console .NET Framework config.
src/testhost.x86/app.config Removes all binding redirects while keeping probing configuration.
src/datacollector/app.config Removes all binding redirects from the datacollector .NET Framework config.
eng/verify-binding-redirects.ps1 Changes validation from “keep redirects in sync” to “redirects forbidden”.

Comment on lines 41 to 46
$dependentAssemblies = $xml.SelectNodes("//asm:dependentAssembly", $nsMgr)
foreach ($dep in $dependentAssemblies) {
$identity = $dep.SelectSingleNode("asm:assemblyIdentity", $nsMgr)
$redirect = $dep.SelectSingleNode("asm:bindingRedirect", $nsMgr)
if (-not $identity -or -not $redirect) { continue }

Comment on lines +52 to 55
if (-not $errors) {
Write-Host " OK - no binding redirects."
}
}
Copy link
Copy Markdown
Member Author

@nohwnd nohwnd left a comment

Choose a reason for hiding this comment

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

Review summary

The overall direction is correct — removing stale binding redirects and replacing the sync-version logic with a zero-tolerance check is a clear improvement, well-motivated by issue #15765.

Two issues in eng/verify-binding-redirects.ps1:

  1. Logic bug in "OK" output (line 52): if (-not $errors) tests the global accumulator, not the current entry. A later clean config won't print "OK" if any earlier config failed. Needs a per-iteration flag (details inline).

  2. Orphaned mandatory parameters (lines 17–18): $PackageDirs and $Configuration are still [Parameter(Mandatory)] but the function no longer uses them. The call in verify-nupkgs.ps1 still satisfies the constraint, so it won't error at runtime — but they're dead code that should be cleaned up.

No concerns with the app.config changes themselves; the deletions match the description exactly.

🧠 Reviewed by expert-reviewer workflow

🧠 Reviewed by Expert Code Reviewer 🧠

@nohwnd

This comment has been minimized.

@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 14, 2026

Closing - removing all binding redirects breaks testhost because it loads arbitrary user assemblies that may reference older versions of shipped DLLs (e.g. System.Collections.Immutable 8.0.0.0 when we ship 10.0.0.0). The redirects for shipped DLLs are actually needed for version unification. The real fix is scoped: remove only orphaned redirects (DLLs we don't ship), which is handled by #15778 (merged) and #15776/#15777 for release branches.

@nohwnd nohwnd closed this May 14, 2026
@nohwnd
Copy link
Copy Markdown
Member Author

nohwnd commented May 14, 2026

Understood — removing this from my tracking. The correct approach is the scoped fix (removing only orphaned redirects for DLLs we don't ship), which is covered by #15778 and the release branch PRs. Closing this out.

🔧 Iterated by PR Iteration Agent 🔧

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.

2 participants