ReSharper: setting C# language level for Solution
Asked Answered
S

2

31

Further to this question, I have lots of projects inside a solution and I dont want to create a dotsettings file for each project. Can anyone help me set the C# Language Level on a solution level.

This is relevant for me as I downloaded VS2015 today and ReSharper is offering me useful refactor suggestions based on targeting C# 6 and my projects are using C#5.

Stalnaker answered 22/7, 2015 at 21:45 Comment(1)
Have you tried setting the language version for the project in Visual Studio? Go to project properties -> Build -> Advanced... -> Language VersionJory
A
38

I added below settings in .sln.DotSettings

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

This line was added to .csproj.DotSettings when I tried to disable c#6 for a particular project. After adding this line in .sln.DotSettings resharper is reporting an error whenever I am trying to use c# 6.0 feature.

Aloysius answered 23/7, 2015 at 16:7 Comment(3)
this worked great thanks. problem resolved. please refer to this gist for my final dotsetting file. gist.github.com/chris-brown/b47ea61ef2c93af50beeStalnaker
Can be applied at project level, solution level, or user level, which is at %APPDATA%\JetBrains\Shared\vAny\GlobalSettingsStorage.DotSet‌​tingsIncensory
It's also possible to set for each project in solution the C# language version via Project Properties > Build tab > Advanced... and ReSharper will detect it by it's own and avoids to suggest greater than configure language features. It is mor eto configure but you will ensure that nobody without ReSharper can use language version features above your defined one.Clove
T
9

According to Jetbrains documentation about C# default version, you can specify the target C# version explicitly by selecting the project in the Solution Explorer and using the C# Language Level property in the Visual Studio's Properties window.

Tagmemics answered 8/3, 2016 at 7:18 Comment(2)
Please post relevant section here.Cymry
from the link ... "you can specify the target C# version explicitly by selecting the project in the Solution Explorer and using the C# Language Level property in the Visual Studio's Properties window (choose View | Properties Window in the menu). " - it is not the project's properties as in right-click the project, properties.Expectancy

© 2022 - 2024 — McMap. All rights reserved.