0

I have the lastest Visual Studio 2017 version

My Visual Studio version

I have tried:

  • Specifically set C# Version project to 7.3 enter image description here

  • Specifically set C# Version project to latest

  • to manually modified the .csproj of the project (to latest and to C# 7.3)
  • Updated the Visual Studio version
  • Used .NET Framework 4.7 instead of 4.7.2
  • to install the ValueTuple Package (which I uninstalled right after)
  • to install Microsoft.Net Compilers package

After all these, my project still does not seems to compile in C# 7.3 because when I try to compare two tuples in the debugger, it prompts this error message:

The error message I get when I use the debugger

which translates to: Error CS8107: Feature 'tuple equality' is not available in C# 7.0. Please use language version 7.3 or greater

And here is my code:

 (CRiverGameState, int, bool) osti;
 bool canRaise = _gameState.GetLstAllowedActionsForCurrentPlayer().Contains(ActionsPossible.Raise);
 (CRiverGameState, int, bool) riverKey = (riverGameState, (int)_boardType, canRaise);

 foreach(var tabarnak in CDBHelper.PRiverAllGameStatesFoldStats.Keys)
 {
   if (tabarnak.Item1.PID == 2592 && tabarnak.Item2 == 1089 && tabarnak.Item3 == false)
     osti = tabarnak;
 }

I'm out of ideas. Why is my project compiled in C# 7.0 instead of C# 7.3 ?

Jonathan
  • 93
  • 2
  • 9
  • please do not post images of code. instead post as text and format the text using the editing tools – jazb Nov 16 '18 at 00:10
  • 2
    Make sure you have enable C# 7.3 for all configurations (Debug, Release, ...). [4 ways to enable the latest C# features](https://www.meziantou.net/2017/08/24/4-ways-to-enable-the-latest-c-features) – meziantou Nov 16 '18 at 00:14
  • I changed the image for code, sorry for this. – Jonathan Nov 16 '18 at 00:14
  • I tried the 4 ways and it doesn't work unfortunately. I also did it for all of the configurations. – Jonathan Nov 16 '18 at 00:21
  • My project is contained in a solution that contains other projects, but those other projects are all updated to C# 7.3 aswell. I have tried the "Directory.Build.props" thing, but it still doesn't work :( – Jonathan Nov 16 '18 at 00:22
  • Just to be clear, you've updated *all* of your projects to use 7.3? – DavidG Nov 16 '18 at 00:24
  • Yes, all of them have the .NET framework version 4.7 and the c# version 7.3 for all configurations (debug, release). I even tried to put a Directory.Build.props for the solution specifying the language version 7.3 with no success. – Jonathan Nov 16 '18 at 00:28
  • It should be as simple as adding `latest` in the csproj file. You could get around it by using `tuple1.Equals(tuple2)` – DavidG Nov 16 '18 at 00:37
  • I have created a new project with a simple WinForms application and it still doesn't work. I'm clearly not using C# 7.3 on my computer for some reason... I think this is related to my version of MSBuild for some strange reason – Jonathan Nov 16 '18 at 00:41
  • I found it! See my post below – Jonathan Nov 16 '18 at 00:46
  • What was the root cause? – Julien Couvreur Nov 16 '18 at 21:47
  • @JulienCouvreur there's no bug, at least not what the OP thinks as a bug - the project compiles but the *debugger expression doesn't*. The *default* language version is the latest major, in this case C# 7. That's the language used by the debugger for expressions, even though the project targets a different version. The project's language version doesn't affect the debugger's. In a multi-project, multi-version solution that's *not* a bad decision. – Panagiotis Kanavos Nov 19 '18 at 09:12
  • @PanagiotisKanavos Thanks for the clarification. We actually have a bug tracking this (debugger should use LangVersion=latest): https://github.com/dotnet/roslyn/issues/28486 – Julien Couvreur Nov 20 '18 at 18:33
  • @JulienCouvreur oops – Panagiotis Kanavos Nov 21 '18 at 07:33

2 Answers2

1

Your debugger version uses C# 7.0.

Your project is using C# 7.3, but the debugger is using C# 7.0.

If you do:

bool result = (osti == riverKey); // This will return true, but not in the debugger 

This will work.

Jonathan
  • 93
  • 2
  • 9
  • You should EDIT your question instead of posting as an answer, which it isn't. – Poul Bak Nov 16 '18 at 06:15
  • 1
    Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. - [From Review](/review/low-quality-posts/21428030) – Poul Bak Nov 16 '18 at 06:15
  • This IS the answer. If you ever encounter this error you'll know why you're getting it. I thought my project wasn't using c# 7.3, but it turned out that it was using c# 7.3 and that the debugger wasn't using c# 7.3 when I use the "watch" variable. However the project is compiled in c# 7.3. – Jonathan Nov 17 '18 at 04:34
  • I don't know why my debugger uses c# 7.0, and I don't care, atleast I know that my project is running under c# 7.3. This is the answer. Now if the person wants to update his debugger to c# 7.3, well that wasn't the question. – Jonathan Nov 17 '18 at 04:35
  • You can report to Microsoft as a bug https://msdn.microsoft.com/en-us/library/zzszcehe%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 – Lex Li Nov 17 '18 at 04:48
  • @Jonathan you *should* care and fix the question. The project *does* compile, contrary to what you posted `my project still does not seems to compile in C# 7.3`. You should change the text and title to ask `why doesn't tuple comparison work in the Watch Window` at least. – Panagiotis Kanavos Nov 19 '18 at 08:53
  • @Jonathan as for this being a bug, it's probably not. The *default* language version is the latest *major* version of the language. That is C# 7.0, not 7.3. [This question](https://stackoverflow.com/questions/44699125/how-to-change-visual-studio-2017-default-language-version-for-all-projects) explains this and is probably a good answer for this question. I suspect the *real* question you'd like to ask is `How do I set the debugger's language version to latest minor instead of default?` – Panagiotis Kanavos Nov 19 '18 at 09:09
  • "Error CS8107: Feature 'tuple equality' is not available in C# 7.0. Please use language version 7.3 or greater" only occurs when the project compiles in C# 7.3, but is not running under c# 7.3 in the watch variables. This is a good question because the person that is looking for this type of answer doesn't know that his debugger (watch variables) version is not the same. So changing the title of the question to "How do I set the debuger's language version to lastest minor instead of default" is wrong because the person that is asking the question doesn't know that this is what's happening. – Jonathan Nov 22 '18 at 22:48
  • Also, the link you posted, I already did that (the "Directory.Build.props" thing). In the first post of the question, you can look at the comments, you'll see that another person suggested to do that and it didn't work. My project is set to c# 7.3 in everything, and I also tried to put everything to "latest", it never worked out. I'm pretty sure it is a bug but I'm too lazy to report it. – Jonathan Nov 22 '18 at 22:50
  • You seems to not have read the whole post or you read it really quickly because you suggest me to use "lastest minor instead of default" when clearly in the first image we can see that I already did that, and in the 1st and 2nd bullet point also suggest that. I wrote "My project doesn't seem to compile in C# 7.3 **because when I try to compare two tuples in the debugger, it prompts this error message (image here)**. I didn't say I was right or anything, I just said that my project doesnt seems to compile in c# 7.3 because of the watch variable thing error. It was just a observation. – Jonathan Nov 22 '18 at 22:57
  • 1
    So, how do I fix it? – Alexei Sosin May 02 '19 at 09:26
0

I was getting this issue albeit with higher versions ie CS8370 C# Feature is not available in C# 7.3. Please use language version {1} or greater. I found getting the very latest updates via the standalone Visual Studio Installer cleared it right up. Note: I got a non-descript error using the Check for Updates option from the Visual Studio Help menu.

Roland
  • 85
  • 3
  • 11