We've been using the Microsoft Fakes framework in our solution for a long time to fake System.DateTime.UtcNow during testing.
More recently, though several weeks ago, we started using C# 7 features (with VS 2017), including tuples as return values from functions. Now, I created a new branch for a release. In the new branch, generating fakes fails with multiple of the messages below
4>C:\Users\...\Source\... 2017\DEV\WebApp.UnitTests\f.cs(116674,53): error CS0234: The type or namespace name 'ITuple' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?) [C:\Users\...\Source\... 2017\DEV\WebApp.UnitTests\obj\Debug\Fakes\m\f.csproj]
4>C:\Users\...\Source\... 2017\DEV\WebApp.UnitTests\f.cs(116674,13): error CS0538: 'ITuple' in explicit interface declaration is not an interface [C:\Users\...\Source\... 2017\DEV\WebApp.UnitTests\obj\Debug\Fakes\m\f.csproj]
I have tried this:
I am not sure what else to try. We didn't encounter this issue when we first started using tuples and added the System.ValueTuple NuGet package. We only noticed the issue when creating a new branch. I suppose either the building of the FakesAssemblies or the restoring of NuGet packages must have triggered something.
Since then, we also noticed it happening when we Rebuild the solution.
EDIT: I have also tried to remove all Fakes assemblies, references, and configuration and starting over. Same result.
The solution turned out to be targeting .NET Framework 4.7.1. Per the docs (RTFM, I know...), ITuple
is defined in System.Runtime.CompilerServices
for the first time in that release:
https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.ituple(v=vs.110).aspx
.NET Framework
Available since 4.7.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With