[rel/4.3] Restore InternalsVisibleTo for deprecated MSTest.Engine to fix MethodAccessException (#9769) - #9939
Merged
Conversation
…AccessException The previously shipped MSTest.Engine package (assembly name Microsoft.Testing.Framework) calls internal platform members such as ArgumentGuard.Ensure. The InternalsVisibleTo grants for Microsoft.Testing.Framework / MSTest.Engine were dropped in #2615 during the rename to Microsoft.Testing.Internal.Framework, causing a System.MethodAccessException at runtime when the old engine binary is loaded against the newer platform (see #9769). Restoring the grants keeps binary compatibility, mirroring the TestRequestExecutionTimeInfo workaround. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 32680b56-ae8b-4df9-bf5d-d6be9a1a3dc4
Contributor
There was a problem hiding this comment.
🤖 Generated by Copilot at Evangelink's request — use with caution and always verify.
Review Summary
Verdict: Looks good ✅
This is a straightforward, well-documented backport that restores two InternalsVisibleTo grants to fix a MethodAccessException in shipped binaries.
Positives
- Excellent inline comment explaining the history and rationale
- Entries are inserted in alphabetical order, consistent with existing style
- Minimal, surgical change — no unnecessary modifications
- Mirrors the established
TestRequestExecutionTimeInfocompatibility pattern
No issues found
The change is purely additive (granting friend access to already-shipped assemblies), introduces no new public API surface, and carries no risk of breaking existing behavior. No action items.
Evangelink
enabled auto-merge (squash)
July 14, 2026 15:05
0101
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #9938 to
rel/4.3.Problem
Native AOT / source-gen test projects fail at runtime with:
Reported in #9769 (comment). Zero tests run, exit code 134.
Root cause
MSTest.Sdk source-gen mode pulls in the (now deprecated) MSTest.Engine package, whose assembly name is still
Microsoft.Testing.Framework. That assembly''sTestApplicationBuilderExtensions.AddTestFrameworkcalls the internalMicrosoft.Testing.Platform.Helpers.ArgumentGuard.Ensure.The
InternalsVisibleTogrants forMicrosoft.Testing.Framework/MSTest.Enginewere removed in #2615 when those projects were renamed toMicrosoft.Testing.Internal.Framework. The already-shipped engine binary was compiled while the grant existed, so loading it against a newerMicrosoft.Testing.Platformthat no longer grants the friend relationship throwsMethodAccessException.Fix
Restore the two
InternalsVisibleTogrants (Microsoft.Testing.Framework,MSTest.Engine) inMicrosoft.Testing.Platform.csproj, mirroring the existingTestRequestExecutionTimeInfocompatibility workaround (issue #8925).Fixes #9769