format icon indicating copy to clipboard operation
format copied to clipboard

IDE0051 / IDE0052 / IDE0005 issues with 7.0.302 and dotnet format --verify-no-changes

Open ryanbuening opened this issue 1 year ago • 2 comments

With the recent upgrade to 7.0.302, dotnet format --verify-no-changes seems to now be reporting IDE0051 and IDE0052 errors incorrectly in my project.

I'm using Blazor with code behind files and several private members are declared in the code behind file (Foo.razor.cs) but only used in the markup file (Foo.razor).

dotnet format --verify-no-changes also seems to be reporting errors for IDE0005 (using unnecessary) in a razor code behind file, but the using is necessary.

ryanbuening avatar May 17 '23 13:05 ryanbuening

i have the same issue

normandev92 avatar May 18 '23 09:05 normandev92

We are seeing the same issue on 7.0.304, but only on Azure CI (using DotNetCoreCLI@2). Locally it works fine somehow....

Edit: we figured it out:

  1. enabled --verbosity diag when calling "dotnet format"
  2. we noticed that one of the Nuget packages we depend on was complaining about missing .Net 6 (we are moving to .Net 7). It seems this particular package is not built as self-contained and it has some instructions in .targets that call a tool. All tagged using directives were about namespaces in this particular package.
  3. we added an additional UseDotNet@2 task to install the .Net 6*runtime (not SDK) and now everything works correctly for us

Locally if worked because devs usually have multiple .Net SDK installed.

domyalex avatar Jun 21 '23 00:06 domyalex