140

While using ReSharper, it suggested "Enable C# 6.0 support for this project". I foolishly clicked on it, and now as advertised it's giving me suggestions for C# 6.0 - which then give me errors as I am not using C# 6.0 in this project.

How can I disable C# 6.0 support, returning it to how it was before? (Preferably without having to individually ignore specific suggestions)

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Mathieu Lomax
  • 1,521
  • 2
  • 9
  • 7
  • 1
    This just happened to me but I don't recall seeing that suggestion. I was creating a new class in my project, implementing an interface and it was suggesting c# 6 stuff. I was so confused.... – Charles Josephs Jun 12 '15 at 15:13

2 Answers2

165

Click the project node in the Solution Explorer. Then look in the Property Grid (F4). You'll see a property named "C# Language Level". Set that to "Default" or your desired language level.

enter image description here

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • This is not available in VS2015 Preview, any alternatives? – Moslem Ben Dhaou Mar 16 '15 at 15:25
  • 13
    It is available under Project => Properties => Build => Advanced. – Ilya Suzdalnitski Mar 26 '15 at 05:18
  • 1
    It is available in 2015 RC, on projects, not on the solution. – Fontanka16 Jun 01 '15 at 20:42
  • Is there perhaps a better solution when having to do this with a lot of projects? Something more globally? – MarioDS Jul 27 '15 at 09:11
  • 4
    @MDeSchaepmeester just multi select all projects to set Language Level once for the whole solution. Each project wil get it's own .DotSettings file – Jochen Jul 27 '15 at 15:38
  • 1
    FYI - Selecting "Default" in VS2015 RTM will still leave C# 6.0 enabled (that's apparently the default in VS2015) -- you need to explicitly select C# 5.0 if that's what you want. – Mr. T Sep 08 '15 at 18:18
  • @IlyaSuzdalnitski Unfortunly, it doesn't work. For example C# suggests C# 6.0 syntax, I accept changes and then VS stays "hey, it's C# 6.0 syntax while you set C# 5.0 for a project, I won't compile it)! So R# uses its own settings and do not respect VS's. – Alex Zhukovskiy Apr 08 '16 at 10:24
  • The other answer is better because it works solution-wide – disklosr Mar 28 '17 at 16:05
  • @disklosr Not always, sometimes you can have different projects at different language levels in the same solution – Jake Jul 19 '17 at 23:05
  • @Jake this answer too doesn't always work, sometimes you've got several projects under one solution and it's a pain to change the settings for each individual one. – disklosr Jul 20 '17 at 19:57
59

TO disable it at once across the solution rather than per project level, please add below in .sln.DotSettings

<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp50</s:String>

it would disable resharper 6.0 features/give you error

EDIT

as per comments, in case you dont have the sln.DotSettings file at all, then you need to create one with below contents

<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> 
    <s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">‌​CSharp50</s:String>
</wpf:ResourceDictionary>
harishr
  • 17,807
  • 9
  • 78
  • 125
  • 12
    This should be marked as the answer, it solves the problem at solution level, i.e. without the need to set per csproj property – aateeque Nov 02 '15 at 18:23
  • 2
    Here is the entire content of sln .DotSettings file, in case you need to recreate it like i did. ` CSharp50` – Jeson Martajaya Nov 05 '15 at 10:44
  • 1
    @JesonMartajaya updated answer to include your comments – harishr Nov 06 '15 at 03:08
  • 1
    This works for me. Heads-up though: that first XML snippet has an unmatched tag at the end. – Nick Smith Nov 30 '15 at 20:12
  • Well now this isn't working for me at all. Not sure why, but ReSharper will just not honor that setting for some reason, and keeps suggesting changes that won't work in C# 5.0. – Nick Smith Dec 14 '15 at 21:05
  • 3
    Updated: I was tearing my hair out trying to figure out why this wasn't working. Turns out I had changed the language setting in the project properties, which creates a .csproj.DotSettings file. When I changed the setting back to "Default" from "CSharp50," the "Default" in the project-specific settings was overriding the solution-wide "CSharp50" setting. Removing the .csproj.DotSettings file and re-opening the solution fixed it. – Nick Smith Dec 14 '15 at 21:13
  • Note that this workaround does require VS2015. It will not work in VS2013. – AnneTheAgile Jan 08 '16 at 17:53
  • @AnneTheAgile Does vs2013 support c# 6? – harishr Jan 09 '16 at 02:01
  • 1
    @entre , I had thought, from what I read, that one is able to add c# 6 support to vs2013, since older dotnets can be upgraded/ modified. But alas it does not seem to go as far as vs2013 usage, unless there is some trick I didn't do. – AnneTheAgile Jan 10 '16 at 02:51
  • 1
    You can create DotSettings file (team or user) with GUI: ReSharper -> Manage Options... Copy Settings To – Anton Kalcik Apr 01 '16 at 14:43
  • 1
    Note that you need to reopen your project/solution for VS2015 to pick up your changes. At least I had to... – rumblefx0 Nov 22 '16 at 08:44