vscode-csharp
vscode-csharp copied to clipboard
Go to definition for a source generated file fails to open the generated file
Repro:
- Open Roslyn solution and wait for load
- Find any type with a definition in
Syntax.xml.Syntax.Generated.cs- for exampleBaseTypeDeclarationSyntaxhere - Expect navigate to definition location, instead throws an error with the following stack:
[Error - 3:46:20 PM] [LanguageServerHost] System.UriFormatException: Failed create URI from 'CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Syntax.Generated.cs'; original string: 'CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Syntax.Generated.cs'
---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 186
--- End of inner exception stack trace ---
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 186
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.<TextSpanToLocationAsync>g__ConvertTextSpanToLocation|30_0(Document document, TextSpan span, Boolean isStale, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 491
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.TextSpanToLocationAsync(Document document, TextSpan textSpan, Boolean isStale, Nullable`1 context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 503
at Microsoft.CodeAnalysis.LanguageServer.Handler.AbstractGoToDefinitionHandler.GetDefinitionAsync(TextDocumentPositionParams request, Boolean typeOnly, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs:line 141
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 3:46:20 PM] Request textDocument/definition failed.
Message: Failed create URI from 'CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Syntax.Generated.cs'; original string: 'CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Syntax.Generated.cs'
Code: -32000
This affects us in a project that uses RefitGenerator. It's very problematic as it completely breaks CTRL+T (show all symbols).
[Error - 1:58:26 PM] [LanguageServerHost] System.UriFormatException: Failed create URI from 'InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\IAccountService.g.cs'; original string: 'InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\IAccountService.g.cs'
---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 186
--- End of inner exception stack trace ---
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 186
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.<TextSpanToLocationAsync>g__ConvertTextSpanToLocation|30_0(Document document, TextSpan span, Boolean isStale, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 477
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.TextSpanToLocationAsync(Document document, TextSpan textSpan, Boolean isStale, Nullable`1 context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 442
at Microsoft.CodeAnalysis.LanguageServer.Handler.WorkspaceSymbolsHandler.LSPNavigateToCallback.AddItemAsync(Project project, INavigateToSearchResult result, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs:line 90
at Microsoft.CodeAnalysis.NavigateTo.AbstractNavigateToSearchService.<>c__DisplayClass13_0.<<GetOnItemFoundCallback>b__0>d.MoveNext() in /_/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs:line 37
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.NavigateTo.AbstractNavigateToSearchService.AddResultIfMatchAsync(DocumentId documentId, Document document, DeclaredSymbolInfo declaredSymbolInfo, PatternMatcher nameMatcher, PatternMatcher containerMatcher, DeclaredSymbolInfoKindSet kinds, Func`2 onResultFound, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs:line 162
at Microsoft.CodeAnalysis.NavigateTo.AbstractNavigateToSearchService.ProcessIndexAsync(DocumentId documentId, Document document, String patternName, String patternContainer, DeclaredSymbolInfoKindSet kinds, Func`2 onResultFound, TopLevelSyntaxTreeIndex index, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs:line 123
at Microsoft.CodeAnalysis.NavigateTo.AbstractNavigateToSearchService.ProcessDocumentAsync(Document document, String patternName, String patternContainer, DeclaredSymbolInfoKindSet kinds, Func`2 onResultFound, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs:line 96
at Microsoft.CodeAnalysis.NavigateTo.AbstractNavigateToSearchService.ProcessDocumentsAsync(Document searchDocument, String patternName, String patternContainer, DeclaredSymbolInfoKindSet kinds, Func`2 onResultFound, ISet`1 documents, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs:line 83
at Microsoft.CodeAnalysis.NavigateTo.AbstractNavigateToSearchService.SearchGeneratedDocumentsInCurrentProcessAsync(Project project, String pattern, IImmutableSet`1 kinds, Func`2 onResultFound, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.GeneratedDocumentSearch.cs:line 60
at Microsoft.CodeAnalysis.NavigateTo.AbstractNavigateToSearchService.SearchGeneratedDocumentsAsync(Project project, String searchPattern, IImmutableSet`1 kinds, Document activeDocument, Func`2 onResultFound, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.GeneratedDocumentSearch.cs:line 42
at Microsoft.CodeAnalysis.NavigateTo.NavigateToSearcher.<>c__DisplayClass19_0.<<ProcessOrderedProjectsAsync>g__SearchCoreAsync|0>d.MoveNext() in /_/src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs:line 322
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.NavigateTo.NavigateToSearcher.<>c__DisplayClass19_0.<<ProcessOrderedProjectsAsync>g__SearchCoreAsync|0>d.MoveNext() in /_/src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs:line 339
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.NavigateTo.NavigateToSearcher.ProcessOrderedProjectsAsync(Boolean parallel, ImmutableArray`1 orderedProjects, HashSet`1 seenItems, Func`4 processProjectAsync, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs:line 301
at Microsoft.CodeAnalysis.NavigateTo.NavigateToSearcher.SearchAllProjectsAsync(Boolean isFullyLoaded, NavigateToSearchScope scope, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs:line 186
at Microsoft.CodeAnalysis.NavigateTo.NavigateToSearcher.SearchAsync(Boolean searchCurrentDocument, NavigateToSearchScope scope, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs:line 130
at Microsoft.CodeAnalysis.NavigateTo.NavigateToSearcher.SearchAsync(Boolean searchCurrentDocument, NavigateToSearchScope scope, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs:line 140
at Microsoft.CodeAnalysis.LanguageServer.Handler.WorkspaceSymbolsHandler.HandleRequestAsync(WorkspaceSymbolParams request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs:line 69
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 1:58:26 PM] Request workspace/symbol failed.
Message: Failed create URI from 'InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\IAccountService.g.cs'; original string: 'InterfaceStubGeneratorV2\Refit.Generator.InterfaceStubGeneratorV2\IAccountService.g.cs'
Code: -32000
I get this bug on a Godot project too. Godot uses source generators. It happens when I try to use "jump to definition" or "find all references", only where it involves generated code, it seems. In non-partial classes, it works fine.
I'm adding source generators to https://github.com/OpenRA/OpenRA/pull/21234 and this is proving to be a blocker for us!
@penev92 you can workaround this by setting EmitCompilerGeneratedFiles property to true
Even then the C# extension throws on all navigation operations that deal with creating an URL for generated code and once I manually open a generated file it can't use any symbols in it to navigate out.
I'm getting the same error and not sure why.
`Using dotnet configured on PATH
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit + C# IntelliCode...
waiting for named pipe information from server...
[stdout] {"pipeName":"\\\\.\\pipe\\0ffc6eee"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info - 6:22:10 PM] [Program] Language server initialized
[Info - 6:22:18 PM] [WorkspaceProjectFactoryService] Project C:\Users\markc\Documents\GitHub\MyFirstCSharpProject\MyFirstCSharpProject.csproj loaded by C# Dev Kit
[Error - 7:34:55 PM] [LanguageServerHost] System.UriFormatException: Failed create URI from 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs'; original string: 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs'
---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString, UriKind uriKind)
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 180
--- End of inner exception stack trace ---
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 188
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.<TextSpanToLocationAsync>g__ConvertTextSpanToLocationAsync|32_0(Document document, TextSpan span, Boolean isStale, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 479
at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.TextSpanToLocationAsync(Document document, TextSpan textSpan, Boolean isStale, Nullable`1 context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 444
at Microsoft.CodeAnalysis.LanguageServer.Handler.FindUsagesLSPContext.ComputeLocationAsync(Nullable`1 documentSpan, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs:line 209
at Microsoft.CodeAnalysis.LanguageServer.Handler.FindUsagesLSPContext.GenerateVSReferenceItemAsync(Int32 definitionId, Int32 id, Nullable`1 documentSpan, ImmutableDictionary`2 properties, ClassifiedTextElement definitionText, Glyph definitionGlyph, Nullable`1 symbolUsageInfo, Boolean isWrittenTo, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs:line 194
at Microsoft.CodeAnalysis.LanguageServer.Handler.FindUsagesLSPContext.OnReferenceFoundAsync(SourceReferenceItem reference, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs:line 167
at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindReferencesProgressAdapter.OnReferenceFoundAsync(SymbolGroup group, ISymbol definition, ReferenceLocation location, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs:line 123
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<>c__DisplayClass20_0.<<ProcessDocumentAsync>g__ProcessDocumentAsync|0>d.MoveNext() in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 301
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessDocumentAsync(Document document, MetadataUnifyingSymbolHashSet symbols, Dictionary`2 symbolToGlobalAliases, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 302
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessDocumentAsync(Document document, MetadataUnifyingSymbolHashSet symbols, Dictionary`2 symbolToGlobalAliases, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 302
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessProjectAsync(Project project, ImmutableArray`1 allSymbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 244
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessProjectAsync(Project project, ImmutableArray`1 allSymbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 244
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.FindReferencesAsync(ImmutableArray`1 symbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 132
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.FindReferencesAsync(ImmutableArray`1 symbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 132
at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.FindReferencesAsync(ImmutableArray`1 symbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 132
at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.FindReferencesAsync(ISymbol symbol, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet`1 documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindReferences_Current.cs:line 68
at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindReferencesAsync(IFindUsagesContext context, ISymbol symbol, Project project, FindReferencesSearchOptions options, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 154
at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindSymbolReferencesAsync(IFindUsagesContext context, ISymbol symbol, Project project, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 125
at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindSymbolReferencesAsync(IFindUsagesContext context, Document document, Int32 position, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 103
at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindLiteralOrSymbolReferencesAsync(IFindUsagesContext context, Document document, Int32 position, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 65
at Microsoft.CodeAnalysis.LanguageServer.Handler.FindAllReferencesHandler.HandleRequestAsync(ReferenceParams referenceParams, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs:line 68
at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 7:34:55 PM] Request textDocument/references failed.
Message: Failed create URI from 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs'; original string: 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs'
Code: -32000
[object Object]`
FYI: this is also blocking any 'Find all references' functionality for me.
I'm getting the same error and not sure why.
`Using dotnet configured on PATH Dotnet path: C:\Program Files\dotnet\dotnet.exe Activating C# + C# Dev Kit + C# IntelliCode... waiting for named pipe information from server... [stdout] {"pipeName":"\\\\.\\pipe\\0ffc6eee"} received named pipe information from server attempting to connect client to server... client has connected to server [Info - 6:22:10 PM] [Program] Language server initialized [Info - 6:22:18 PM] [WorkspaceProjectFactoryService] Project C:\Users\markc\Documents\GitHub\MyFirstCSharpProject\MyFirstCSharpProject.csproj loaded by C# Dev Kit [Error - 7:34:55 PM] [LanguageServerHost] System.UriFormatException: Failed create URI from 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs'; original string: 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs' ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions) at System.Uri..ctor(String uriString, UriKind uriKind) at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 180 --- End of inner exception stack trace --- at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.CreateAbsoluteUri(String absolutePath) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 188 at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.<TextSpanToLocationAsync>g__ConvertTextSpanToLocationAsync|32_0(Document document, TextSpan span, Boolean isStale, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 479 at Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions.TextSpanToLocationAsync(Document document, TextSpan textSpan, Boolean isStale, Nullable`1 context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs:line 444 at Microsoft.CodeAnalysis.LanguageServer.Handler.FindUsagesLSPContext.ComputeLocationAsync(Nullable`1 documentSpan, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs:line 209 at Microsoft.CodeAnalysis.LanguageServer.Handler.FindUsagesLSPContext.GenerateVSReferenceItemAsync(Int32 definitionId, Int32 id, Nullable`1 documentSpan, ImmutableDictionary`2 properties, ClassifiedTextElement definitionText, Glyph definitionGlyph, Nullable`1 symbolUsageInfo, Boolean isWrittenTo, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs:line 194 at Microsoft.CodeAnalysis.LanguageServer.Handler.FindUsagesLSPContext.OnReferenceFoundAsync(SourceReferenceItem reference, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs:line 167 at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindReferencesProgressAdapter.OnReferenceFoundAsync(SymbolGroup group, ISymbol definition, ReferenceLocation location, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs:line 123 at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.<>c__DisplayClass20_0.<<ProcessDocumentAsync>g__ProcessDocumentAsync|0>d.MoveNext() in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 301 --- End of stack trace from previous location --- at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessDocumentAsync(Document document, MetadataUnifyingSymbolHashSet symbols, Dictionary`2 symbolToGlobalAliases, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 302 at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessDocumentAsync(Document document, MetadataUnifyingSymbolHashSet symbols, Dictionary`2 symbolToGlobalAliases, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 302 at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessProjectAsync(Project project, ImmutableArray`1 allSymbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 244 at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.ProcessProjectAsync(Project project, ImmutableArray`1 allSymbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 244 at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.FindReferencesAsync(ImmutableArray`1 symbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 132 at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.FindReferencesAsync(ImmutableArray`1 symbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 132 at Microsoft.CodeAnalysis.FindSymbols.FindReferencesSearchEngine.FindReferencesAsync(ImmutableArray`1 symbols, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs:line 132 at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.FindReferencesAsync(ISymbol symbol, Solution solution, IStreamingFindReferencesProgress progress, IImmutableSet`1 documents, FindReferencesSearchOptions options, CancellationToken cancellationToken) in /_/src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindReferences_Current.cs:line 68 at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindReferencesAsync(IFindUsagesContext context, ISymbol symbol, Project project, FindReferencesSearchOptions options, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 154 at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindSymbolReferencesAsync(IFindUsagesContext context, ISymbol symbol, Project project, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 125 at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindSymbolReferencesAsync(IFindUsagesContext context, Document document, Int32 position, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 103 at Microsoft.CodeAnalysis.FindUsages.AbstractFindUsagesService.FindLiteralOrSymbolReferencesAsync(IFindUsagesContext context, Document document, Int32 position, CancellationToken cancellationToken) in /_/src/Features/Core/Portable/FindUsages/AbstractFindUsagesService_FindReferences.cs:line 65 at Microsoft.CodeAnalysis.LanguageServer.Handler.FindAllReferencesHandler.HandleRequestAsync(ReferenceParams referenceParams, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs:line 68 at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176 [Error - 7:34:55 PM] Request textDocument/references failed. Message: Failed create URI from 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs'; original string: 'Godot.SourceGenerators\Godot.SourceGenerators.ScriptPropertiesGenerator\PlayerMove_ScriptProperties.generated.cs' Code: -32000 [object Object]`
This temporary fix introduced here
~~It seems they changed default setting back to use OmniSharp instead of Roslyn.~~
Having it set to OmniSharp used to solve the issue IIRC, but now, when using "jump to definition" or "find all references" of Godot partial classes in OmniSharp, I do get to see the generated code in the popup thingy, but when clicking to actually open it in a new tab, there's another issue, an error in the Virtual Text Document Provider, it seems:
The editor could not be opened due to an unexpected error: Unable to resolve text model content for resource
omnisharp-source-generated:/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/[...]_ScriptMethods.generated.cs
In the dev tools console log:
ERR Error: Unable to resolve text model content for resource omnisharp-source-generated:/Godot.SourceGenerators/Godot.SourceGenerators.ScriptMethodsGenerator/MyNS.MyClass_ScriptMethods.generated.cs
at u.resolveTextModelContent (workbench.desktop.main.js:2413:50371)
at async u.doCreateReferencedObject (workbench.desktop.main.js:2413:49039)
at async v.acquire (workbench.desktop.main.js:37:3821)
at async h.createModelReference (workbench.desktop.main.js:2413:51322)
at async u.resolve (workbench.desktop.main.js:1903:52420)
at async r.setInput (workbench.desktop.main.js:2402:15966)
at async d.doSetInput (workbench.desktop.main.js:2400:35207)
at async d.doOpenEditor (workbench.desktop.main.js:2400:33029)
at async d.openEditor (workbench.desktop.main.js:2400:31739)
at async workbench.desktop.main.js:2530:31512
at async C.doOpenCodeEditor (workbench.desktop.main.js:1186:99411)
at async C.openCodeEditor (workbench.desktop.main.js:720:6831)
@geekley Who was "they" in this case?
I meant the developers of this extension. If I'm not mistaken dotnet.server.useOmnisharp had a default of false on this new version (v2?) but it appears it changed back to a default of true recently...? But I could be remembering this wrong.
We didn't change it no; it's still defaulted to false.
Well, I'm actually using a fork from Open-VSX, so it could be that. It defaults to true here:
@geekley Ah yes, it looks like @muhammadsammy did change the default for their fork:
https://github.com/muhammadsammy/free-vscode-csharp/commit/5c51b954bbcd6b44e49d951735020418d5376992
Same happens in Unity:
[Error - 11:09:28 PM] Request textDocument/references failed. Message: Failed create URI from 'Unity.Entities.SourceGen.SystemGenerator\Unity.Entities.SourceGen.SystemGenerator.SystemGenerator\ClientSystem__System_6611871210.g.cs'; original string: 'Unity.Entities.SourceGen.SystemGenerator\Unity.Entities.SourceGen.SystemGenerator.SystemGenerator\ClientSystem__System_6611871210.g.cs'
The latest update of v2.15.30 seems to have fixed the issue. Was able to find references without errors for a Godot (v4.2.1) project. Would like a second opinion from anyone else who was previously facing this issue.
Used to get the System.UriFormatException, I'm getting a different error when I try to "go to definition" now:
The editor could not be opened due to an unexpected error:
Unable to resolve resource source-generated:/Pictoria.Server.Generators/Pictoria.Server.Generators.DataAccessLayerIncrementalGenerator/PlayerModel.Generated.cs
Using the latest insider build:
Version: 1.86.0-insider (user setup)
Commit: a45edfc415d19852fa3c3e1cd255a02de9e016d2
Date: 2024-01-11T05:36:37.776Z
Electron: 27.2.1
ElectronBuildId: 26149897
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Windows_NT x64 10.0.22621
and vscode-csharp v2.15.30.
Edit:
Context: Pictoria.Server.Generators is a class library project with several incremental generators, including DataAccessLayerIncrementalGenerator. A console project references Pictoria.Server.Generators as a "project reference". I get the error when, in console project logic, I "go to definition" a Pictoria.Server.Generators generated type.
Extension version 2.15.30 appears to have resolved the go to symbol, go to definition, and go to implementations issues for me, too. This is a huge improvement in the experience for me and my team--thanks very much to the maintainers.
To clarify a bit: there's still more work to do to make Go to Definition to source generated files actually work. To give a bit of a sense how this works:
- The Roslyn server has to send down a custom URI to VS Code for source generated files, since they're potentially virtual and not on disk.
- The Roslyn VS Code extension then needs to recognize this URI and go display the dynamic content and such.
The UriFormatException was because we had a place that wasn't correctly doing the first step. So if you had find references that found 10 references, and just one happened to be in a source generated file, then we'd fail to create the URI properly and thus the entire request would fail. Which was icky. So we fixed that; the work for step 2 isn't in, which is why @JeremyTCD is getting the error he's seeing. But that'll only happen if you actually need to open a generated file. In my example of Find References w/ 10 references, at least now you can view the other 9. :smile:
I'm leaving this bug open until I actually fix the end-to-end though. I'll retitle it.
@jasonmalinowski thanks for clarifying, appreciate the work you're putting into this issue!
@jasonmalinowski any update on this?
@hutterm It's in code review now, so should land if not this week then next week.
@jasonmalinowski two weeks have passed, any update here?
@arsinclair This demonstrates why I should never give a promise of a ship date -- I'm now on leave with the arrival of our new baby. 👶 We'll have somebody else wrap up the work but we're still handing that off.