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

Omnisharp randomly ignores editorconfig settings, requires restart #4184

Closed
stewartadam opened this issue Nov 5, 2020 · 7 comments · Fixed by OmniSharp/omnisharp-roslyn#2028

Comments

@stewartadam
Copy link

stewartadam commented Nov 5, 2020

Issue Description

I have editorconfig and roslyn analyzers support both enabled in my omnisharp preferences, and a .editorconfig in my repo root that applies for all projects in the tree.

Omnisharp generally does pick up on this and respect the settings, however seemingly at random Omnisharp will drop the editorconfig settings and revert to the default rule set and make recommendations against the editorconfig. Specifically, this is present in editorconfig:

dotnet_diagnostic.SA1101.severity = none
dotnet_style_qualification_for_field = false:error

After some time, when the bug triggers I'll start seeing recommendations for SA1101 to remove 'this'. Restarting omnisharp fixes the issue (temporarily).

Steps to Reproduce

Load C# project and edit it

Expected Behavior

omnisharp respects editorconfig; don't have to constantly restart omnisharp

Actual Behavior

Have to restart omnisharp every few minutes

Logs

OmniSharp log

Debug log has some details from a private repo; reach out to me directly for logs

C# log

See above

Environment information

VSCode version: 1.50.1
C# Extension: 1.23.5

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.403 Commit: 9e895200cd

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/3.1.403/

Host (useful for support):
Version: 3.1.9
Commit: 774fc3d6a9

.NET Core SDKs installed:
3.1.403 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

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

Visual Studio Code Extensions
Extension Author Version
aadb2c AzureADB2CTools 1.2.93
azure-account ms-vscode 0.9.3
azurerm-vscode-tools msazurermtools 0.13.0
code-spell-checker streetsidesoftware 1.9.2
cortex-debug marus25 0.3.7
cpptools ms-vscode 1.0.1
csharp ms-dotnettools 1.23.5
CursorColumnSelectOnTrueLines martinzimmermannapps 0.0.2
docomment k--kato 0.1.18
EditorConfig EditorConfig 0.15.1
gitlens eamodio 10.2.3
go golang 0.18.1
kubernetes-context Okteto 0.1.0
markdown-all-in-one yzhang 3.3.0
markdown-mermaid bierner 1.8.1
markdown-preview-enhanced shd101wyy 0.5.13
mssql ms-mssql 1.9.0
prettier-vscode esbenp 5.7.1
python ms-python 2020.10.332292344
remote-wsl ms-vscode-remote 0.50.1
scala scala-lang 0.4.5
sublime-keybindings ms-vscode 4.0.7
terraform hashicorp 2.2.3
vscode-azurefunctions ms-azuretools 1.0.0
vscode-azureresourcegroups ms-azuretools 0.2.0
vscode-azurestorage ms-azuretools 0.11.0
vscode-cosmosdb ms-azuretools 0.15.0
vscode-docker ms-azuretools 1.7.0
vscode-dotnet-adapter derivitec-ltd 1.4.3
vscode-dotnet-runtime ms-dotnettools 0.1.2
vscode-drawio hediet 1.0.3
vscode-html-css ecmel 0.2.3
vscode-icons vscode-icons-team 11.0.0
vscode-kubernetes-tools ms-kubernetes-tools 1.2.1
vscode-markdownlint DavidAnson 0.37.2
vscode-node-azure-pack ms-vscode 0.0.11
vscode-solution-explorer fernandoescolar 0.3.11
vscode-test-explorer hbenl 2.19.1
vscode-yaml redhat 0.12.0
vsliveshare ms-vsliveshare 1.0.3121
xml DotJoshJohnson 2.5.1
@JoeRobich
Copy link
Member

@stewartadam Not sure if it is a typo, but editorconfig files do not have a ".json" extension. They should simply be named .editorconfig

@stewartadam
Copy link
Author

Thx, it was a typo -- can confirm the file is .editorconfig in my repo.

@demdh
Copy link

demdh commented Nov 11, 2020

I can confirm the problem. I also have to restart OmniSharp constantly to get rid of warnings that appear because the .editorconfig settings are not taken into account.
Unfortunately I'm unable to deliver a repro because I can't identify the cause. The whole thing happens after a few minutes.
A restart of VS Code does not bring any relief.

@stewartadam
Copy link
Author

fwiw, I've noticed it pretty consistently on Azure Function projects if I run 'dotnet clean' and delete the .vscode/ folder. When subsequently opening the folder in VS Code, a few prompts show up to restore projects, initialize the project for use with VS Code, and initialize the project for use with Functions.

You click yes, yes, yes... and by the time it's all done, omnisharp is loaded but ignores editorconfig.

@mareklinka
Copy link

Started seeing the same behavior with C# extension 1.23.6. For me, the trigger that causes OmniSharp to start ignoring the .editorconfig file is rebuild (dotnet build --no-incremental).

When I load the workspace for the first time, everything works fine and all settings are respected. The moment I rebuild, OmniSharp outputs the following:

[info]: OmniSharp.MSBuild.ProjectManager
        Update project: DataAccess
[dbug]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Project (ProjectId, #05540e1b-acf3-411e-a483-fcf6e1193800 - ) updated, reanalyzing its diagnostics.
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: DataModel
[dbug]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Project (ProjectId, #6fc4b559-c765-4dd6-9195-76957c62eae4 - ) updated, reanalyzing its diagnostics.
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Server.Domain
[dbug]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Project (ProjectId, #2b300a91-eb43-4573-91bc-96d45496b6e0 - ) updated, reanalyzing its diagnostics.
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Graph
[dbug]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Project (ProjectId, #119d988c-3db9-4f3d-9483-7c4e5e1abcdf - ) updated, reanalyzing its diagnostics.
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: ExcelExport
[dbug]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Project (ProjectId, #833150d6-577d-4c1a-8fc4-997b72a1f13e - ) updated, reanalyzing its diagnostics.

After that, all settings in the .editorconfig file are ignored and the only thing that fixes it is to restart omnisharp.

@junpeikun
Copy link

I am seeing the same behavior in my Unity projects and that happens everytime I create a C# file inside the Unity editor. When I do that, I switch back to VS Code and I get welcomed by a bunch of warnings and sqwiggly lines. An omnisharp restart gets rid of that but it is annoying in the long run.

@onionhammer
Copy link

This appears to be happening for me.. when I run dotnet build it works, but when I click 'Debug Test' on a unit test, it shows all kinds of build errors like CA1707 and CA1000

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