OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.79k stars 420 forks source link

BUG: Auto import usages stopped working after update #2474

Open iabdelkareem opened 2 years ago

iabdelkareem commented 2 years ago

Environment:

Omnisharp: 1.39.2 Neovim: 0.8.0 OS: Fedora Workstation 36

After the recent update to omnisharp I noticed that auto import usages stopped working. I checked the logs and I found this warning message being emitted many times.

[WARN][2022-11-17 10:54:16] ...lsp/handlers.lua:487     "OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService: No symbol found. File: [SOME_FILE], Line: 1, Column: 0. | "

My ~/.omnisharp/omnisharp.json contains the following

{
  "fileOptions": {
    "systemExcludeSearchPatterns": [
      "**/node_modules/**/*",
      "**/bin/**/*",
      "**/obj/**/*"
    ],
    "excludeSearchPatterns": []
  },
  "RoslynExtensionsOptions": {
    "documentAnalysisTimeoutMs": 10000,
    "enableDecompilationSupport": true,
    "enableImportCompletion": true,
    "enableAnalyzersSupport": true,
    "diagnosticWorkersThreadCount": 8,
    "locationPaths": [],
    "inlayHintsOptions": {
      "enableForParameters": true,
      "forLiteralParameters": true,
      "forIndexerParameters": true,
      "forObjectCreationParameters": true,
      "forOtherParameters": true,
      "suppressForParametersThatDifferOnlyBySuffix": false,
      "suppressForParametersThatMatchMethodIntent": false,
      "suppressForParametersThatMatchArgumentName": false,
      "enableForTypes": true,
      "forImplicitVariableTypes": true,
      "forLambdaParameterTypes": true,
      "forImplicitObjectCreation": true
    }
  },
  "FormattingOptions": {
    "EnableEditorConfigSupport": true,
    "OrganizeImports": true,
    "NewLine": "\n",
    "UseTabs": false,
    "TabSize": 4,
    "IndentationSize": 4,
    "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
  }
}
DencoL commented 2 years ago

Can confirm on Ubuntu and Windows.

iabdelkareem commented 1 year ago

Any updates?

EnriqueBravo115 commented 1 year ago

same behavior Fedora 38 nvim 0.9.1

AnhQuanTrl commented 1 year ago

Same behaviour with nvim 0.9.2

rudiejd commented 1 year ago

Same with ubuntu, nvim 0.9.0

iabdelkareem commented 9 months ago

Update: I debugged the issue and found out that the Cake CompletionHandler removes the using statements. When I comment on this line, everything works as intended. I'm not sure why the cake handler runs for a C# file and would appreciate your help resolving this issue.

For now, until this issue is resolved, if anyone is interested you can comment the line I mentioned above and build omnisharp yourself.

iabdelkareem commented 9 months ago

This issue mentioned here as well

https://github.com/OmniSharp/omnisharp-roslyn/issues/2573

areiass36 commented 7 months ago

I wasn't able to build it on my mac, is there an easier way for me to get it?