Uh oh!
There was an error while loading. Please reload this page.
Reference System.Memory 4.6.3 in the .NETFramework adapter - #9209
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>
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
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Petr Pokorny (0101)
left a comment
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.
Uh oh!
There was an error while loading. Please reload this page.
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).