Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lots of squiggly lines after updating to .net core 2.1 - 'may need to supply run time policy'

Tags:

Don't know why I did, but I updated to .Net Core 2.1 yesterday. Ever since I updated, I am seeing tons of squiggly lines throughout my solution in Visual Studio on mac (so annoying). Here's the warning message -

enter image description here

I think understand the source of the warning. Basically, I am referencing to a lot of 3rd party Nuget packages (Autofac, Serilog, etc.) and they are built with an older version of .Net Core. This is what the warning is trying to tell me I think. But my code works just fine, don't have any issues running it.

After researching a little bit, I think the error is CS1701. It is also added [by default] to be ignored in the Compiler settings for all projects in my solution. This is why I am not seeing this warning reported when I build my project/solution. However, the squiggly's are still shown in the text editor in Visual Studio.

Visual Studio is kind enough to offer a solution to suppress these squiggly lines, by adding a pragma statement at the top of .cs file - #pragma warning disable CS1701 // Assuming assembly reference matches identity. But I am afraid I need to add this line to all .cs file in my solution (there are a lot).

Does anyone know any other better way to suppress these squiggly lines in the text editor, please?

like image 829
scorpion35 Avatar asked Dec 04 '18 16:12

scorpion35


1 Answers

Goto Preferences->Text Editor -> Source Code Analysis -> Code Rules (tab) and change the line Rule Id="CS1701" Action="Warning" to
Rule Id="CS1701" Action="Hidden" and press OK.

Wait a for a short while and the lines will disappear.

like image 153
Tim Avatar answered Oct 11 '22 16:10

Tim