Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2017 Bug or new features?

Tags:

After upgrading to VS 2017 I got the following error from this code (which has always been working perfectly)

byte[] HexStringToByteArray(string hex)     {         if (hex.Length % 2 == 1)             throw new Exception("The binary key cannot have an odd number of digits");          byte[] arr = new byte[hex.Length >> 1];          for (int i = 0; i < hex.Length >> 1; ++i) // Error in this line         {             arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));         }          return arr;     } 

Exception:

Error 1: The variable 'i' cannot be used with type arguments Error 2: 'hex' is a variable but is used like a type     

the solution was to surround the expression by parentheses.

for (int i = 0; i < (hex.Length >> 1); ++i) 

But that made me wonder is this a bug or a new functionality? Thanks.

like image 527
Mhd. Yasseen Avatar asked Mar 08 '17 10:03

Mhd. Yasseen


People also ask

What is the latest Visual Studio 2017 version?

Visual Studio 2017 version 15.9 is the final supported servicing baseline for Visual Studio 2017 and has entered the extended support period. Enterprise and Professional customers needing to adopt a long term stable and secure development environment are encouraged to standardize on this version.

Is VS 2017 still supported?

Visual Studio 2017: mainstream support ends April 12, 2022, and the product will transition to extended support until April 2027. During extended support we'll provide fixes only for security issues. We recommend users move to the 15.9 supported baseline to remain under support.

What's the difference between Visual Studio 2019 and 2022?

Visual Studio 2019 had several features that improved overall accessibility, and VS 2022 improved and added even more accessibility features. Instead of relying on plugins or add-ons, users can modify the interface to improve visibility and organization and work better with approved extensions.


1 Answers

Thanks for reporting this. This is a confirmed regression in the precedence of parsing. This fix will ship in the first quarterly release of VS2017 at the latest.

Information on the fix: https://github.com/dotnet/roslyn/pull/16834

like image 110
Julien Couvreur Avatar answered Sep 30 '22 16:09

Julien Couvreur