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

Using IgnoredCodeIssues with legacy C# extension #526

Closed
jlmakes opened this issue Jul 4, 2016 · 10 comments
Closed

Using IgnoredCodeIssues with legacy C# extension #526

jlmakes opened this issue Jul 4, 2016 · 10 comments
Milestone

Comments

@jlmakes
Copy link

jlmakes commented Jul 4, 2016

Environment

  • .NET CLI 1.0.0-preview1-002702
  • Mac OS X 10.11
  • VS Code version: 1.2.1
  • C# Extension version: Legacy C# (Unity development)

Issue

There’s this annoying issue with Unity development and VS Code where you get 99+ warnings instantly upon loading your project because of using System; at the top of virtually every Unity script.

screen shot 2016-07-04 at 4 04 21 pm

Attempted, but Failed Solution

I found this Omnisharp Roslyn Issue (closed) which addresses what I am attempting to do, so I tried adding a omnisharp.json file to my project root with:

{
    "IgnoredCodeIssues": [
        "^Unnecessary using directive.$"
    ]
}

This, as you may already suspect, borks everything and throws a similar error:

System.FormatException: Unsupported JSON token 'StartArray' was found.
Path 'IgnoredCodeIssues', line 2 position 27.

I‘ve described the problem and my failed solution, is there any hope?

tumblr_njmj4xfu2c1s6w6foo1_500

@DustinCampbell
Copy link
Member

Hi! I realize this issue is quite stale. However, I wanted to give you a couple of updates.

First, we've released version 1.5.3 of the C# extension, which should work much better for you if you're still trying to use the Legacy C# extension. Additionally, in the past several months VS Code has made a few UI changes to make it easier to view a large number of diagnostic issues in the Problems pane.

Second, I've created a v1.6-beta2 release of the C# extension that properly handles the <NoWarn/> tag in .csproj files to suppress various warnings. I don't believe this will allow you to specifically disable the "Unnecessary using directives", but we've already downgraded those from warnings. See this page for information on installing beta releases if you interested in trying it out.

@jlmakes
Copy link
Author

jlmakes commented Dec 7, 2016

Thanks for the response @DustinCampbell

Updated Environment

  • .NET CLI 1.0.0-preview2-1-003177
  • Mac OS X 10.11
  • VS Code version: 1.7.2
  • C# Extension version: 1.5.3

The upgrade in C# extension seems to successfully replace the legacy extension with regards to mono support and working with Unity. Also, the warnings have indeed been downgraded to infos, and instead of showing 99+ it now explicitly counts 180 on my particular project.

But every file is still haunted with this...

screen shot 2016-12-07 at 6 19 14 pm

Do you have any suggestions?

@DustinCampbell
Copy link
Member

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

  1. If you have a .csproj project, you can ignore unnecessary using directive warnings by adding the following to the project: <NoWarn>8019</NoWarn>.
  2. 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.

@DustinCampbell DustinCampbell added this to the 1.7 milestone Feb 8, 2017
@skryshi
Copy link

skryshi commented Feb 13, 2017

@DustinCampbell The proposed solution doesn't work for Unity projects. They use .csproj files that get automatically overwritten by Unity on every recompile. So I still got 600+ infos.

@DustinCampbell
Copy link
Member

That's a great point @skryshi. I'm going to do something specific for Remove Unnecessary Usings as part of #1231.

@skryshi
Copy link

skryshi commented Feb 13, 2017

Thank you @DustinCampbell

@skryshi
Copy link

skryshi commented Feb 13, 2017

@DustinCampbell In the meanwhile, is it possible to disable all info messages? I tried setting:

"omnisharp.loggingLevel": "error"

but it still shows info messages in the Problems window.

@DustinCampbell
Copy link
Member

"omnisharp.loggingLevel" only affects the logging of the OmniSharp server itself. You can see this choosing View->Output from the VS Code menu and selecting "OmniSharp Log" from the combobox in the top-right corner of the Output pane.

This doesn't control the diagnostics that the C# compiler produces for your project, which are simply reported by OmniSharp. AFAICT, VS Code does not provide a way to hide various levels of diagnostics (like VS does).

@skryshi
Copy link

skryshi commented Feb 14, 2017

I see, keep hitting a wall :( It's just that this sea of 600+ infos makes it really hard to code in VSCode. I am surprised this isn't voiced more often by Unity3D devs. Will probably have to switch back to the crappy MonoDevelop.

To think of it, there is one more warning type that could drown all signal in noise for Unity3D devs: "... is obsolete." Unity regularly releases updates that cause dozens if not hundreds of these warnings with older assets until they are updated. Which usually takes months if ever.

@DustinCampbell
Copy link
Member

Yup. I totally agree that's it's pretty horrid. That's why I'll be taking a look at Remove Unnecessary Usings specific in 1.8.

Obsolete is probably not something I can help with -- especially if it's a generated project. I'd recommend touching base with Unity to add a for obsolete warnings. Additionally, it might be worth adding a request for VS Code itself (e.g. https://github.com/Microsoft/vscode/issues) to allow turning off the display for info and warning in the Problems window.

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

No branches or pull requests

3 participants