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

Watch .editorconfig for changes #1904

Closed
loligans opened this issue Jul 24, 2020 · 3 comments · Fixed by #2028
Closed

Watch .editorconfig for changes #1904

loligans opened this issue Jul 24, 2020 · 3 comments · Fixed by #2028

Comments

@loligans
Copy link

Issue Description

When a user edits their .editorconfig file Omnisharp does not reload the .editorconfig configuration. In order for the new configuration to be used, Omnisharp must be restarted.

Note: It is not enough to force Omnisharp to re-analyze all projects, Omnisharp must be restarted for the changes to take effect.

Steps to Reproduce

  1. Simply modify your .editorconfig

Expected Behavior

Omnisharp re-analyzes using the updated configuration.

Actual Behavior

Omnisharp does nothing until the user restarts Omnisharp.

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.47.2
C# Extension: 1.22.1

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.302 Commit: 41faccf259

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

Host (useful for support):
Version: 3.1.6
Commit: 3acd9b0cd1

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

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.6 [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.22.1
docomment k--kato 0.1.14
errorlens usernamehw 3.1.1
gitlens eamodio 10.2.2
msbuild-project-tools tintoy 0.3.8
remote-wsl ms-vscode-remote 0.44.4
vscode-versionlens pflannery 1.0.8
@filipw filipw transferred this issue from dotnet/vscode-csharp Aug 20, 2020
@filipw
Copy link
Member

filipw commented Aug 20, 2020

could you please provide some more details? e.g. a sample csproj you have, which setting you are trying to change, and which exact steps you did follow?

We run a file watcher over editorconfig so it should definitely work -

_fileSystemWatcher.Watch(".editorconfig", (file, changeType) =>
{
QueueProjectUpdate(projectFileInfo.FilePath, allowAutoRestore: false, projectFileInfo.ProjectIdInfo);
});

@loligans
Copy link
Author

@filipw I will provide a project sample in a followup comment.

Regarding the code snippet you provided, does it watch nested .editorconfig files when a single project has multiple .editorconfig's?

I saw that it does handle parent .editorconfig files but I don't know if that is the same thing. In the below tree, the parent .editorconfig to MyProject1 would be the .editorconfig for MySolution.sln

->MySolution.sln
->.editorconfig
->MyProject1/
--->.editorconfig
----->Autogenerated_Files/
------->.editorconfig
->MyProject2/
--->.editorconfig

@loligans
Copy link
Author

I was mistaken. It looks like the modified .editorconfig is captured just like you said, but the analysis is only triggered after manually running: OmniSharp: Analyze All Projects or OmniSharp: Analyze Current Project

Note: Closing and reopening the file does not cause the file to be re-analyzed.

To me it feels like modifying the .editorconfig should trigger a re-analysis of some kind. Take the following for example:

  • Re-Analyze all open documents first
  • Re-Analyze all effected projects second

When updating the .editorconfig the following OmniSharp logs are generated:

[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Development\github.com\loligans\OmnisharpTests\OmnisharpTests.Terminal\OmnisharpTests.Terminal.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Development\github.com\loligans\OmnisharpTests\OmnisharpTests.Library\OmnisharpTests.Library.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Development\github.com\loligans\OmnisharpTests\OmnisharpTests.Terminal\OmnisharpTests.Terminal.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Development\github.com\loligans\OmnisharpTests\OmnisharpTests.Terminal\OmnisharpTests.Terminal.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Development\github.com\loligans\OmnisharpTests\OmnisharpTests.Library\OmnisharpTests.Library.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Development\github.com\loligans\OmnisharpTests\OmnisharpTests.Library\OmnisharpTests.Library.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: OmnisharpTests.Terminal
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: OmnisharpTests.Library

When manually running OmniSharp: Analyze All Projects the following OmniSharp logs are generated:

[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.ReAnalyzeService
        Queue analysis for all projects.

When manually running OmniSharp: Analyze Current Project the following OmniSharp logs are generated:

[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.ReAnalyzeService
        Queue analysis for project(s) (ProjectId, #54a442aa-dc7f-4c69-b819-3ef4280c0362 - )

Test notes

Attached is the sample project I used to gather the above logs. I modified the OmniSharpTests.Terminal project's .editorconfig file to showcase what I am talking about.
Change : OmnisharpTests.Terminal/.editorconfig:dotnet_diagnostic.CS1998.severity from none to warning
OmnisharpTests.zip

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