4

I've currently to test VS2015 to see how it reacts with our solution. I've some trouble because VS2015 brings C#6, which I cannot yet use(because my colleagues don't have this, because our build machine will also not have it before months).

I saw that I should be able to specify for each project language Version to C#5. I did it for all our projects(270 of them). Now when I compile with a C#6 feature, I've an error, which is good.

But, resharper keep trying to make me use Expression body for properties, string interpolation, ...

Is there a way that Resharper don't propose this kind of changes?

J4N
  • 19,480
  • 39
  • 187
  • 340
  • See "[*How do I disable C# 6 Support in Visual Studio 2015?*](http://stackoverflow.com/q/30461640/1364007)" - [this answer](http://stackoverflow.com/a/31611892/1364007) suggests editing the `.dotsettings` file to disable C# 6.0 feature suggestions in ReSharper for the *solution*. – Wai Ha Lee Dec 09 '15 at 12:37

2 Answers2

5

So I understand you just disabled C#6 support in Roslyn using:
Project Properties/Build/Advanced/Language Version.

But you also have to tell ReSharper to not suggest C#6 features (see comments) by selecting a project in the solution explorer, and then changing the following in the properties window:

properties window

The good news is that you can select multiple projects at once in the solution explorer.

Lucas Trzesniewski
  • 50,214
  • 11
  • 107
  • 158
  • So there is no way that resharper use the information of the project? Because we will hate have to do it twice when restoring C#6 – J4N Dec 09 '15 at 09:39
  • As far as I know, the ReSharper setting is independent from the Roslyn setting, unfortunately. But remember that: 1) you can select multiple projects in the solution explorer and change the option in one go, or: 2) directly mess with the .DotSettings file which will be created for each project. If you don't have any other project-specific settings, deleting the DotSettings files should do the trick. – Lucas Trzesniewski Dec 09 '15 at 09:41
  • 1
    ReSharper will use the default C# level of the project. By default, this is not set, meaning it always floats up - so VS2015 uses C# 6. So you can specify the language version via project properties → Build → Advanced → Language Version (which sets the `` property in the `.csproj` file) and ReSharper will honour that setting. The setting in the answer can be used to override this value. – citizenmatt Dec 09 '15 at 10:53
  • 1
    @citizenmatt hmm I assumed this didn't work as the OP said so in the question... This invalidates my answer, could you please turn your comment into an answer? I'll delete mine afterwards. – Lucas Trzesniewski Dec 09 '15 at 12:52
  • I can guarantee that I was having it set to `Default` previously and my project was having the Language version set to C#5, with no success. After specifying this c#5.0 Language level on each of my project, it works. So I can assume that @LucasTrzesniewski is correct with his answer. Two questions: For new projects, is there a way to change the default value? And is this project setting shared accross our developers(we use TFS as source control) – J4N Dec 09 '15 at 13:00
  • The config will be shared if you commit the DotSettings files. As for the rest, maybe @citizenmatt could tell if there's something wrong here. – Lucas Trzesniewski Dec 09 '15 at 13:13
  • 1
    I missed off the important detail that changes to the LangVersion aren't recognised in real time, and a project reload is required. I've added my comment as an answer, too. – citizenmatt Dec 09 '15 at 17:00
2

ReSharper will use the default C# level of the project. By default, this is not set, meaning it always floats up - so VS2015 uses C# 6. So you can specify the language version via project properties → Build → Advanced → Language Version (which sets the property in the .csproj file) and ReSharper will honour that setting.

However, ReSharper doesn't get notified that the value has changed, so does not update on-the-fly, but it will honour the setting on project/solution reload.

Alternatively, as per @lucas-trzesniewski's answer, you can override the project's LangVersion (or default, lack of LangVersion) by telling ReSharper directly what C# version it should target.

citizenmatt
  • 18,085
  • 5
  • 55
  • 60
  • 1
    In my case I used a tool( https://github.com/khellang/LangVersionFixer ) to change all my version at once, then only I opened the solution, so resharper should have been able to read it, but it wasn't the case. Do you see any reasons it would not have worked? – J4N Dec 09 '15 at 17:23