Downgrade C# Version from 7 to 6

Completed

Rider asked me if i want to "upgrade" version from 6 to 7. I clicked Yes.

Now i am stuck in c# 7 with no way to downgrade back to c# 6. Unity doesnt even compile the new syntax (old code works fine). I get inspections suggesting to create local functions that is invalid syntax in c# 6.

Help, how do i undo my change? I went in settings -> toolset, there is no relevant option. Nowhere.

0
5 comments

Hello,

In order to change C# version for code inspections, please do the following:

Right click on the project - > Properties -> Application -> Language level

Hope it helps.

2
Avatar
Permanently deleted user

I have both "Unity Support Plugin" in Rider and "Unity3dRider" in unity assets project .

My .csproj was correct :
<PropertyGroup><LangVersion>6</LangVersion></PropertyGroup> <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>

However...Nice Idea: Trying to Manipulate the files directly from disk. Here is what i found:

The Evil File Was Called: Assembly-CSharp.csproj.DotSettings. It Contained the following:

<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">CSharp70</s:String></wpf:ResourceDictionary>

Deleting this file fixed the problem. Thank you for your suggestion.

2
Avatar
Permanently deleted user

I am using unity engine. In language level it had the following allowed settings: default, c#1, c#2, c#3, c#4, c#5, c#6.
I chose c#6. Rider intellisense still recognised c#7 as valid syntax.
I chose default. Rider intellisense still recognised c#7 as valid syntax. Now c#6 "button" got removed from list. why?
i chose c#5. Rider intellisense still recognised c#7 as valid syntax.

Behaviour: With the suggested changes, during compilation from Rider.
It correctly "identifies" new syntax as errors but this is only during compilation.

I close and reopened rider. Problem persisted. Intellisense still allows c#7 syntax.

1

Hi!

Do you have Unity support plugin enabled? One of its features is managing the LangLevel setting.
https://github.com/JetBrains/resharper-unity
Automatically sets correct C# language version, if not already specified in .csproj - ReSharper will no longer suggest code fixes that won't compile! Supports the default C# 4 compiler, Unity 5.5's optional C# 6 compiler and the C# 6/7.0 compiler in the CSharp60Support plugin.

You may try to delete check the sln.DotSettings or sln.DotSettings.user file near sln. 

There was an issue https://youtrack.jetbrains.com/issue/RIDER-2458, it is marked as solved but seems like we need to recheck it.

Thanks for reporting.

1

Please sign in to leave a comment.