Skip to content
New issue

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

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

Already on GitHub? # to your account

Add UriKind.RelativeOrAbsolute #189

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Conversation

granitrocky
Copy link

I was running into an issue with UriFormat errors. Reading the dotnet docs, if a relative path is passed into the Uri constructor, it throws this error. By adding UriKind.RelativeOrAbsolute to the constructor, the errors go away and everything works as expected:

https://learn.microsoft.com/en-us/dotnet/api/system.uri.-ctor?view=net-8.0#system-uri-ctor(system-string-system-urikind)

lsp-request: 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)
   at CSharpLanguageServer.Conversions.Uri.fromPath(String path) in /home/jonny/programming/csharp-language-server/src/CSharpLanguageServer/Conversions.fs:line 25
   at CSharpLanguageServer.Conversions.Path.toUri@33.Invoke(String path)
   at CSharpLanguageServer.Conversions.Location.fromRoslynLocation(Location loc) in /home/jonny/programming/csharp-language-server/src/CSharpLanguageServer/Conversions.fs:line 71
   at CSharpLanguageServer.Handlers.References.Pipe #1 stage #2 at line 49@49-1.Invoke(ReferenceLocation rl) in /home/jonny/programming/csharp-language-server/src/CSharpLanguageServer/Handlers/References.fs:line 49
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@99.DoMoveNext(b& curr) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 102
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator‘1.System.Collections.IEnumerator.MoveNext() in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 84
   at Microsoft.FSharp.Collections.SeqModule.Distinct@1316.GenerateNext(IEnumerable‘1& next) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 1318
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase‘1.MoveNextImpl() in D:\a\_work\1\s\src\FSharp.Core\seqcore.fs:line 427
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase‘1.System.Collections.IEnumerator.MoveNext() in D:\a\_work\1\s\src\FSharp.Core\seqcore.fs:line 469
   at System.Collections.Generic.List‘1..ctor(IEnumerable‘1 collection)
   at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable‘1 source) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 989
   at CSharpLanguageServer.Handlers.References.handle@46-163.Invoke(IEnumerable‘1 _arg2) in /home/jonny/programming/csharp-language-server/src/CSharpLanguageServer/Handlers/References.fs:line 51
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation‘1 ctxt, b result1, FSharpFunc‘2 userCode) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 525
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc‘2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112

@razzmatazz
Copy link
Owner

could you provide a test case for this issue? so it could be encoded as a unit test?

btw is this on linux, macos or windows?

@granitrocky
Copy link
Author

This is on Fedora Workstation 40. I'll try and get an MRP, but this was the first I had seen this problem. I think it's from multiple external references, but I'll see what I can find.

@granitrocky
Copy link
Author

So I seem to only be able to reproduce this behavior when there is a source generator in the project, and I use find-references. I am using this while building a game in Godot, so that is where I am seeing the error.

@razzmatazz
Copy link
Owner

I have just tested this with ASP.NET project where source generators are used for .cshtml and it fixes the issue there as well!

This also seems to be very much related to #178

Thank you!

@razzmatazz razzmatazz merged commit dee5c62 into razzmatazz:master Sep 27, 2024
1 of 2 checks passed
razzmatazz added a commit that referenced this pull request Nov 15, 2024
.. by reverting #189 (will fix later)
razzmatazz added a commit that referenced this pull request Nov 15, 2024
…ext.IncludeDeclaration (#199)

* Add tests for "textDocument/references" handler

* Respect Context.IncludeDeclaration in handler for "textDocument/findReferences"

* Update CHANGELOG.md

* Fix an issue in Windows tests

.. by reverting #189 (will fix later)

* another attempt at it
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants