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

Upgrade Omnisharp.Extensions.LanguageServer to 0.16.0 #1754

Closed
wants to merge 4 commits into from

Conversation

razzmatazz
Copy link
Contributor

This brings some more LSP functionality to life. The fixes work for me --, under
emacs (emacs-lsp) I now have autocompletion, go-to-definition, error list,
lenses working via lsp.

I am not really sure if this is how I should plug ProgressManager into omnisharp code (i.e. what should the lifetime of progress manager look like). When looking at code samples from csharp-language-server-protocol repo, it seems that it should be a singleton and then passed over to handlers. Maybe @david-driscoll can comment on that.

@dnfclas
Copy link

dnfclas commented Apr 1, 2020

CLA assistant check
All CLA requirements met.

@razzmatazz razzmatazz changed the title Upgrade Omnisharp.Extensions.LanguageServer to 0.16.0 [WIP] Upgrade Omnisharp.Extensions.LanguageServer to 0.16.0 Apr 1, 2020
@razzmatazz
Copy link
Contributor Author

Oops, I didn't convert some of LanguageServerOptions update calls. I commented out in my branch and didn't fix before making a PR.

@d4ncer
Copy link

d4ncer commented Apr 21, 2020

Thanks for this @razzmatazz ! I've just started writing C# and I'm trying to build your branch on OS X, but it's been failing at the ExecuteRunScript step:

========================================
ExecuteRunScript
========================================
System.ArgumentException: Stateful callbacks are not supported for PollingFileChangeToken
Parameter name: state
  at OmniSharp.Utilities.PhysicalFileProviderExtensions+PollingFileChangeToken.RegisterChangeCallback (System.Action`1[T] callback, System.Object state) [0x0000a] in <590ffeff3d5144aea13c36245e853ee6>:0
  at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[TState].RegisterChangeTokenCallback (Microsoft.Extensions.Primitives.IChangeToken token) [0x00000] in <c3b12d09dbc54674b98ec51e8188e9fc>:0
  at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[TState]..ctor (System.Func`1[TResult] changeTokenProducer, System.Action`1[T] changeTokenConsumer, System.Action state) [0x00022] in <c3b12d09dbc54674b98ec51e8188e9fc>:0
  at Microsoft.Extensions.Primitives.ChangeToken.OnChange (System.Func`1[TResult] changeTokenProducer, System.Action changeTokenConsumer) [0x0001c] in <c3b12d09dbc54674b98ec51e8188e9fc>:0
  at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor (Microsoft.Extensions.Configuration.FileConfigurationSource source) [0x00035] in <5b0219d367fd4fd68bb5d8e979bb16b3>:0
  at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider..ctor (Microsoft.Extensions.Configuration.Json.JsonConfigurationSource source) [0x00000] in <0e68ef06fd2e44e8aef196caafeeef36>:0
  at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build (Microsoft.Extensions.Configuration.IConfigurationBuilder builder) [0x00007] in <0e68ef06fd2e44e8aef196caafeeef36>:0
  at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build () [0x0001a] in <73ed7793ea1a45819bf37bbc13eec1c6>:0
  at OmniSharp.ConfigurationBuilder.Build () [0x00079] in <bba286bb0f664b74bc7e305a7f088607>:0
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x000db] in <9c6d323a86d94d29a42049f2317275d9>:0
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000d] in <bba286bb0f664b74bc7e305a7f088607>:0
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00039] in <344a1e8cd6594b17b1e01f8df6ae8827>:0
  at OmniSharp.CommandLineApplication.Execute (System.String[] args) [0x000a7] in <bba286bb0f664b74bc7e305a7f088607>:0
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x0002a] in <9c6d323a86d94d29a42049f2317275d9>:0
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x00029] in <bba286bb0f664b74bc7e305a7f088607>:0

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at OmniSharp.Utilities.PhysicalFileProviderExtensions+PollingFileChangeToken.DisposeCore (System.Boolean disposing) [0x00021] in <590ffeff3d5144aea13c36245e853ee6>:0
  at OmniSharp.Utilities.DisposableObject.Dispose () [0x00001] in <590ffeff3d5144aea13c36245e853ee6>:0
  at OmniSharp.Utilities.PhysicalFileProviderExtensions+PhysicalFileProviderWrapper.DisposeCore (System.Boolean disposing) [0x00020] in <590ffeff3d5144aea13c36245e853ee6>:0
  at OmniSharp.Utilities.DisposableObject.Finalize () [0x00002] in <590ffeff3d5144aea13c36245e853ee6>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at OmniSharp.Utilities.PhysicalFileProviderExtensions+PollingFileChangeToken.DisposeCore (System.Boolean disposing) [0x00021] in <590ffeff3d5144aea13c36245e853ee6>:0
  at OmniSharp.Utilities.DisposableObject.Dispose () [0x00001] in <590ffeff3d5144aea13c36245e853ee6>:0
  at OmniSharp.Utilities.PhysicalFileProviderExtensions+PhysicalFileProviderWrapper.DisposeCore (System.Boolean disposing) [0x00020] in <590ffeff3d5144aea13c36245e853ee6>:0
  at OmniSharp.Utilities.DisposableObject.Finalize () [0x00002] in <590ffeff3d5144aea13c36245e853ee6>:0

Is there something I'm missing or should be doing?

@razzmatazz
Copy link
Contributor Author

@d4ncer

Is there something I'm missing or should be doing?

No, I was stuck on the same thing and this is why the PR has [WIP] flag.. I just uncommented the line throwing the exception in PhysicalFileProviderExtensions.cs when I was testing on my machine, but I didn't find a solution yet (busy with other things in the meantime).

@d4ncer
Copy link

d4ncer commented Apr 21, 2020

@razzmatazz Ah that makes sense, will try commenting the line out to test! Thank you 🙇

@rwols
Copy link

rwols commented Apr 27, 2020

Can we split this PR up into getting things to work at all versus adding extremely advanced features like progress managers?

v1.35 of omnisharp-roslyn reports textDocumentSync: 0 as a capability, rendering the language server essentially useless.

@razzmatazz
Copy link
Contributor Author

Can we split this PR up into getting things to work at all versus adding extremely advanced features like progress managers?

v1.35 of omnisharp-roslyn reports textDocumentSync: 0 as a capability, rendering the language server essentially useless.

The api for LSP extension has changed and progress manager is required in all the places to be provided. I might have not discovered a way to avoid this by submitting a mock in every place and I might not understand the new progress manager api properly, but this PR is results of my first attempt last time.

razzmatazz added 2 commits May 9, 2020 18:12
This brings some more LSP functionality to life. Works for me --, under
emacs (emacs-lsp) I now have autocompletion, go-to-definition, error list,
lenses working.
…ileChangeToken.cs

After upgrade of Omnisharp.Extensions.LSP we started getting errors
where Microsoft.Extensions.Configuration API started to register
stateful file change callbacks.
@razzmatazz
Copy link
Contributor Author

razzmatazz commented May 9, 2020

@d4ncer I believe I fixed the issue with PollingFileChangeToken (hopefully didn't break live omnisharp.json reloading).

There is still an issue with log messages not being reported to LSP client, thus still [WIP].

But it seems to be somewhat working at this state (at least with emacs/emacs-lsp)

This uses LoggerFactory as built by composition host so we can actually
have logging working with the new Omnisharp.Extensions.LSP version.
@razzmatazz razzmatazz changed the title [WIP] Upgrade Omnisharp.Extensions.LanguageServer to 0.16.0 Upgrade Omnisharp.Extensions.LanguageServer to 0.16.0 May 9, 2020
@razzmatazz
Copy link
Contributor Author

I got logging to client working again, and maybe someone can review this PR. All the changes related to ProgressManager needs review the most, as I am not sure about semantics, but the changes appear not to break/make things worse.

@d4ncer
Copy link

d4ncer commented May 10, 2020

@razzmatazz Great news! I'll try again sometime today and report back. For some reason I couldn't get even basic go-to-def working with master, so I switched to using omnisharp-emacs instead, which has been amazing! So thank you for both 😂

@razzmatazz
Copy link
Contributor Author

Hi @filipw. Would it be possible to review this PR as it fixes LSP mode of omnisharp-roslyn (w.r.t. file sync issue)?

@razzmatazz
Copy link
Contributor Author

I have created a more conservative version of this PR in:

Which does not require so many changes to the codebase (no ProgressManager changes required) and still fixes the issue with file synchronisation.

@razzmatazz
Copy link
Contributor Author

Closing this one in favor of the more conservative #1791

@razzmatazz razzmatazz closed this May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants