Latet beta c# 7 tupels are not working
Hi,
With Tuples samples I am getting following error.
CS8179 Predefined type 'System.ValueTuple`2' is not defined or imported
With Tuples samples I am getting following error.
CS8179 Predefined type 'System.ValueTuple`2' is not defined or imported
Comments
Process.Start (Path.GetDirectoryName (GetType().Assembly.Location));
and then click on the folder in explorer (it might be behind LINQPad).
Do you see any subdirectories starting with 'shadow'? And if you open one of them, is there a file present called 'System.ValueType.dll'?
First, explicitly add a reference to that file.
If that doesn't help, try running the following query, which includes a reference to the System.ValueTuple nuget package:
http://share.linqpad.net/vrf46m.linq
...this isn't a production machine ;-)
When before deleting the folder, I tried this:
System.Runtime.CompilerServices.TupleElementNamesAttribute namesAttr;
I got this error:
CS0433 The type 'TupleElementNamesAttribute' exists in both 'System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
which led me to look for System.ValueTuple.dll and in turn to delete the folder under temp.
"Tuples" linqpad sample mentions in the end:
// Tuples rely on a new type called System.ValueTuple, in the NuGet package of the same name.
// LINQPad includes this automatically, so you don't have to import anything.
After deleting the folder, I was always getting a warning that %AppData%\..\Local\Temp\LINQPad5\System.ValueTuple\System.ValueTuple.dll does not exist, although things worked as expected. To avoid the warning and while waiting until Joe fixes this, I compiled an empty dll named System.ValueTuple.dll, which I use to overwrite the one LP writes in this folder when it starts.
The overwrite is conveniently done by a little LinqPad script:
var dummy = Environment.ExpandEnvironmentVariables(@%AppData%\..\Local\Temp\LINQPad5\System.ValueTuple.dll);
var extra = Environment.ExpandEnvironmentVariables(@%AppData%\..\Local\Temp\LINQPad5\System.ValueTuple\System.ValueTuple.dll);
File.Copy(dummy, extra, true);
It seems to me that when a system already has all the necessary, LINQPad should not try to add this reference automatically.
The types for value tuples are supposed to come from the System.ValueType.dll assembly, which is available on NuGet. If you add a reference to this assembly, LINQPad will not add its own automatic reference to System.ValueType.
Is there something I'm missing?
- Windows 10 Enterprise Insider Preview. Build 14986.rs_prerelease.161202-1928.
- Visual Studio Enterprise 2017RC/15.0.0-RC.4+26206.0
- dotnet --version := 1.0.0-rc4-004771
- mscorlib ilspy header:
// C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// ...
// [assembly: AssemblyFileVersion("4.6.2012.0")]
mscorlib check in for ValueTuple.cs : Dec 22, 2016:
https://github.com/dotnet/coreclr/blob/2d49c2c743831b7078c4360f28a81ba28fc47a05/src/mscorlib/src/System/ValueTuple.cs
More History:
https://github.com/dotnet/coreclr/commits/875b7487efcfe0a0b148ad01f33505e065f5a5af/src/mscorlib/src/System/ValueTuple.cs
Also, after removing the offending folder as I said before, and running this:
var namedTuple = (word: "three", number: 3);
namedTuple.Dump();
I get this dumped:
ValueTuple
(three, 3)
Item1 three
Item2 3
which obviously has another problem, as the names were lost.
typeof (int).Assembly.GetType ("System.ValueTuple") == null
Thanks!
typeof (int).Assembly.GetType ("System.ValueTuple") == null
Results:
False
There has been an update to the Windows 10 Insider Slow ring build in the last few days; mscorlib(C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll) is now at [assembly: AssemblyFileVersion("4.7.2046.0")].
Hope this helps!
Daniel
[edit] P.S. Running Visual Studio 2017 Enterprise RTM.
https://www.linqpad.net/Download.aspx#beta
This new build checks whether mscorlib contains System.ValueType, and if so, automatically removes the automatic reference to System.ValueType.dll.
Thank you very much,
Daniel