Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Go to Definition on a source-generated method doesn't work #6350

Closed
arunchndr opened this issue Sep 12, 2023 · 2 comments
Closed

[BUG] Go to Definition on a source-generated method doesn't work #6350

arunchndr opened this issue Sep 12, 2023 · 2 comments
Assignees
Milestone

Comments

@arunchndr
Copy link
Member

From vscode-dotnettools created by svick: microsoft/vscode-dotnettools#457

Describe the Issue

It seems that using Go to Definition on a partial method whose definition comes from a source generator does not work.

Steps To Reproduce

  1. Create a new .Net 7 project.

  2. Add the following code:

    using System;
    using System.Text.RegularExpressions;
    
    partial class Target
    {
        [GeneratedRegex("abc|def", RegexOptions.IgnoreCase, "en-US")]
        private static partial Regex AbcOrDefGeneratedRegex();
    
        static void Main()
        {
            Console.WriteLine(AbcOrDefGeneratedRegex().Match("foo"));
        }
    }
  3. Use Go to Definition on AbcOrDefGeneratedRegex().

  4. Error "Request textDocument/definition failed." pops up. The log contains:

[Error - 4:09:41 PM] [LanguageServerHost]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 174
   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 464
   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 429
   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 61
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 176
[Error - 4:09:41 PM] Request textDocument/definition failed.
  Message: Invalid URI: The format of the URI could not be determined.
  Code: -32000 
[object Object]

Environment Information

  • Latest release (v0.3.21) or pre-release version Dev Kit extension (v0.4.8)
  • v2.0.416 of C# extension
@arunchndr
Copy link
Member Author

Consistent repro, but only with C# Dev Kit installed. cc: @dibarbet in case this came up in the uri support context.

@arunchndr arunchndr modified the milestones: September, October Oct 2, 2023
@jasonmalinowski
Copy link
Member

Duplicate of #6426.

@jasonmalinowski jasonmalinowski closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants