Invalid .editorconfig breaks the OmniSharp extension
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 737
- Avg merge
- 17h 56m
- Merged PRs (30d)
- 21
Description
## Issue Description ##
Basic functionality such as `Go to definition` or `Refactor` doesn't work.
After checking the logs, I noticed an unrelated error that is posted below in the Logs section.
I could infer from the log that the issue related to a method called `ParseUsingDirectivesPlacement` which after looking it up seems to be related to the .editorconfig file.
Disabling the csharp_using_directive_placement rule, fixed the issue.
### Before the fix
https://user-images.githubusercontent.com/1418564/205727301-64dcb3c7-b58a-4e83-9338-252dd3e594ff.mp4
### After the fix
https://user-images.githubusercontent.com/1418564/205727547-af938e5c-4cad-4a58-87fe-c94b98081f46.mp4
## Steps to Reproduce ##
Add this rule to `.editorconfig` file:
```
csharp_using_directive_placement = false:warning
```
## Expected Behavior ##
All functionality of OmniSharp should work even though the .editorconfig file is not valid.
Or at least give a warning that the file needs to be fixed rather than failing silently.
## Actual Behavior ##
Open any C# solution folder, and try any functionality such as `Go to definition`, you will notice that nothing happens.
Trying any Refactor action yields the same result.
## Logs ##
### OmniSharp log ###
[fail]: OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService
Error computing refactorings for Microsoft.CodeAnalysis.IntroduceVariable.IntroduceVariableCodeRefactoringProvider
System.NotSupportedException: Specified method is not supported.
at Microsoft.CodeAnalysis.CSharp.CodeStyle.CSharpCodeStyleOptions.ParseUsingDirectivesPlacement(String optionString, CodeStyleOption2`1 default)
at Microsoft.CodeAnalysis.CSharp.CodeStyle.CSharpCodeStyleOptions.<>c__DisplayClass49_0.b__0(String s)
at Microsoft.CodeAnalysis.Options.EditorConfigStorageLocation`1.TryGetOption(String value, Type type, T& result)
at Microsoft.CodeAnalysis.AnalyzerConfigOptionsExtensions.TryGetEditorConfigOption[T](AnalyzerConfigOptions analyzerConfigOptions, IOption option, Optional`1 defaultValue, T& value)
at Microsoft.CodeAnalysis.CSharp.AddImport.CSharpAddImportsService.GetUsingDirectivePlacementCodeStyleOption(AnalyzerConfigOptions configOptions, CodeStyleOption2`1 fallbackValue)
at Microsoft.CodeAnalysis.AddImport.AbstractAddImportsService`4.GetAddImportOptions(AnalyzerConfigOptions configOptions, Boolean allowInHiddenRegions, AddImportPlacementOptions fallbackOptions)
at Microsoft.CodeAnalysis.CodeCleanup.CodeCleanupOptionsProviders.GetCodeCleanupOptions(AnalyzerConfigOptions options, Boolean allowImportsInHiddenRegions, CodeCleanupOptions fallbackOptions, LanguageServices languageServices)
at Microsoft.CodeAnalysis.CodeCleanup.CodeCleanupOptionsProviders.GetCodeCleanupOptionsAsync(Document document, CodeCleanupOptions fallbackOptions, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CodeCleanup.CodeCleanupOptionsProviders.GetCodeCleanupOptionsAsync(Document document, CodeCleanupOptionsProvider fallbackOptionsProvider, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.IntroduceVariable.IntroduceVariableCodeRefactoringProvider.ComputeRefactoringsAsync(CodeRefactoringContext context)
at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectRefactoringActions(Document document, TextSpan span, List`1 codeActions) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Services\Refactoring\V2\BaseCodeActionService.cs:line 224
Received response for /v2/getcodeactions but could not find request.
### C# log ###
No output
## Environment information ##
**VSCode version**: 1.73.1
**C# Extension**: 1.25.2
Dotnet Information
.NET SDK (reflecting any global.json):
Version: 6.0.403
Commit: 2bc18bf292
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.403\
global.json file:
Not found
Host:
Version: 6.0.11
Architecture: x64
Commit: 943474ca16
.NET SDKs installed:
2.2.207 [C:\Program Files\dotnet\sdk]
3.1.425 [C:\Program Files\dotnet\sdk]
5.0.412 [C:\Program Files\dotnet\sdk]
6.0.401 [C:\Program Files\dotnet\sdk]
6.0.403 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Download .NET:
https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs:
https://aka.ms/dotnet/runtimes-sdk-info
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|Bookmarks|alefragnani|13.3.1|
|code-runner|formulahendry|0.11.8|
|code-spell-checker|streetsidesoftware|2.11.1|
|csharp|ms-dotnettools|1.25.2|
|dart-code|Dart-Code|3.54.1|
|data-workspace-vscode|ms-mssql|0.3.0|
|debug-visualizer|hediet|2.4.0|
|docomment|k--kato|0.1.31|
|dotnet-interactive-vscode|ms-dotnettools|1.0.3553070|
|duplicate-finder|tlevesque2|0.0.6|
|flutter|Dart-Code|3.54.0|
|gc-excelviewer|GrapeCity|4.2.56|
|git-graph|mhutchie|1.30.0|
|githistory|donjayamanne|0.6.19|
|gitlens|eamodio|13.1.1|
|grammarly|znck|0.22.1|
|isort|ms-python|2022.8.0|
|jupyter|ms-toolsai|2022.9.1303220346|
|jupyter-keymap|ms-toolsai|1.0.0|
|kotlin|fwcd|0.2.26|
|live-server|ms-vscode|0.4.4|
|markdown-mermaid|bierner|1.15.2|
|markdown-preview-enhanced|shd101wyy|0.6.5|
|material-icon-theme|PKief|4.22.0|
|nodejs-repl|lostfields|0.5.15|
|partial-diff|ryu1kn|1.4.3|
|powershell|ms-vscode|2022.11.0|
|prettier-vscode|esbenp|9.10.3|
|python|ms-python|2022.18.2|
|randomeverything|helixquar|0.0.3|
|remote-explorer|ms-vscode|0.0.2|
|remote-repositories|ms-vscode|0.24.0|
|remote-ssh|ms-vscode-remote|0.92.0|
|remote-ssh-edit|ms-vscode-remote|0.84.0|
|remote-wsl|ms-vscode-remote|0.72.0|
|remotehub|GitHub|0.46.0|
|rest-book|tanhakabir|6.2.1|
|rest-client|humao|0.25.1|
|sqltools|mtxr|0.26.0|
|terraform|4ops|0.2.5|
|terraform|hashicorp|2.25.1|
|text-power-tools|qcz|1.38.0|
|tldraw-vscode|tldraw-org|1.25.2|
|typescript-notebook|donjayamanne|2.0.6|
|typing-sounds|Mtuan|0.0.4|
|vs-code-prettier-eslint|rvest|5.0.4|
|vscode-data-preview|RandomFractalsInc|2.3.0|
|vscode-drawio|hediet|1.6.4|
|vscode-eslint|dbaeumer|2.2.6|
|vscode-jupyter-cell-tags|ms-toolsai|0.1.6|
|vscode-jupyter-slideshow|ms-toolsai|0.1.5|
|vscode-notes|dionmunk|1.1.0|
|vscode-paper|xahon|0.0.4|
|vscode-proto3|zxh404|0.5.5|
|vscode-pull-request-github|GitHub|0.54.1|
|vscode-pylance|ms-python|2022.11.40|
|vscode-react-refactor|planbcoding|1.1.3|
|vscode-solution-explorer|fernandoescolar|0.7.4|
|vscode-sql-formatter|adpyke|1.4.4|
|vscode-thunder-client|rangav|2.1.0|
|vscode-todo-plus|fabiospampinato|4.19.0|
|yuml|JaimeOlivares|3.5.1|;
Contributor guide
Assessment
This issue has not been assessed yet.