Skip to content

Reference System.Memory 4.6.3 in the .NETFramework adapter#9209

Merged
Evangelink merged 2 commits into
microsoft:mainfrom
Evangelink:dev/amauryleve/bump-system-memory-462
Jun 17, 2026
Merged

Reference System.Memory 4.6.3 in the .NETFramework adapter#9209
Evangelink merged 2 commits into
microsoft:mainfrom
Evangelink:dev/amauryleve/bump-system-memory-462

Conversation

@Evangelink

Copy link
Copy Markdown
Member

On net462, MSTestAdapter.PlatformServices references System.Memory (the linked XxHash code uses Span/MemoryMarshal). That reference is currently 4.0.1.2, pulled in transitively as System.Memory 4.5.5 via Microsoft.TestPlatform.ObjectModel -> System.Reflection.Metadata 8.0.0 -> System.Collections.Immutable 8.0.0.

Hosts that unify System.Memory to 4.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 the 4.0.1.2 reference: the deployed 4.0.5.0 is rejected by exact-version assembly resolution and discovery fails with FileNotFoundException for System.Memory 4.0.1.2.

This pins System.Memory to 4.6.3 (assembly 4.0.5.0) and references it explicitly so the net462 adapter assemblies bind 4.0.5.0, matching what those hosts deploy. The reference is conditioned on net462/netstandard2.0/uwp; modern .NET (net8.0+) uses the in-box Span and is unaffected.

Verified by rebuilding net462: MSTestAdapter.PlatformServices.dll now references System.Memory 4.0.5.0 (was 4.0.1.2).

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>
Copilot AI review requested due to automatic review settings June 17, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.Memory centrally to 4.6.3 (assembly version 4.0.5.0) via Directory.Packages.props.
  • Add an explicit PackageReference to System.Memory for the adapter platform services project on applicable TFMs.
  • Flow the pinned System.Memory version into MSTest.TestAdapter packaging (.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

Comment thread src/Adapter/MSTestAdapter.PlatformServices/MSTestAdapter.PlatformServices.csproj Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 17, 2026 07:57
@Evangelink
Evangelink marked this pull request as ready for review June 17, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new

@Evangelink
Evangelink enabled auto-merge (squash) June 17, 2026 08:56
@Evangelink Evangelink added the state/needs-review Awaiting review from the team. label Jun 17, 2026

@0101 0101 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@Evangelink
Evangelink merged commit 49dd172 into microsoft:main Jun 17, 2026
38 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/bump-system-memory-462 branch June 17, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants