18

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

PussInBoots
  • 11,028
  • 9
  • 52
  • 84
  • 1
    It tells you about code smell and bad practices and it's there to help you follow best practices :P – Tseng May 06 '19 at 18:44
  • 3
    @Tseng okay, but I did not write those libraries/.dlls marked with that warning triangle. Why is it showing me stuff that I have no power over? – PussInBoots May 06 '19 at 18:45

4 Answers4

11

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.

Pavel Shastov
  • 2,657
  • 1
  • 18
  • 26
2

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.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • 11
    I understand what you're saying but I don't understand how those .dlls are MY code. I didn't write those. Neither does the individual rules under each .dll say in which file my issues are in MY own files. The most intuitive thing that I can come up with is if I double click on one of those rules VS should automatically take me to that piece of code? – PussInBoots May 06 '19 at 22:25
  • 2
    I have the same issue with a freshly-generated and empty aspnet core 3.1 api project. One issue it reports is "ASP0000: Do not call 'IServiceCollection.BuildServiceProvider' in 'ConfigureServices'". The only line of code in that method is "services.AddControllers();" which I did not put there. Therefore, the reported issue is not mine for two reasons: First, I did not write this code, it was scaffolded by the framework. Second, the issue it is reporting is flat-out wrong. – Charles Josephs Dec 12 '19 at 15:00
  • @CharlesJosephs https://stackoverflow.com/questions/58804132/asp-net-core-3-0-disable-asp0000-do-not-call-iservicecollection-buildservicepr – jessehouwing Dec 12 '19 at 20:10
  • No, this is flat out wrong, those warnings aren't issues in our code, those are issues in the dependency DLLs. They are utterly useless, if they can't be used to navigate to the source of the issue. Moreover, we shouldn't be fixing warnings in nugets that come from Microsoft. And guess what, they appear even on empty ASP net core template projects that are developed by MS. – HamsterWithPitchfork Feb 13 '20 at 18:24
0

In my case, the warnings disappeared after I set net core 3.1 as target framework in project properties.

0

I've had the same issue. I think its because of the "C:\Program Files\dotnet" folder perssion. you can open the visual studio by Run as Administrator or give the folder all permission in security folder. I did it and my proplem was resolved.