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

Feature Request - Suppress Diagnostics #3746

Closed
ercgeek opened this issue Apr 26, 2020 · 5 comments
Closed

Feature Request - Suppress Diagnostics #3746

ercgeek opened this issue Apr 26, 2020 · 5 comments

Comments

@ercgeek
Copy link

ercgeek commented Apr 26, 2020

Issue Description

This is not an issue, is a request for an additional configuration option: "Suppress Diagnostics". When checked on the extension would perform all other C# functionality but would not report diagnostic errors or warnings. Similar to "Suppress Hidden Diagnostics" but suppressing all diagnostics.

This feature would allow another extension to associate with "csharp" documents and provide diagnostics that override the OmniSharp diagnosticsProvider entries.

In my use case my custom app uses C# as its scripting mechanism. The C# written is valid C# but without namespace & class wrappers and with some classes, members and methods predefined. VS Code is a great front-end to edit these scripts but the diagnostics from OmniSharp are not relevant to the scripts.

Alternatively, provide a mechanism for another extension to turn diagnosticsProvider off programatically.

Steps to Reproduce

Expected Behavior

When "Suppress Diagnostics" is true the extension would not report diagnostic errors or warnings

Actual Behavior

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.44.2
C# Extension: 1.21.17

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.201 Commit: b1768b4ae7

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

Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8

.NET Core SDKs installed:
3.1.201 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

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

Visual Studio Code Extensions
Extension Author Version
csharp ms-dotnettools 1.21.17
LiveServer ritwickdey 5.6.1
@cartermp
Copy link

@ercgeek which scripting mechanism are you using with the C# code?

@ercgeek
Copy link
Author

ercgeek commented Apr 29, 2020

I use an older library called Westwind.wwScripting. My app wraps the C# user code with a namespace and class definition plus some predefined members and methods before calling wwScripting for execution. If wwScripting finds any C# errors I want to report them back as VS Code problems.

I had posted a question in StackOverflow before I understood better how OmniSharp C# extension works - https://stackoverflow.com/questions/61310404/vs-code-c-sharp-extension-extending-further

I've tested the idea by modifying OmniSharp extension in two places: 1) adding the "Supress Diagnostics" settings option in package.json and 2) adding a few lines of code to diagnosticsProvider.ts to read the settings and prevent reporting the diagnostics to VS Code when "Suppress Diagnostics" is true.

I realize my use case is unique, would welcome other ideas on how to do what I need if adding this feature is not valuable to the overall OmniSharp extension user base.

@JoeRobich
Copy link
Member

@ercgeek The next release of the C# extension (or set omnisharp.path: "latest" in settings.json right now) will be using Roslyn's .editorconfig support which includes the ability to configure the severity of diagnostics. After setting omnisharp.enableEditorConfigSupport: truein settings.json, You could simply add an .editorconfig in your script folder with the following:

root = true

[*.cs]
# Default severity for all analyzer diagnostics
dotnet_analyzer_diagnostic.severity = silent

@ercgeek
Copy link
Author

ercgeek commented Apr 29, 2020

Excellent, thanks much.

@ercgeek ercgeek closed this as completed Apr 29, 2020
@marcospgp
Copy link

For those wondering: @JoeRobich 's code should be added to a .editorconfig file at the project root, next to the .csproj files if you have any.

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

No branches or pull requests

4 participants