Roslyn: Unexpected message level diagnostics in error list

Created on 14 Jul 2020  路  14Comments  路  Source: dotnet/roslyn

Version Used:
Version 16.8.0 Preview 1.0 [30313.6.master]

Steps to Reproduce:

  1. Open a solution
  2. Enable the "Messages" tab on the error list

Expected Behavior:
A relatively clean error list, even with Messages enabled (at least, for people that care about code style).

Actual Behavior:
A bunch of message level diagnostics in the Error List for things that I wouldn't expect to see there. For example:

Severity    Code    Description Project File    Line    Suppression State
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Data\AreaStatsByWeek.cs 60  
Message IDE0046 'if' statement can be simplified        C:\Code\YouHaveIssues\YouHaveIssues\AzureAuthenticationService.cs   57  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\AzureAuthenticationService.cs   85  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Data\AreaStatsByWeek.cs 61  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Data\AreaStatsByWeek.cs 96  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Data\AreaStatsByWeek.cs 97  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\KustoContext.cs 67  
Message IDE0005_gen Using directive is unnecessary.     C:\Code\YouHaveIssues\YouHaveIssues\obj\Debug\netcoreapp3.1\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs  2   
Message RemoveUnnecessaryImportsFixable         C:\Code\YouHaveIssues\YouHaveIssues\obj\Debug\netcoreapp3.1\.NETCoreApp,Version=v3.1.AssemblyAttributes.cs  2   
Message IDE0005_gen Using directive is unnecessary.     C:\Code\YouHaveIssues\YouHaveIssues\obj\Debug\netcoreapp3.1\YouHaveIssues.AssemblyInfo.cs   11  
Message RemoveUnnecessaryImportsFixable         C:\Code\YouHaveIssues\YouHaveIssues\obj\Debug\netcoreapp3.1\YouHaveIssues.AssemblyInfo.cs   11  
Message IDE0005_gen Using directive is unnecessary.     C:\Code\YouHaveIssues\YouHaveIssues\obj\Debug\netcoreapp3.1\YouHaveIssues.RazorAssemblyInfo.cs  11  
Message RemoveUnnecessaryImportsFixable         C:\Code\YouHaveIssues\YouHaveIssues\obj\Debug\netcoreapp3.1\YouHaveIssues.RazorAssemblyInfo.cs  11  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Program.cs  33  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\RepositoryConfig.cs 11  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  28  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  31  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  39  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  40  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  42  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  43  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  46  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  57  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  59  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  60  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  61  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  69  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  73  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  75  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  78  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  79  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  81  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  83  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  84  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  86  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  88  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  89  
Message IDE0058 Expression value is never used      C:\Code\YouHaveIssues\YouHaveIssues\Startup.cs  90  
Area-IDE Bug Investigation Required

Most helpful comment

Thanks @ryanbrandenburg @Pilchie - I confirmed this only happens when Razor LSP Preview experience enabled in Tools\Options\Environment\Preview Features.

I investigated it and this seems to be an issue specific to LSP - tagging @dibarbet @allisonchou, more specifically the fact that LSP does not have concept of hidden diagnostics and treats them equivalent to info/message diagnostics: https://github.com/dotnet/roslyn/blob/f14fd53433507d9d5664cb1d0836ec8fcb5606b9/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs#L197-L200

All 14 comments

YouHaveIssues Kevin

I am unable to repro this on a simple project with IDE0058 violation on latest 16.8 drop:

Microsoft Visual Studio Enterprise 2019 Int Preview
Version 16.8.0 Preview 1.0 [30313.166.master]
VisualStudio.16.IntPreview/16.8.0-pre.1.0+30313.166.master

image

Also unable to repro it on Roslyn.sln. @Pilchie, you sure you don't have any .editorconfig severity overrides?

I do not have an editorconfig in this project.

@Pilchie Are you still seeing this issue? I am unable to repro it on latest builds on either small projects or real world projects.

@mavasani I'm seeing what I assume is the same or a similar issue, though in a slightly different context.

Repro Steps:

  1. Latest VS Master, File->New->Project->Blazor App (I chose Blazor server but I don't think it should matter).
  2. Tools->Options->Preview Features->Check Enable experimental Razor editor (requires restart).
  3. Restart VS.
  4. Open Shared/NavMenu.razor
  5. View->Error List
  6. Give it a couple seconds, after which you should see ~9 messages, mostly IDE0005_gen, with one RemoveUnnecessaryImportsFixable.
  7. Open Program.cs, add an unused using if none already exist. See that IDE0005's are shown.
    image
    image

Interestingly I attempted to add #pragma's for IDE0005_gen to the imports in their CodeGen and it did not resolve the issue.

Yes, I have still been seeing this, though I was OOF last week.

Could this be related to having the Razor LSP Preview experience enabled in Tools\Options\Environment\Preview Features somehow?

Thanks @ryanbrandenburg @Pilchie - I confirmed this only happens when Razor LSP Preview experience enabled in Tools\Options\Environment\Preview Features.

I investigated it and this seems to be an issue specific to LSP - tagging @dibarbet @allisonchou, more specifically the fact that LSP does not have concept of hidden diagnostics and treats them equivalent to info/message diagnostics: https://github.com/dotnet/roslyn/blob/f14fd53433507d9d5664cb1d0836ec8fcb5606b9/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs#L197-L200

@dibarbet @allisonchou I have assigned the issue to you.

There are two parts here

  1. Razor is activating the regular C# lsp server w/out the DisableUserExperience attribute - this caused the LSP diagnostics on non-razor files. PR here - https://github.com/dotnet/aspnetcore-tooling/pull/2320
  2. And Manish is correct there are no hidden diagnostics in LSP yet, though a fix for that is set to be available soon. Will see if I can work-around for the moment.

For 1) dotnet/aspnetcore-tooling#2320 will fix the diagnostics showing up for .cs files, however they will still show up for .razor files.

For 2), I just saw that support for pull model and hidden diagnostics is merged into the LSP client (pending VS insertion). My proposal here is to wait for that to be inserted and just switch to pull model with full support for hidden diagnostics in a few days.

I know switching to pull model will require changes on the razor side, so wanted to ask if that was do-able. cc @NTaylorMullen @ryanbrandenburg

I know switching to pull model will require changes on the razor side, so wanted to ask if that was do-able. cc @NTaylorMullen @ryanbrandenburg

Would definitely be possible but we should coordinate when that work goes in.

@CyrusNajmabadi assigning to you - these should disappear with proper hidden diagnostic support

I've been having the issue shown by @ryanbrandenburg for a while now and I see that you are working on it, but is there an established release date for the fix or a specific 16.9 preview you are targeting?

Was this page helpful?
0 / 5 - 0 ratings