Reference System.Memory 4.6.3 in the .NETFramework adapter#9209
Merged
Evangelink merged 2 commits intoJun 17, 2026
Merged
Conversation
System.Memory flows into the net462 adapter transitively (via Microsoft.TestPlatform.ObjectModel -> System.Reflection.Metadata 8.0.0 -> System.Collections.Immutable 8.0.0) at 4.5.5, whose .NETFramework assembly version is 4.0.1.2. The linked XxHash code (Span/MemoryMarshal) makes MSTestAdapter.PlatformServices reference System.Memory, so the shipped assembly carries a 4.0.1.2 reference. Hosts that unify System.Memory to 4.0.5.0 (e.g. Visual Studio) and run the adapter under a test host that does not apply the test source's binding redirects (the VSTest test host loads its own config) cannot satisfy the 4.0.1.2 reference: the deployed 4.0.5.0 is rejected by exact-version resolution and discovery fails with FileNotFoundException for System.Memory 4.0.1.2. Pin System.Memory to 4.6.3 (assembly 4.0.5.0) and reference it explicitly so the net462 assemblies bind 4.0.5.0, matching the version those hosts deploy. Verified: the rebuilt net462 MSTestAdapter.PlatformServices.dll now references System.Memory 4.0.5.0 instead of 4.0.1.2. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a .NET Framework (net462) assembly binding failure in the MSTest adapter by explicitly referencing/pinning System.Memory so the adapter compiles against (and therefore references) the System.Memory assembly version commonly deployed by hosts like Visual Studio (4.0.5.0), avoiding FileNotFoundException during discovery.
Changes:
- Pin
System.Memorycentrally to4.6.3(assembly version4.0.5.0) viaDirectory.Packages.props. - Add an explicit
PackageReferencetoSystem.Memoryfor the adapter platform services project on applicable TFMs. - Flow the pinned
System.Memoryversion intoMSTest.TestAdapterpackaging (.nuspec) via a new nuspec property.
Show a summary per file
| File | Description |
|---|---|
| src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj | Adds an explicit System.Memory reference (conditioned to legacy TFMs) to ensure the compiled assembly binds the desired version. |
| src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.nuspec | Adds System.Memory as an explicit NuGet dependency for net462 and uap10.0 groups. |
| src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj | Exposes SystemMemoryVersion as a nuspec property for packaging substitution. |
| Directory.Packages.props | Introduces SystemMemoryVersion=4.6.3 and centrally pins System.Memory to that version. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Evangelink
enabled auto-merge (squash)
June 17, 2026 08:56
0101
approved these changes
Jun 17, 2026
0101
left a comment
Member
There was a problem hiding this comment.
Automated safety check passed: no dangerous changes detected (no secrets, exfiltration, destructive ops, or suspicious dependencies). Approving as requested. Note: this is a quick safety sanity check, not a full code review.
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.
On
net462,MSTestAdapter.PlatformServicesreferencesSystem.Memory(the linked XxHash code usesSpan/MemoryMarshal). That reference is currently4.0.1.2, pulled in transitively asSystem.Memory 4.5.5viaMicrosoft.TestPlatform.ObjectModel->System.Reflection.Metadata 8.0.0->System.Collections.Immutable 8.0.0.Hosts that unify
System.Memoryto4.0.5.0(e.g. Visual Studio) and run the VSTest adapter under a test host that does not apply the test source's binding redirects (the VSTest test host loads its own config) cannot satisfy the4.0.1.2reference: the deployed4.0.5.0is rejected by exact-version assembly resolution and discovery fails withFileNotFoundExceptionforSystem.Memory 4.0.1.2.This pins
System.Memoryto4.6.3(assembly4.0.5.0) and references it explicitly so thenet462adapter assemblies bind4.0.5.0, matching what those hosts deploy. The reference is conditioned onnet462/netstandard2.0/uwp; modern .NET (net8.0+) uses the in-boxSpanand is unaffected.Verified by rebuilding
net462:MSTestAdapter.PlatformServices.dllnow referencesSystem.Memory 4.0.5.0(was4.0.1.2).