question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Go To Definition" times out on a complex metadata file

See original GitHub issue

Issue Description

Cannot “Go To Definition” with anything that was imported from a package that isn’t from the default nuget source.

Steps to Reproduce

Try to “Go To Definition” on a method from an Object that was defined in a package that came from a source other that the default nuget’s.

Expected Behavior

To go to the definition

Actual Behavior

Claims “no definition found”

Logs

OmniSharp log

    ************  Response ************ 

{ “Request_seq”: 101, “Command”: “/gotoDefinition”, “Running”: true, “Success”: false, “Message”: “"System.OperationCanceledException: The operation was canceled.\n at System.Threading.CancellationToken.ThrowOperationCanceledException () [0x00010] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 \n at System.Threading.CancellationToken.ThrowIfCancellationRequested () [0x00008] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 \n at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.ApplyTriviaOperations (Microsoft.CodeAnalysis.Formatting.FormattingContext context, System.Threading.CancellationToken cancellationToken) [0x00004] in <98b6908531d840228bf235ca8d22fd88>:0 \n at Microsoft.CodeAnalysis.Formatting.AbstractFormatEngine.Format (System.Threading.CancellationToken cancellationToken) [0x0008b] in <98b6908531d840228bf235ca8d22fd88>:0 \n at Microsoft.CodeAnalysis.CSharp.Formatting.CSharpSyntaxFormattingService.Format (Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions options, System.Collections.Generic.IEnumerable1[T] formattingRules, Microsoft.CodeAnalysis.SyntaxToken token1, Microsoft.CodeAnalysis.SyntaxToken token2, System.Threading.CancellationToken cancellationToken) [0x0000c] in <faea2fbe354e4ba6bda2599ef8169680>:0 \\n at Microsoft.CodeAnalysis.Formatting.AbstractSyntaxFormattingService.FormatIndividually (Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions options, System.Collections.Generic.IEnumerable1[T] rules, System.Collections.Generic.IList1[T] spansToFormat, System.Threading.CancellationToken cancellationToken) [0x00036] in <98b6908531d840228bf235ca8d22fd88>:0 \\n at Microsoft.CodeAnalysis.Formatting.AbstractSyntaxFormattingService.Format (Microsoft.CodeAnalysis.SyntaxNode node, System.Collections.Generic.IEnumerable1[T] spans, System.Boolean shouldUseFormattingSpanCollapse, Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions options, System.Collections.Generic.IEnumerable1[T] rules, System.Threading.CancellationToken cancellationToken) [0x0004a] in <98b6908531d840228bf235ca8d22fd88>:0 \\n at Microsoft.CodeAnalysis.Formatting.Formatter.GetFormattingResult (Microsoft.CodeAnalysis.SyntaxNode node, System.Collections.Generic.IEnumerable1[T] spans, Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Options.OptionSet options, System.Collections.Generic.IEnumerable1[T] rules, System.Threading.CancellationToken cancellationToken) [0x0008e] in <98b6908531d840228bf235ca8d22fd88>:0 \\n at Microsoft.CodeAnalysis.Formatting.Formatter.Format (Microsoft.CodeAnalysis.SyntaxNode node, System.Collections.Generic.IEnumerable1[T] spans, Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.Options.OptionSet options, System.Collections.Generic.IEnumerable1[T] rules, System.Threading.CancellationToken cancellationToken) [0x00000] in <98b6908531d840228bf235ca8d22fd88>:0 \\n at Microsoft.CodeAnalysis.Formatting.Formatter.FormatAsync (Microsoft.CodeAnalysis.Document document, System.Collections.Generic.IEnumerable1[T] spans, Microsoft.CodeAnalysis.Options.OptionSet options, System.Collections.Generic.IEnumerable1[T] rules, System.Threading.CancellationToken cancellationToken) [0x0014a] in <98b6908531d840228bf235ca8d22fd88>:0 \\n at Microsoft.CodeAnalysis.MetadataAsSource.AbstractMetadataAsSourceService.AddSourceToAsync (Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Compilation symbolCompilation, Microsoft.CodeAnalysis.ISymbol symbol, System.Threading.CancellationToken cancellationToken) [0x0049a] in <3e93b7a6b0cb4d6c978ff97c83568be8>:0 \\n at OmniSharp.Roslyn.MetadataExternalSourceService.GetAndAddExternalSymbolDocument (Microsoft.CodeAnalysis.Project project, Microsoft.CodeAnalysis.ISymbol symbol, System.Threading.CancellationToken cancellationToken) [0x00246] in <b86a8f7ee5524070a682f0426faddb57>:0 \\n at OmniSharp.Roslyn.CSharp.Services.Navigation.GotoDefinitionService.Handle (OmniSharp.Models.GotoDefinition.GotoDefinitionRequest request) [0x0037e] in <8ca5e445b15640a0986680e5a0180b25>:0 \\n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \\n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \n at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \n at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000e7] in <add5f40a6e784fcca3e930b59965388b>:0 "”, “Body”: null, “Seq”: 5854, “Type”: “response” }

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: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/3.1.403/

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

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

