Open BinaryTENSHi opened 6 months ago
Just start having the same problem... I would also note that the somewhat required dotnet build
before dotnet format
(to make sure all source generated file are present) doesn't help. I was already using net8 for some time but just recently updated to 8.0.204 SDK so the breaking must happened somewhere between those versions. Can repro locally and on our build machine via azure pipelines too (where same SDK version is installed.)
Visual studio: 17.9.6
dotnet sdk: 8.0.204
dotnet runtime: 8.0.4
Having the same issue where dotnet format style
removes used imports. When running dotnet format style -v detailed
I get the output:
error IDE0005: Using directive is unnecessary
Which then removes the import. When running dotnet build
after, I receive following output:
error CS0246: The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)
dotnet runtime version: 8.0.6
dotnet CLI/SDK version: 8.0.301
running dotnet format
with Windows Terminal
Just want to bump this as we are also hit by this now. Both on SDK 8.0.400 and 8.0.304 (runtime 8.0.8)
Describe the bug
Running
dotnet format --verify-no-changes
reports aerror IDE0005: Using directive is unnecessary.
false positive when the namespace is from a used class that was generated using a Roslyn source generator.Running
dotnet format
removes theusing {namespace};
which then leads to a compilation error afterward.To Reproduce
I have created a minimal reproducible example here: https://github.com/BinaryTENSHi/dotnet-format-source-generator
dotnet format --verify-no-changes
Running
dotnet format
and thendotnet build
results in a compilation error.Further technical details
.NET SDK
8.0.204