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

VS Code extension: Do not warn about unused usings #315

Closed
dougbu opened this issue May 12, 2016 · 13 comments
Closed

VS Code extension: Do not warn about unused usings #315

dougbu opened this issue May 12, 2016 · 13 comments
Labels

Comments

@dougbu
Copy link
Member

dougbu commented May 12, 2016

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.

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

@Eilon
Copy link
Member

Eilon commented May 12, 2016

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.

@eamodio
Copy link
Contributor

eamodio commented Jun 14, 2016

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

@kurzemnieks
Copy link

Any solution for this?

@CanisLupus
Copy link

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

@DustinCampbell
Copy link
Member

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.

@Eilon
Copy link
Member

Eilon commented Feb 8, 2017

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.

@DustinCampbell
Copy link
Member

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).

@Eilon
Copy link
Member

Eilon commented Feb 8, 2017

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.

@DustinCampbell
Copy link
Member

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

@Eilon
Copy link
Member

Eilon commented Feb 8, 2017

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!

@DustinCampbell
Copy link
Member

It is annoying. Agreed 100%. 😄

I (finally) filed an official request on VS Code for faded code: microsoft/vscode#20219.

@Eilon
Copy link
Member

Eilon commented Feb 8, 2017

Thanks!

@DustinCampbell
Copy link
Member

(Very glad to see you here @Eilon 😄)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants