[fix] fix: add RequestingAssembly to AssemblyResolveEventArgs for binary compat#16076
Conversation
…mpat (#15765) The SDK 10.0.300 ships a version of AssemblyResolver that accesses AssemblyResolveEventArgs.RequestingAssembly, but this property was missing from AssemblyResolveEventArgs, causing MissingMethodException when DisableAppDomain=true is used with net462 tests. Add RequestingAssembly property and an overloaded constructor to AssemblyResolveEventArgs, and update the net462 PlatformAssemblyResolver to pass the requesting assembly from the CLR ResolveEventArgs. Fixes #15765 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR restores binary compatibility for assembly resolution by adding RequestingAssembly to AssemblyResolveEventArgs and flowing it from the .NET Framework resolver path.
Changes:
- Adds a new
AssemblyResolveEventArgs(string?, Assembly?)constructor. - Adds the
RequestingAssemblypublic getter. - Passes
ResolveEventArgs.RequestingAssemblythrough the net462 resolver bridge and records the new public API.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/Runtime/IAssemblyResolver.cs |
Adds the new constructor and RequestingAssembly property to resolver event args. |
src/Microsoft.TestPlatform.PlatformAbstractions/net462/Runtime/PlatformAssemblyResolver.cs |
Forwards the CLR ResolveEventArgs.RequestingAssembly value into platform abstraction event args. |
src/Microsoft.TestPlatform.PlatformAbstractions/PublicAPI/PublicAPI.Unshipped.txt |
Declares the new public API surface. |
nohwnd
left a comment
There was a problem hiding this comment.
🧠 Reviewed by Expert Code Reviewer
Dimensions activated: Public API Surface Protection · Backward Compatibility & Rollback Safety · Cross-TFM & Framework Resolution · Testhost Assembly Loading & Resolution
Result: No issues found.
| Dimension | Verdict |
|---|---|
| Public API Surface Protection | ✅ Both new entries correctly declared in PublicAPI.Unshipped.txt; property is appropriately get-only |
| Backward Compatibility & Rollback Safety | ✅ Purely additive — existing single-arg constructor and all current callers are unaffected |
| Cross-TFM & Framework Resolution | ✅ System.Reflection.Assembly? available on all TFMs; netcore resolver correctly omits RequestingAssembly since AssemblyLoadContext.Resolving doesn't expose it |
| Testhost Assembly Loading & Resolution | ✅ Directly fixes the MissingMethodException on get_RequestingAssembly for DisableAppDomain=true + net462 scenario |
PR description alignment: accurate and complete.
🧠 Reviewed by Expert Code Reviewer 🧠
🤖 Expert vstest review (automated)Small, additive binary-compatibility patch to 🛑 BlockersNone.
|
- Update RequestingAssembly XML doc to note it is always null on .NET (Core) because AssemblyLoadContext.Resolving does not expose the requesting assembly - Update netcore PlatformAssemblyResolver to explicitly pass null for requestingAssembly for symmetry/grepability - Add AssemblyResolveEventArgsTests covering both constructor overloads Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
|
Thanks for the review! I've addressed the suggestions in the follow-up commit:
Regarding the PR description: the description does mention the revert context in the root cause section, but I'll leave a note here for future readers — as of
|
nohwnd
left a comment
There was a problem hiding this comment.
🧠 Reviewed by Expert Code Reviewer
Scope of this review: Incremental commit 94b81ab on top of the previously-reviewed 285d14f.
Changes since last review:
- XML doc on
RequestingAssemblyexplaining the always-nullbehaviour on .NET (Core) - netcore
PlatformAssemblyResolvernow explicitly passesrequestingAssembly: null(symmetry / grepability) - New
AssemblyResolveEventArgsTestscovering both constructor overloads
Result: No issues found.
| Dimension | Verdict |
|---|---|
| Public API Surface Protection | ✅ No new API added in this commit |
| Correctness | ✅ Explicit null on netcore path is correct — AssemblyLoadContext.Resolving does not expose the requesting assembly |
| Test coverage | ✅ Three test cases cover the single-arg constructor (null default), two-arg with assembly, and two-arg with explicit null |
| Documentation | ✅ Remarks correctly document the TFM asymmetry |
PR description alignment: accurate and complete — describes both commits together.
🧠 Reviewed by Expert Code Reviewer 🧠
🧠 Reviewed by Expert Code Reviewer 🧠
🤖 This is an automated fix by the Issue Triage agent.
Fixes #15765
Root Cause
SDK 10.0.300 ships a version of
Microsoft.TestPlatform.Common.dllwhoseAssemblyResolver.OnResolvemethod callsargs.RequestingAssemblyon anAssemblyResolveEventArgsinstance. However,AssemblyResolveEventArgsinMicrosoft.TestPlatform.PlatformAbstractions.dllnever had this property, causing aMissingMethodExceptionat runtime:This only manifests with
RunConfiguration.DisableAppDomain=truetargetingnet462, because that mode runs tests in the current AppDomain, loading vstest's assembly resolver into it. TheAppDomain.AssemblyResolveevent fires and hitsOnResolve, which crashes.Fix
RequestingAssemblyproperty toAssemblyResolveEventArgsAssemblyResolveEventArgs(string? name, Assembly? requestingAssembly)PlatformAssemblyResolverbridge to passResolveEventArgs.RequestingAssemblythrough to vstest'sAssemblyResolveEventArgsPublicAPI.Unshipped.txtTesting
The fix restores binary compatibility between the two assemblies. The affected scenario (
DisableAppDomain=trueon net462) would no longer throwMissingMethodExceptionwhen the assembly resolver fires.