Omnisharp-vscode: VS Code extension: Do not warn about unused `using`s

Created on 12 May 2016  路  13Comments  路  Source: OmniSharp/omnisharp-vscode

The C# extension and VS Code already show recommendations to remove unused usings in any open C# file. However the warnings for this same cleanup recommendation make it more difficult to find real issues in the project. Note projects w/ unused usings build without warnings.

The warnings in the IDE are inconsistent as well: VS code doesn't even show a recommendation to simplify the namespace qualification in the statement below.

``` c#
using System;
using System.Threading.Tasks;

...
var result = System.Threading.Tasks.Task.FromResult(0);
```

For example, in a recently-created project using a VS template:
usings

Bug

Most helpful comment

It is annoying. Agreed 100%. :smile:

I (finally) filed an official request on VS Code for faded code: https://github.com/Microsoft/vscode/issues/20219.

All 13 comments

Indeed, it seems that surfacing these rather minor issues as 鈿狅笍 Warnings is a bit much. Lots of projects have extraneous using statements and showing all of them for an entire project could get tiring.

Is there any way to control what things are considered warnings or errors?

Any solution for this?

I would also like to know how to disable this specific warning.

Hi everyone! In the 1.7 release (due out soon), you should be able to do the following.

  • If you have a .csproj project, you can ignore unnecessary using directive warnings by adding the following to the project: <NoWarn>8019</NoWarn>.
  • If you have a project.json project, you can ignore the unnecessary using directive warnings by adding the following to buildOptions in the project.json: "nowarn": ["8019"]

Hopefully that will address this for everyone here.

Ugh. Is this actually a useful warning though? It's so completely harmless to have extra using's.

It also means that every default ASP.NET Core project will have several dozen of these warnings because default projects always include "a few extra" namespaces because you'll almost certainly need them. E.g. every new CS file typically includes System, System.Linq, System.Collections.Generic, and perhaps some others, yet because they aren't used in the default code, you get a bunch of warnings in your face and it's only because you didn't have a chance to write any code yet.

It's only a warning because VS Code doesn't have the ability to declare a diagnostic that is "hidden" that has a different presentation (such as fading the code).

I'm not sure it's better to have dozens of unimportant warnings than to have nothing at all. If VS Code later adds support for faded code like VS then it's fine. But in the meantime this seems like aggressive behavior for a code editor.

I know at least for me, when I see a 鈿狅笍 Warning in the editor, I go fix it immediately. Something is dangerous and/or wrong with my code! You always fix compiler warnings. But this is 100% innocuous.

Also, to be clear, this was already downgraded to "info" long ago. However, VS Code still displays it with a green squiggle in the editor.

image

Ohhh, that's not as bad then. I think I'd still find it a little annoying, especially if there are ~20 - 30 in a default project. But it's not obnoxious. Thanks!

It is annoying. Agreed 100%. :smile:

I (finally) filed an official request on VS Code for faded code: https://github.com/Microsoft/vscode/issues/20219.

Thanks!

(Very glad to see you here @Eilon :smile:)

Was this page helpful?
0 / 5 - 0 ratings