omnisharp-roslyn icon indicating copy to clipboard operation
omnisharp-roslyn copied to clipboard

.editorconfig rule being ignored

Open marcospgp opened this issue 3 years ago • 14 comments

Issue Description

dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity rule in .editorconfig is ignored.

Expected Behavior

The following .editorconfig file:

image

Should prevent this warning:

image

When the .vscode settings are:

image

and omnisharp.json is:

image

Actual Behavior

Instead, only the = none rule suppressions in .editorconfig work. The last line does not work.

Environment information

VSCode version: 1.52.1 C# Extension: 1.23.8

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.102 Commit: 573d158fea

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

Host (useful for support): Version: 3.1.2 Commit: 916b5cba26

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

.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.2 [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
beautify HookyQR 1.5.0
code-runner formulahendry 0.11.2
csharp ms-dotnettools 1.23.8
debugger-for-chrome msjsdiag 4.12.11
dotenv mikestead 1.0.1
graphql-for-vscode kumar-harsh 1.15.3
prettier-vscode esbenp 5.8.0
unity-debug Unity 3.0.2
vscode-docker ms-azuretools 1.9.1
vscode-eslint dbaeumer 2.1.14
vscode-markdownlint DavidAnson 0.38.0
vscode-standardjs-snippets capaj 0.8.15
vscode-todo-highlight wayou 1.0.4
vscode-typescript-tslint-plugin ms-vscode 1.3.3
vscodeintellicode VisualStudioExptTeam 1.2.10

marcospgp avatar Jan 24 '21 12:01 marcospgp

can you please provide your OmniSharp log and some repro project?

I just tested this scenario and it works as expected for me, toggling

dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary

and

dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity

results in IDE0047 being disabled and enabled correctly.

filipw avatar Jan 24 '21 14:01 filipw

@filipw omnisharp log here:

Starting OmniSharp server at 24/01/2021, 15:03:36
    Target: c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Tavern Tycoon.sln

OmniSharp server started.
    Path: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\OmniSharp.exe
    PID: 20276

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin"
            CscToolExe = csc.exe
            CscToolPath = c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Roslyn
            MSBuildExtensionsPath = c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild
            MSBuildToolsPath = c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Skip loading projects listed in solution file or under target directory because MsBuild:LoadProjectsOnDemand is true.
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon' on host 17808.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.Editor.csproj'
[info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers
        Solution initialized -> queue all documents for code analysis. Initial document count: 0.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Assembly-CSharp.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Assembly-CSharp.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.Editor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.Editor.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Unity.UIElements.Samples.Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Unity.UIElements.Samples
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Unity.UIElements.Samples.Editor
[fail]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 30,
  "Command": "/findusages",
  "Running": true,
  "Success": false,
  "Message": "\"System.InvalidOperationException: Unexpected null\\r\\n   at Roslyn.Utilities.Contract.Fail(String message)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.MapToAppropriateSymbol(ISymbol symbol)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsCoreAsync>d__20.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<DetermineAllSymbolsAsync>d__19.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<FindReferencesAsync>d__8.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__34.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__40.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.<FindReferencesAsync>d__39.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService.<Handle>d__2.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Navigation\\\\FindUsagesService.cs:line 41\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<AggregateResponsesFromLanguageHandlers>d__18.MoveNext()\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 227\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 131\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n   at OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 215\"",
  "Body": null,
  "Seq": 137,
  "Type": "response"
}

I'm not sure how to create a minimal project that reproduces this issue as this is a convoluted unity project. I can give you access to the github repo if that helps, or provide other files or logs as desired. Let me know!

marcospgp avatar Jan 24 '21 15:01 marcospgp

this doesn't really show anything related to editorconfig. can you capture the log again after setting "omnisharp.logginglevel":"debug"?

also, can you please try to:

  • disable the Unity anlayzers to see if it conflicts
  • disable other .editorconfig rules
  • check the location of .editorconfig if it's correct or check if you don't have other .editorconfig files that might override the configured behavior

filipw avatar Jan 25 '21 07:01 filipw

I removed the Unity analyzers .dll from the project but it made no difference.

I also updated my .editorconfig file to only include that one rule:

# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true

# C# files
[*.cs]

dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity

but the warning keeps showing.

The only other .editorconfig file in the project is created by Unity and looks like this:

[*.asmdef]
scrape_api = true

[**/Tests/**.asmdef]
scrape_api = false

[**/Samples/**.asmdef]
scrape_api = false

Here's the omnisharp log with debug logging level:

Starting OmniSharp server at 25/01/2021, 11:35:55
    Target: c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\Tavern Tycoon.sln

OmniSharp server started.
    Path: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\OmniSharp.exe
    PID: 20072

[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Cake, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.DotNetTest, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Host, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.MSBuild, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Roslyn, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Roslyn.CSharp, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Script, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[dbug]: OmniSharp.CompositionHostBuilder
        Loaded OmniSharp.Shared, Version=1.37.0.0, Culture=neutral, PublicKeyToken=null
[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[dbug]: OmniSharp.CompositionHostBuilder
        .NET SDK requires MSBuild instances version 16.3 or higher
[dbug]: OmniSharp.MSBuild.Discovery.Providers.VisualStudioInstanceProvider
        An exception was thrown while retrieving Visual Studio instances.
System.DllNotFoundException: Unable to load DLL 'Microsoft.VisualStudio.Setup.Configuration.Native.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at OmniSharp.MSBuild.Discovery.Interop.GetSetupConfiguration(ISetupConfiguration& configuration, IntPtr reserved)
   at OmniSharp.MSBuild.Discovery.Interop.GetSetupConfiguration() in D:\a\1\s\src\OmniSharp.Host\MSBuild\Discovery\Interop.cs:line 25
   at OmniSharp.MSBuild.Discovery.Providers.VisualStudioInstanceProvider.GetInstances() in D:\a\1\s\src\OmniSharp.Host\MSBuild\Discovery\Providers\VisualStudioInstanceProvider.cs:line 28
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin"
[dbug]: OmniSharp.CompositionHostBuilder
        MSBuild instance StandAlone 16.8.0 scored at 1
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.Utilities.Core.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.Tasks.Core.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.Framework.dll' (name-only).
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin"
            CscToolExe = csc.exe
            CscToolPath = c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Roslyn
            MSBuildExtensionsPath = c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild
            MSBuildToolsPath = c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.Utilities.Core.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.Framework.dll' (name-only).
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.dll' (name-only).
[fail]: OmniSharp.Services.AssemblyLoader
        An error occurred when attempting to access 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\./NuGet/microsoft.unity.analyzers.1.9.0/analyzers/dotnet/cs'.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon\NuGet\microsoft.unity.analyzers.1.9.0\analyzers\dotnet\cs'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.EnumerateFiles(String path, String searchPattern)
   at OmniSharp.Services.AssemblyLoader.LoadAllFrom(String folderPath) in D:\a\1\s\src\OmniSharp.Host\Services\AssemblyLoader.cs:line 46
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=3.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll'.
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Features, Version=3.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.CodeAnalysis.VisualBasic.Features.dll'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        SUCCESS: Resolved to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Microsoft.Build.dll' (name-only).
[dbug]: OmniSharp.MSBuild.ProjectSystem
        MSBuild environment: 
Mode: Standalone
RunningTests: False
RunningInVisualStudio: False
MSBuildToolsDirectory32: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin
MSBuildToolsDirectory64: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin
MSBuildSDKsPath: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Sdks
CurrentMSBuildConfigurationFile: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\MSBuild.exe.config
CurrentMSBuildExePath: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\MSBuild.exe
CurrentMSBuildToolsDirectory: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin
VisualStudioInstallRootDirectory: 
MSBuildExtensionsPath: c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin

[dbug]: OmniSharp.MSBuild.ProjectLoader
        'MSBuildExtensionsPath' set to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild'
[dbug]: OmniSharp.MSBuild.ProjectLoader
        'CscToolPath' set to 'c:\Users\marcospgp\.vscode\extensions\ms-dotnettools.csharp-1.23.8\.omnisharp\1.37.5\.msbuild\Current\Bin\Roslyn'
[dbug]: OmniSharp.MSBuild.ProjectLoader
        'CscToolExe' set to 'csc.exe'
[info]: OmniSharp.MSBuild.ProjectSystem
        Skip loading projects listed in solution file or under target directory because MsBuild:LoadProjectsOnDemand is true.
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[dbug]: OmniSharp.WorkspaceInitializer
        Starting with OmniSharp options: {"RoslynExtensionsOptions":{"EnableDecompilationSupport":false,"EnableAnalyzersSupport":true,"EnableImportCompletion":false,"DocumentAnalysisTimeoutMs":10000,"LocationPaths":["./NuGet/microsoft.unity.analyzers.1.9.0/analyzers/dotnet/cs"]},"FormattingOptions":{"OrganizeImports":false,"EnableEditorConfigSupport":true,"NewLine":"\n","UseTabs":false,"TabSize":2,"IndentationSize":2,"SpacingAfterMethodDeclarationName":false,"SpaceWithinMethodDeclarationParenthesis":false,"SpaceBetweenEmptyMethodDeclarationParentheses":false,"SpaceAfterMethodCallName":false,"SpaceWithinMethodCallParentheses":false,"SpaceBetweenEmptyMethodCallParentheses":false,"SpaceAfterControlFlowStatementKeyword":true,"SpaceWithinExpressionParentheses":false,"SpaceWithinCastParentheses":false,"SpaceWithinOtherParentheses":false,"SpaceAfterCast":false,"SpacesIgnoreAroundVariableDeclaration":false,"SpaceBeforeOpenSquareBracket":false,"SpaceBetweenEmptySquareBrackets":false,"SpaceWithinSquareBrackets":false,"SpaceAfterColonInBaseTypeDeclaration":true,"SpaceAfterComma":true,"SpaceAfterDot":false,"SpaceAfterSemicolonsInForStatement":true,"SpaceBeforeColonInBaseTypeDeclaration":true,"SpaceBeforeComma":false,"SpaceBeforeDot":false,"SpaceBeforeSemicolonsInForStatement":false,"SpacingAroundBinaryOperator":"single","IndentBraces":false,"IndentBlock":true,"IndentSwitchSection":true,"IndentSwitchCaseSection":true,"IndentSwitchCaseSectionWhenBlock":true,"LabelPositioning":"oneLess","WrappingPreserveSingleLine":true,"WrappingKeepStatementsOnSingleLine":true,"NewLinesForBracesInTypes":true,"NewLinesForBracesInMethods":true,"NewLinesForBracesInProperties":true,"NewLinesForBracesInAccessors":true,"NewLinesForBracesInAnonymousMethods":true,"NewLinesForBracesInControlBlocks":true,"NewLinesForBracesInAnonymousTypes":true,"NewLinesForBracesInObjectCollectionArrayInitializers":true,"NewLinesForBracesInLambdaExpressionBody":true,"NewLineForElse":true,"NewLineForCatch":true,"NewLineForFinally":true,"NewLineForMembersInObjectInit":true,"NewLineForMembersInAnonymousTypes":true,"NewLineForClausesInQuery":true},"FileOptions":{"SystemExcludeSearchPatterns":["**/node_modules/**/*","**/bin/**/*","**/obj/**/*","**/.git/**/*","**/.git","**/.svn","**/.hg","**/CVS","**/.DS_Store","**/.gitignore","**/.gitmodules","**/*.booproj","**/*.pidb","**/*.suo","**/*.user","**/*.userprefs","**/*.unityproj","**/*.dll","**/*.exe","**/*.pdf","**/*.mid","**/*.midi","**/*.wav","**/*.gif","**/*.ico","**/*.jpg","**/*.jpeg","**/*.png","**/*.psd","**/*.tga","**/*.tif","**/*.tiff","**/*.3ds","**/*.3DS","**/*.fbx","**/*.FBX","**/*.lxo","**/*.LXO","**/*.ma","**/*.MA","**/*.obj","**/*.OBJ","**/*.asset","**/*.cubemap","**/*.flare","**/*.mat","**/*.meta","**/*.prefab","**/*.unity","build/","Build/","Library/","library/","obj/","Obj/","ProjectSettings/","temp/","Temp/"],"ExcludeSearchPatterns":[]},"RenameOptions":{"RenameOverloads":false,"RenameInStrings":false,"RenameInComments":false},"ImplementTypeOptions":{"InsertionBehavior":null,"PropertyGenerationBehavior":null},"Plugins":{"LocationPaths":null}}
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\marcospgp\Documents\Unity\Projects\Tavern Tycoon' on host 6112.
[dbug]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 1,
  "Command": "/projects"
}
[dbug]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 2,
  "Command": "/projects"
}
[dbug]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 2,
  "Command": "/projects",
  "Running": true,
  "Success": true,
  "Message": null,
  "Body": {
    "MsBuild": {
      "SolutionPath": null,
      "Projects": []
    },
    "Script": {
      "Projects": []
    }
  },
  "Seq": 55,
  "Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 1,
  "Command": "/projects",
  "Running": true,
  "Success": true,
  "Message": null,
  "Body": {
    "MsBuild": {
      "SolutionPath": null,
      "Projects": []
    },
    "Script": {
      "Projects": []
    }
  },
  "Seq": 54,
  "Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 3,
  "Command": "/projects"
}
[dbug]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 3,
  "Command": "/projects",
  "Running": true,
  "Success": true,
  "Message": null,
  "Body": {
    "MsBuild": {
      "SolutionPath": null,
      "Projects": []
    },
    "Script": {
      "Projects": []
    }
  },
  "Seq": 59,
  "Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 5,
  "Command": "/filesChanged",
  "Arguments": [
    {
      "FileName": "c:\\Users\\marcospgp\\AppData\\Roaming\\Code\\logs\\20210125T113552\\userDataSync.log",
      "changeType": "Create"
    }
  ]
}
[dbug]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 4,
  "Command": "/filesChanged",
  "Arguments": [
    {
      "FileName": "c:\\Users\\marcospgp\\AppData\\Roaming\\Code\\logs\\20210125T113552\\telemetry.log",
      "changeType": "Create"
    }
  ]
}
[dbug]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 4,
  "Command": "/filesChanged",
  "Running": true,
  "Success": true,
  "Message": null,
  "Body": {},
  "Seq": 64,
  "Type": "response"
}
[dbug]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 5,
  "Command": "/filesChanged",
  "Running": true,
  "Success": true,
  "Message": null,
  "Body": {},
  "Seq": 63,
  "Type": "response"
}

marcospgp avatar Jan 25 '21 11:01 marcospgp

Does it work in Visual Studio? OmniSharp uses .editorconfig support that's built into the C# compiler now.

I suspect the bug is not really in OmniSharp but in Roslyn, because there should be a bunch of log entries related to loading editorconfig (https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp.MSBuild/ProjectManager.cs#L559-L582) file but they don't show up in your log.

What are the locations of the .editorconfig files you mentioned, relative to the solution file and project files?

filipw avatar Jan 25 '21 12:01 filipw

@filipw I don't have Visual Studio installed to check :(

My .editorconfig file is in the root folder, next to the .sln and .csproj files. Unity's is in /Library\PackageCache\[email protected].

The .editorconfig file at the root of the project is being loaded though, since the other rules do work, right?

marcospgp avatar Jan 25 '21 12:01 marcospgp

Is this a "modern" project file (with project SDK on top, e.g. https://github.com/OmniSharp/omnisharp-roslyn/blob/master/src/OmniSharp.Roslyn/OmniSharp.Roslyn.csproj#L1) or the old-school project file?

If the latter, then loading editorconfig will not be supported

filipw avatar Jan 25 '21 13:01 filipw

But the .editorconfig is working as I mentioned so it must be being loaded? I tried removing some of the other rules and it worked as expected.

But also none of the .csproj files refer to any SDK. They look like this: <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

marcospgp avatar Jan 25 '21 15:01 marcospgp

I noticed that settings in the format of dotnet_diagnostic.<RuleId>severity = silent

Are ignored. For example dotnet_diagnostic.IDE0008.severity = none get ignored, while csharp_using_directive_placement = outside_namespace:error works.

My omnisharp.json:

{
  "RoslynExtensionsOptions": {
    "LocationPaths": ["/home/cobra/.omnisharp/Rozlynator"],
    "enableAnalyzersSupport": true
  },
  "FormattingOptions": {
    	"OrganizeImports": true,
        "enableEditorConfigSupport": true
  }
}

Example in the editor (in this case nvim): image

Even after reloading the omnisharp server or closing nvim and reopening it, it still ignores the editorconfig settings.

RononDex avatar Apr 12 '21 06:04 RononDex

I'm having the same issue in emacs/lsp-mode (with a Unity project as well, if that's relevant). "Silent" doesn't work, but "none" does.

The following line yields a suggestion-level lint "Expression value is never used [IDE0058]".

csharp_style_unused_value_expression_statement_preference = discard_variable:silent

The following line yields an error-level lint "Expression value is never used [IDE0058]" (as expected)

csharp_style_unused_value_expression_statement_preference = discard_variable:error

The following line yields no lint.

csharp_style_unused_value_expression_statement_preference = discard_variable:none

elizagamedev avatar May 02 '21 06:05 elizagamedev

Setting these rules in the FormattingOptions in omnisharp.json does not affect linting, but I noticed it does affect the style respected by the Format Document thing in the ctrl+shift+P pop up menu in VSCode.

Regardless, using .editorconfig is more general and non Omnisharp-specific, so it is preferable.

I managed to set up a rule set (based on this template). This caused a lot of warnings to appear, which means the rules are working.

Among these, I noticed that the original rule that led to opening this issue was now working:

image

I have formatted my hard drive since I opened this issue and retrying this now, so who knows what it could have been! I suppose this issue can be closed now anyway 🙂

It would still be cool to have some info on how to set a style guide using .editorconfig somewhere in the readme!

marcospgp avatar Jun 20 '21 16:06 marcospgp

Any more info on this? I'm having the same issue [reported under issue #5246 on Omnisharp-vscode]. There I thought it was only the code formatting, but after finding this issue and doing some more experiments, I noticed that the entire .editorconfig is being ignored.

bestknighter avatar Jun 17 '22 16:06 bestknighter

I am not sure if this is the same problem but what I observed with my editorconfig, was that if a rule had the VS-Code notation it didn't work. e.g. sharp_style_expression_bodied_methods = true => works sharp_style_expression_bodied_methods = true:hint => doesn't work

tilupe avatar Aug 19 '22 10:08 tilupe

That might be one of the issues, but I just created a simple project to test and I still had the issue... My repro project is just the three following files in the same folder.

omnisharp.json

{
    "RoslynExtensionsOptions": {
        "EnableAnalyzersSupport": true
    },
    "FormattingOptions": {
        "EnableEditorConfigSupport": true
    }
}

.editorconfig

root=true

[*]
indent_style = space

[*.cs]
indent_size = 4
trim_trailing_whitespace = false
insert_final_newline = true

test.cs

using System;

public class Test
{
    public static string DoTest()
    {
        int a = 1;
        if (a == 1)
        {
            return "equals";
        }
        else
        {
            var ans = "not equals";
            return ans;
        }
    }
}

Both indent_style and indent_size are respected. I can change them and a simple omnisharp server restart makes the "Format Document" command use the new values. trim_trailing_whitespace and insert_final_newline does NOT work. I can change their value, comment, remove, change order and restart the omnisharp server but the "Format Document" command will always ignore them and go with the default.

bestknighter avatar Aug 28 '22 03:08 bestknighter