.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.9 [/usr/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
csharp ms-dotnettools 1.23.5
mongodb-vscode mongodb 0.2.1
vscode-docker ms-azuretools 1.7.0
vscode-kubernetes-tools ms-kubernetes-tools 1.2.1
vscode-yaml redhat 0.12.0
vscodeintellicode VisualStudioExptTeam 1.2.10

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
filipwcommented, Nov 6, 2020

thanks, I tried it out, it’s very helpful.

As I suspected the functionality works - it just runs into a timeout (by default 2s) because the metadata file it needs to go to is really large. Unfortunately this timeout at the moment is not configurable.

What you can do, is you can enable decompilation support (you can find instructions here https://www.strathweb.com/2020/05/decompilation-support-in-omnisharp-and-c-extension-for-vs-code/). This has a higher timeout and should easily complete. As an added bonus you will get better quality behavior - instead of seeing just metadata, you will see decompiled code.

To avoid these problems for the future, we will increase or add an option to increase the go to definition timeout.

0reactions
nonsensationcommented, Jun 11, 2021

@filipw I have timed it, it was always 20secs up to 30 secs. I also changed RoslynExtensionsOptions.DocumentAnalysisTimeoutMs (if this is even the correct variable), without any changes Am I able to change the timeout?

Also, here is the log:

[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 72,
  "Command": "/gotoDefinition",
  "Arguments": {
    "FileName": "c:\\dev\\prj\\test\\Program.cs",
    "Line": 10,
    "Column": 20,
    "WantMetadata": true
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response ************ 
{
  "Request_seq": 72,
  "Command": "/gotoDefinition",
  "Running": true,
  "Success": false,
  "Message": "\"System.OperationCanceledException: The operation was canceled.
     at System.Threading.CancellationToken.ThrowOperationCanceledException()
     at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.<GetOrBuildCompilationInfoAsync>d__22.MoveNext()
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.<GetCompilationSlowAsync>d__20.MoveNext()
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Roslyn.CSharp.Services.Decompilation.OmniSharpCSharpDecompiledSourceService.<AddAssemblyInfoRegionAsync>d__5.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Decompilation\\\\OmniSharpCSharpDecompiledSourceService.cs:line 89
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Roslyn.CSharp.Services.Decompilation.OmniSharpCSharpDecompiledSourceService.<AddSourceToAsync>d__3.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Decompilation\\\\OmniSharpCSharpDecompiledSourceService.cs:line 53
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Roslyn.CSharp.Services.Decompilation.DecompilationExternalSourceService.<GetAndAddExternalSymbolDocument>d__4.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Decompilation\\\\DecompilationExternalSourceService.cs:line 56
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Roslyn.CSharp.Services.Navigation.GoToDefinitionHelpers.<GetMetadataMappedSpan>d__1.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Navigation\\\\GoToDefinitionHelpers.cs:line 38
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Roslyn.CSharp.Services.Navigation.GotoDefinitionService.<Handle>d__4.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Navigation\\\\GotoDefinitionService.cs:line 59
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Endpoint.EndpointHandler`2.<GetFirstNotEmptyResponseFromHandlers>d__19.MoveNext()
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 230
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 131
     --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 215\"",
  "Body": null,
  "Seq": 108,
  "Type": "response"
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found