Disable "C# 7.0 language feature" errors inside of razor

Completed

Hey I have recently updated my project to support having c# 7 language features inside of razor syntax. Which works completely fine when I run it/compile the views. However it seems like resharper constantly has error warnings in the code saying "C# 7.0 language feature" which makes it seem like it will fail. Which is really annoying. These errors go away if I suspend resharper. I have not been able to figure out where to fix this issue.

I updated my proj to support c#7 by using the `Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider` nuget package and the web config updates going with it.

Can anyone point me to where I can disable this error or make resharper realise that my proj now supports this? See screenshot below below

I have Resharper Ultimate 2017.1.1

1
9 comments

@Kadajgw, can you, please, provide example of your web.config file (with necessary directives for C# 7.0 compiler).

0
Avatar
Permanently deleted user

My web config is pretty massive but this was the main bit that changed for the c#7 stuff

 

<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:7 /nowarn:1659;1699;1701" />
</compilers>
</system.codedom>

0

Yes, that should work. I am afraid we need some small repro project to reproduce the problem.

0
Avatar
Permanently deleted user

It works fine in my demo project :) haha. Any ideas what I could look for in my other project? It's quite an old bulky solution 

0
Avatar
Permanently deleted user

I think I'm having the same issue, except this is for a .NET Core 1.1 app, which shouldn't use web.config, since that is for IIS hosting, right?

I added:

 <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.2.0" />

Which made it so I can render Razor views that contain C# 7 features, but I still see an error message in the IDE:

Edit: I should have mentioned, I'm using VS2017 15.0.26430.12 and R# 2017.1.2.

1

HEllo @wyatterman!

 

Could you please try to install ReSharper 2017.2 latest EAP build - https://www.jetbrains.com/resharper/eap/ and check if the problem is still reproduced?

Is there any chance you could provide sample solution?

Thank you.

0
Avatar
Permanently deleted user

Hey,

 

I would just like to say that the new build you mentioned solves my issue Angelina.

 

Thanks :)

0

 Great! :) Thank you for letting know.

0

Quick addendum to mention that the 2017.2 EAP also solved this issue on my end. In my case this was caused by the /langversion parameter in the web.config. The recent updates to Microsoft.CodeDom.Providers.DotNetCompilerPlatform started putting 'default' there, which made ReSharper flag any usage of C#6+ as an error, unless I put the numeric version back in.

The current EAP seems to work fine with both 'default' and 'latest', so yay \o/

0

Please sign in to leave a comment.