Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analyzers warnings in ASP.NET Core 2.2 project in VS2019

I have what is basically a default ASP.NET Core 2.2 project created from the default Razor Pages templates.

Now, in solution explorer -> Dependencies there is a node called "Analyzers".

First of all, at first I had no idea what it was for. I think I know now but it's still kind of fuzzy.

Secondly, why does it have a warning icon? Same with its child nodes.

Note: I'm not under the "NuGet" node, so this is not a question about missing dependencies or anything like that.

And thirdly; why is this "feature" there if it's only there to confuse me?!

enter image description here

like image 207
PussInBoots Avatar asked May 06 '19 18:05

PussInBoots


People also ask

What are analyzers in .NET core?

ASP.NET Core provides an MVC analyzers package intended for use with web API projects. The analyzers work with controllers annotated with ApiControllerAttribute, while building on web API conventions. The analyzers package notifies you of any controller action that: Returns an undeclared status code.

Is Visual Studio code good for asp net?

Visual Studio Code lets you write ASP.NET Core applications by leveraging all of the evolved editing features available to C# and to the other file types in the project. Being a cross-platform itself, it's the perfect companion to start writing MVC applications for Linux, OS X and Windows.

How do I open an ASP NET project in Visual Studio?

Start Visual Studio, on the File menu select New, and then select Project. In the New Project dialog box, select Visual Basic or Visual C# as the programming language. In the Templates pane, select ASP.NET Empty Web Application, and name the project SofiaCarRentalWebApp. Click OK to create the solution and the project.


2 Answers

I had the same issue. After I restarted Visual Studio with Administrator privileges, Analyzers titles started to show the name instead of the path and the "warning" is gone.

EDIT

There is a GiHub issue about it.

A temporary fix would be to close the solution and to delete .dtbcache file in the .vs folder.

like image 140
Pavel Shastov Avatar answered Oct 06 '22 14:10

Pavel Shastov


The warnings under each analyzer assembly are issues found in your code. Found by rules in those assemblies.

With the introduction of the Roslyn compilers it has become easier to analyse your sourcecode even before the compiler runs. These rules are packaged in special nuget packages. When these rules run they show in the error window and in this list.

If a rule misbehaves, or you want to turn it off or you want to look at just the MVC rules, this view is quite useful.

When analyzers themselves run into issues (some are not as good as others) the respective issues are also shown here. It looks like the RS* rules are actually issues with the rules themselves.

like image 35
jessehouwing Avatar answered Oct 06 '22 13:10

jessehouwing