Can you switch on C# 7.0 features within Visual Studio 2015 (Enterprise) or do you need to upgrade to 2017?

- 20,585
- 22
- 95
- 108

- 3,424
- 7
- 43
- 70
-
4If you have Enterprise, you have an MSDN subscription as well. VS 2017 RTMs in a couple of weeks. It already has a Go-Live license – Panagiotis Kanavos Feb 10 '17 at 10:15
-
@PanagiotisKanavos: Yeah just seen that as we speak thank you :) – garfbradaz Feb 10 '17 at 11:11
2 Answers
Yes, you can replace the compiler shipped with Visual Studio for a C# 7-enabled version by installing the Nuget package Microsoft.Net.Compilers:
Referencing this package will cause the project to be built using the specific version of the C# and Visual Basic compilers contained in the package, as opposed to any system installed version.
There is no indication that I can see on the package page as to whether this is officially supported in Visual Studio 2015. My not-thorough tests so far indicate that it works but not painlessly - C# 7 code compiles, but is underlined with the red squiggly line which indicates a syntax error:
Note that you will also need to install the Nuget package System.ValueTuple to use the new C# 7 value tuples features.

- 20,585
- 22
- 95
- 108
-
5Notice there is still an error (red squiggly line) in the editor window. Having VS still reporting errors even though the Build succeeded is not a great solution. Anyone know how to get the VS editor to stop showing these false-positive errors? – cwills Apr 20 '17 at 00:19
You have to download/checkout and build the NET Compiler Platform ("Roslyn") from Github and then you can test the C# 7 Features with VS 2015!
More Info:
https://github.com/dotnet/roslyn/tree/master
If you like video tutorials, than watch this video:
https://joshvarty.wordpress.com/2016/02/10/lrn-quick-tip-how-to-test-out-c-7-features-with-roslyn/

- 16,345
- 7
- 52
- 70
-
Do not down vote without to leave a comment, you have to exmplain why you did that. Be a brave and a good man and remove it! my answer is more correct then the selected one! – Bassam Alugili Feb 22 '17 at 16:50
-
Hi @BassamAlugili, is it possible what you are saying for VS 2015 professional? – dcg Feb 23 '17 at 20:37
-
I didn't understand why people are down voting @BassamAlugili answer. – Banketeshvar Narayan Feb 25 '17 at 13:42
-
@BassamAlugili has given his opinion and it is correct. Everybody knows that C# 7 support has been provided wit Visual Studio 2017. But it is also possible with Visual Studio 2015 update 2 by using Roslyn Latest source code. Below is a small link how to test C# 7 feature with Visual Studio 2015.http://www.c-sharpcorner.com/article/how-to-compile-test-C-Sharp-7-features/ But it requires a lot of setting changes so I will recommend using Visual Studio 2017 RC in wich use can test your C# 7 features in one go. – Banketeshvar Narayan Feb 25 '17 at 13:54
-
But if you would not like to play with Compiler source code I will always recommend to use Visual Studio 2017. link http://www.c-sharpcorner.com/article/top-10-new-features-of-c-sharp-7-with-visual-studio-2017/ have the list of supported C#7 features with Visual Studio 2017. – Banketeshvar Narayan Feb 25 '17 at 13:58