Cannot "Go To Definition" with anything that was imported from a package that isn't from the default nuget source.
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.
To go to the definition
Claims "no definition found"
************ 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
"Body": null,
"Seq": 5854,
"Type": "response"
}
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|;
I should add that this works fine on Visual Studio. I'm not sure why it's not working here on VS Code with OmniSharp.
I've tried all solutions here: https://stackoverflow.com/questions/47995468/vscode-c-sharp-go-to-definition-f12-not-working/51215346
None worked for me.
This is a fresh install too.
I've also tried on Windows 10 to no avail
************ Response ************
{
"Request_seq": 16,
"Command": "/gotoDefinition",
"Running": true,
"Success": false,
"Message": "\"System.OperationCanceledException: The operation was canceled.\r\n at System.Threading.CancellationToken.ThrowOperationCanceledException()\r\n at Microsoft.CodeAnalysis.CSharp.Simplification.AbstractCSharpReducer.AbstractReductionRewriter.SimplifyNodeTNode\r\n at Microsoft.CodeAnalysis.CSharp.Simplification.CSharpNameReducer.Rewriter.VisitIdentifierName(IdentifierNameSyntax node)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitQualifiedName(QualifiedNameSyntax node)\r\n at Microsoft.CodeAnalysis.CSharp.Simplification.CSharpNameReducer.Rewriter.VisitQualifiedName(QualifiedNameSyntax node)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitQualifiedName(QualifiedNameSyntax node)\r\n at Microsoft.CodeAnalysis.CSharp.Simplification.CSharpNameReducer.Rewriter.VisitQualifiedName(QualifiedNameSyntax node)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitAttribute(AttributeSyntax node)\r\n at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node)\r\n at Microsoft.CodeAnalysis.CSharp.Simplification.AbstractCSharpReducer.AbstractReductionRewriter.VisitNodeOrToken(SyntaxNodeOrToken nodeOrToken, SemanticModel semanticModel, Boolean simplifyAllDescendants)\r\n at Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService3.<>c__DisplayClass10_1.<<ReduceAsync>b__0>d.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.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.Simplification.AbstractSimplificationService3.3.<ReduceAsync>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.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.Simplification.Simplifier.<ReduceAsync>d__17.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.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.CodeAnalysis.MetadataAsSource.AbstractMetadataAsSourceService.<AddSourceToAsync>d__4.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.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Roslyn.MetadataExternalSourceService.<GetAndAddExternalSymbolDocument>d__4.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn\\\\MetadataExternalSourceService.cs:line 63\\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.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n 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 73\\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.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Endpoint.EndpointHandler2.2.<HandleRequestForLanguage>d__20.MoveNext() in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 230\\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.ThrowForNonSuccess(Task task)\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at OmniSharp.Endpoint.EndpointHandler2.
"Body": null,
"Seq": 114,
"Type": "response"
}
this should definitely be working. could you share a repro project with this error?
Hey @filipw,
Unfortunately I personally only know of one external source for nuget packages, and it's my work one so I'm not allowed to share. I was hoping maybe someone else had one so I could test.
Unfortunately without a repro it is impossible to provide any help. This is not related to a fact whether a nuget reference is external or internal.
What you are seeing is not really any real error yet - it's only a timeout. At the moment go to definition when definition is contained in a metadata is limited to 5 seconds, so if it takes longer (e.g. slow machine or a very complex metadata source text) then it might get canceled in the process and not complete.
Ok I see. I'll invite you to a private repo.
@filipw invite sent for repo.
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.
Awesome, thank you so much @filipw !
Hey @filipw FYI I tried enabling decompilation support and I'm still getting the same results.
I was also wondering if we could swap the label from "Needs More Info"
what do you see in the log when you enabled decompilation? It works without issues on my machine on your repro project
Nevermind it works fine. I wasn't creating omnisharp.json in the right place. Sorry for the bother.
Most helpful comment
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.