Moq dependency uprev is not working as expected
Describe the Bug
Moq has a dependency hierarchy as follows System.Threading.Tasks.Extensions >= 4.5.4 System.Runtime.CompilerServices.Unsafe >= 4.5.3
In my application I use System.Runtime.CompilerServices.Unsafe to 4.7.0
so from the Moq definition, everything is fine..
But trying to execute a unit test that uses AsSpan() from System.Memory throws an exception (during Release and Debug mode)
System.IO.FileLoadException HResult=0x80131040 Message=Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Source=System.Memory StackTrace: at System.MemoryExtensions.AsSpan(String text) at UnitTestProject1.UnitTest1.TestMethod1() in C:\source\repos\ConsoleApp9\UnitTestProject1\UnitTest1.cs:line 13
Steps to Reproduce
Create a unit test project with the following nugets:
Moq Version="4.20.69" MSTest.TestAdapter Version="2.2.8" MSTest.TestFramework Version="2.2.8" System.Memory Version="4.5.4" System.Runtime.CompilerServices.Unsafe Version="4.7.0"
Try to run (release or debug) and you'll get an exception on the b = a.AsSpan() line.
namespace UnitTestProject1
{
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
string a = "asdfdsa";
var b = a.AsSpan();
}
}
}
Expected Behavior
following the dependency definition, Moq should work with System.Runtime.CompilerServices.Unsafe 4.7.0
Exception with Stack Trace
System.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=System.Memory
StackTrace:
at System.MemoryExtensions.AsSpan(String text)
at UnitTestProject1.UnitTest1.TestMethod1() in C:\source\repos\ConsoleApp9\UnitTestProject1\UnitTest1.cs:line 13
Version Info
Target Framework is net4.6.2. Using SDK csproj
Referenced packages: Moq Version="4.20.69" MSTest.TestAdapter Version="2.2.8" MSTest.TestFramework Version="2.2.8" System.Memory Version="4.5.4" System.Runtime.CompilerServices.Unsafe Version="4.7.0"
Additional Info
Sounds like you'd need a binding redirect for that assembly
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.
This issue will now be closed since it has been labeled 'stale' without activity for 30 days.
