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

Code lens System.ArgumentNullException in diff editor #5843

Closed
vchirikov opened this issue Jun 21, 2023 · 9 comments · Fixed by dotnet/roslyn#74544
Closed

Code lens System.ArgumentNullException in diff editor #5843

vchirikov opened this issue Jun 21, 2023 · 9 comments · Fixed by dotnet/roslyn#74544
Assignees
Milestone

Comments

@vchirikov
Copy link

Environment data

dotnet --info output:

.NET SDK:
 Version:   8.0.100-preview.3.23178.7
 Commit:    e300b0e1e6

VS Code version: 1.79.2
C# Extension version: v2.0.212

log

[Error - 2:48:15 PM] [LanguageServerHost]System.ArgumentNullException: Value cannot be null. (Parameter 'Document is null when it was required for codeLens/resolve')
   at Microsoft.CodeAnalysis.LanguageServer.Handler.RequestContext.GetRequiredDocument() in /_/src/Features/LanguageServer/Protocol/Handler/RequestContext.cs:line 191
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens.CodeLensResolveHandler.HandleRequestAsync(CodeLens request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs:line 38
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 124
   
   
...


[Error - 2:48:15 PM] Request codeLens/resolve failed.
  Message: Value cannot be null. (Parameter 'Document is null when it was required for codeLens/resolve')
  Code: -32000 
  
...

[Error - 2:48:17 PM] [LanguageServerHost]System.ArgumentNullException: Value cannot be null. (Parameter 'Document is null when it was required for codeLens/resolve')
   at Microsoft.CodeAnalysis.LanguageServer.Handler.RequestContext.GetRequiredDocument() in /_/src/Features/LanguageServer/Protocol/Handler/RequestContext.cs:line 191
   at Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens.CodeLensResolveHandler.HandleRequestAsync(CodeLens request, RequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs:line 38
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken)

Steps to reproduce

  1. Open modified cs file diff (diff editor)
  2. See the errors

Codelens related config:

  "csharp.referencesCodeLens.enabled": false,
  "csharp.testsCodeLens.enabled": true,
  "merge-conflict.codeLens.enabled": true,
  "diffEditor.codeLens": true,

Expected behavior

No errors

Actual behavior

Error popup & error logs

@vchirikov
Copy link
Author

@beccamc any updates on this?

@beccamc
Copy link
Contributor

beccamc commented Jul 7, 2023

@vchirikov I am able to reproduce and have tracked down the root cause. We're having an issue with URL encodings coming from VS Code making file paths not equivalent. I am working on a fix. Thanks for your patience on this!

@arunchndr arunchndr modified the milestones: Preview 2, GA Jul 25, 2023
@beccamc
Copy link
Contributor

beccamc commented Jul 31, 2023

The root cause is the DocumentUriConverter returning a path using URL encodings. Working with the relevant team on a fix.

This test case is a simple way to reproduce...

        var gitString = "git:/c:/Repos/MyRepo/MyNewFile.cs?{\"path\":\"c:\\\\Repos\\\\MyRepo\\\\MyNewFile.cs\",\"ref\":\"~\"}";
        var myUri = new System.Uri(gitString);

        var serializedWithConverter = JsonConvert.SerializeObject(myUri, new DocumentUriConverter());
        var deserializedWithConverter = JsonConvert.DeserializeObject<Uri>(serializedWithConverter, new DocumentUriConverter());

        // this fails because "%22": "%5C%5C" are used 
        Assert.Equal(myUri.OriginalString, deserializedWithConverter.OriginalString);

@dibarbet dibarbet modified the milestones: GA, August Aug 2, 2023
@vchirikov
Copy link
Author

@beccamc will it be included in august releases? the extension doesn't work at all without it

@beccamc
Copy link
Contributor

beccamc commented Aug 25, 2023

@tmat Do you know about the status of the DocumentUri fix?

@tmat
Copy link
Member

tmat commented Aug 25, 2023

Where is Uri.OriginalString used?

@beccamc
Copy link
Contributor

beccamc commented Aug 25, 2023

@tmat This was supposed to be fixed by this PR I believe - dotnet/roslyn#69304. This went in a couple weeks ago. I can check and see if the issue still reproduces.

@tmat
Copy link
Member

tmat commented Aug 25, 2023

I don't think it would be. That fix only addressed issues with certain Unicode characters.

@arunchndr arunchndr modified the milestones: August, October Oct 2, 2023
@beccamc
Copy link
Contributor

beccamc commented Dec 20, 2023

@tmat Do you mind taking over this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants