Closed ercgeek closed 4 years ago
@ercgeek which scripting mechanism are you using with the C# code?
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.
@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: true
in 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
Excellent, thanks much.
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.
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
C# log
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-downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |csharp|ms-dotnettools|1.21.17| |LiveServer|ritwickdey|5.6.1|;