Omnisharp-vscode: Add option to make 'unnecessary using directive' diagnostics to appear

Created on 26 Apr 2017  路  8Comments  路  Source: OmniSharp/omnisharp-vscode

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.1)

Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1

Runtime Environment:
OS Name: fedora
OS Version: 25
OS Platform: Linux
RID: fedora.24-x64
Base Path: /opt/dotnet/sdk/1.0.1

VS Code version: 1.11.2
C# Extension version: 1.9.0

Steps to reproduce

Add an unnecessary using statement.

Expected behavior

A diagnostic info message about the unnecessary using statement.
using

Actual behavior

No diagnostic info message is shown and the using statement is not highlighted.

Feature Request Resolved-Fixed

Most helpful comment

At least __don't agree__ with removing the __wavy underline__ in the editor for those unnecessary using directives! without those signs in the editor so we __cannot__ spot them anymore, would u expect us to move the cursor __each line by line__ in __each .cs file__ to find out unnecessary using directives?! this change makes the Remove Unnecessary Usings __totally useless__.

All 8 comments

vscode 1.12.0, c# extension 7439ef476f038e927604fe3f9753c7132c2cf42d commit (after 1.9.0 release) - same behaviour.

This is by design. We suppressed this message in the PR to https://github.com/OmniSharp/omnisharp-vscode/issues/1231. Eventually, we hope to have faded code support in VS Code so we can provide this information a bit more unobtrusively (https://github.com/Microsoft/vscode/issues/20219 tracks this).

Note that the light bulb still appears and works if you move it to an unnecessary using, but we will no longer spam unnecessary using diagnostics.

At least __don't agree__ with removing the __wavy underline__ in the editor for those unnecessary using directives! without those signs in the editor so we __cannot__ spot them anymore, would u expect us to move the cursor __each line by line__ in __each .cs file__ to find out unnecessary using directives?! this change makes the Remove Unnecessary Usings __totally useless__.

I appreciate your passion @cateyes99! Unfortunately, VS Code doesn't make it possible to remove the item from the Problems list (which _many_ complained about) while keeping the squiggle in the editor.

If you like, you can file an issue (or submit a PR) to make this behavior optional. And, eventually, I hope we'll have the ability to fade code as I mentioned before to make this behave more like it does in Visual Studio (in VS, we fade unnecessary using directives but don't just the message in the Error List).

@DustinCampbell pull request to make this configurable.

Nice! I've re-opened, assigned to you, and put in our 1.10 milestone. Thanks very much for the contribution!

Adding the same comment I put in the PR here:

I'm planning to release a new C# for VS Code beta later today or early tomorrow. That will have this setting in it.

@DustinCampbell Probably don't want to go down this route, but this extension _could_ provide unused usings via decorations rather than diagnostics. The TypeLens extension currently does this: https://github.com/kisstkondoros/typelens/blob/master/src/extension.ts#L96

Was this page helpful?
0 / 5 - 0 ratings