Reputation: 5157
My question is the opposite of just about every question I have found online.
I want to enable C# 7.0 warnings/errors in Resharper (running in VS2017, release just installed today.)
I need to do this because the project I am working on will be published to my workplace's server, and their CI throws fatal errors when C# 7.0 features are used (R# C# 7.0 language feature
), so I can't use them (they won't accept any project that fails fatally with their CI.)
They're using Resharper CLI in the CI. So I want to make my Resharper throw the same errors, so I can quickly locate and eliminate C# 7.0 features. My Resharper shows the project as being clean (other than some minor "it might be a problem but it's not for me" things), so I have no fatal errors or even warnings about C# 7.0 when I run a code analysis.
Every question I have seen so far is asking about how to disable warnings about C# 7.0. My Resharper is not throwing any warnings or errors, while the one on our CI is.
I've looked through the options but can't find any obvious "C# 7.0" options. I've looked for something like "maximum supported language/throw an error if language feature in later version is used/etc" but I can't seem to find anything.
Edit: Web.config codedom section:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
</compilers>
</system.codedom>
It's definitely set to language version 6...
Upvotes: 2
Views: 2596
Reputation: 1
The Resharper language rules and Studio rules lie in different places. Studio (and Roslyn) rules you can find in project settings. Resharper keeps warning rules in the [ProjectName].csproj.DotSettings file.
Xml Node:
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp70</s:String>
This file can be safely deleted to get things back to default.
File for warnings 6.0 will be something like that:
<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">CSharp60</s:String>
</wpf:ResourceDictionary>
Upvotes: 0
Reputation: 10897
You can configure which C# version the build engine uses for each project by right clicking on the project, select Properties
, Select the Build
section, click on Advanced...
, set Language version
to whichever version your CI server works with. Once you do this the build will fail when you build locally on any C#7.0 features.
Alternately you could try to get your CI server upgraded to work with C#7.0.
Upvotes: 8