Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary imports on save not working #4401

Closed
snebjorn opened this issue Feb 16, 2021 · 0 comments · Fixed by #4717
Closed

Remove unnecessary imports on save not working #4401

snebjorn opened this issue Feb 16, 2021 · 0 comments · Fixed by #4717

Comments

@snebjorn
Copy link

Issue Description

According to OmniSharp/omnisharp-roslyn#1581 then codeActionsOnSave should be able to fix issues on save.

"editor.codeActionsOnSave": {
  "source.fixAll.csharp": true
}

But I can't get it to remove unnecessary imports on save.
I can however run the fixes manually via the command palette.

image

I've included the OmniSharp log for running these manually.
Also why is there two for removing unused imports?
And shouldn't the CS8019 be IDE0005?

I have the following settings:

"[csharp]": {
  "editor.codeActionsOnSave": {
    "source.fixAll.csharp": true
  }
},
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.organizeImportsOnFormat": true

organizeImportsOnFormat does work, so something is working :)

Steps to Reproduce

Add an unused import statement, like using System.Buffers;. Then save.

Expected Behavior

using System.Buffers; should be removed.

Actual Behavior

using System.Buffers; isn't removed.

Logs

OmniSharp log

[info]: OmniSharp.Roslyn.CSharp.Services.Refactoring.RunFixAllCodeActionService Fixing CS8019. [info]: OmniSharp.Roslyn.CSharp.Services.Refactoring.RunFixAllCodeActionService Fixing RemoveUnnecessaryImportsFixable.

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.53.2
C# Extension: 1.23.9

Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.101 Commit: d05174dc5a

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.101\

Host (useful for support):
Version: 5.0.1
Commit: b02e13abab

.NET SDKs installed:
2.2.401 [C:\Program Files\dotnet\sdk]
3.1.404 [C:\Program Files\dotnet\sdk]
5.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
Angular-BeastCode Mikael 10.0.3
angular-console nrwl 16.0.2
angular-schematics cyrilletuzi 4.10.1
angular-spectator-snippets NetanelBasal 0.0.2
auto-barrel mikehanson 1.9.0
better-align wwm 1.1.6
better-comments aaron-bond 2.1.0
bracket-pair-colorizer-2 CoenraadS 0.2.0
code-spell-checker streetsidesoftware 1.10.2
csharp ms-dotnettools 1.23.9
debugger-for-chrome msjsdiag 4.12.12
docomment k--kato 0.1.20
dotnet-interactive-vscode ms-dotnettools 1.0.211402
dotnet-test-explorer formulahendry 0.7.5
EditorConfig EditorConfig 0.16.4
github-actions formulahendry 0.0.1
gitlens eamodio 11.2.1
jbockle-format-files jbockle 3.0.0
markdown-all-in-one yzhang 3.4.0
markdown-mermaid bierner 1.9.2
mermaid-markdown-syntax-highlighting bpruitt-goddard 1.2.0
ng-template Angular 11.2.0
ng-zorro-vscode cipchk 11.1.1
openapi-designer philosowaffle 0.3.0
prettier-vscode esbenp 5.9.2
sort-js-object-keys zengxingxin 1.0.6
user-secrets adrianwilczynski 2.0.1
vscode-dotnet-runtime ms-dotnettools 1.0.0
vscode-drawio hediet 1.3.0
vscode-eslint dbaeumer 2.1.14
vscode-icons vscode-icons-team 11.1.0
vscode-openapi 42Crunch 3.10.0
vscode-pull-request-github GitHub 0.23.1
vscode-sql-formatter adpyke 1.4.4
vscode-stylelint stylelint 0.86.0
vscode-typescript-tslint-plugin ms-vscode 1.3.3
vscode-versionlens pflannery 1.0.9
vscode-yaml redhat 0.15.0
vscodeintellicode VisualStudioExptTeam 1.2.11
vsliveshare ms-vsliveshare 1.0.3629
xml DotJoshJohnson 2.5.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant