Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# 6 error messages on VS2013 despite using Microsoft.Net.Compilers nuget package

Over half of our 50 man development team still uses Visual Studio 2013. Despite this, we would like to use C# 6. So we tried using this solution: https://stackoverflow.com/a/32010632/3997704.

Compilation with Microsoft.Net.Compilers works fine, as does our CI environment. However, Visual Studio shows a lot of errors in the Error List related to C# 6 features. I tried getting rid of the errors by using clean solution, rebuild, restarting Visual Studio and clearing ReSharper caches but none worked.

like image 527
mnwsmit Avatar asked Mar 14 '23 01:03

mnwsmit


1 Answers

Even though you install the Microsoft.Net.Compilers package in your project, Visual Studio still uses the C# 5 compiler for the editor. That's why it compiles the C# 6 code, but the editor doesn't understand it. Unfortunately, there is no way to change the compiler editor uses and probably never will be.

So the only way for the full C# 6 support is to upgrade to Visual Studio 2015.

like image 144
David Ferenczy Rogožan Avatar answered Apr 27 '23 21:04

David Ferenczy Rogožan