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.
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.
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.
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.
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
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