tgjones / HlslTools

A Visual Studio extension that provides enhanced support for editing High Level Shading Language (HLSL) files
http://timjones.io/blog/archive/2016/04/25/hlsl-tools-for-visual-studio-v1.0-released
Other
561 stars 97 forks source link

VSCode: Language Client: NullReferenceException #199

Closed simco50 closed 3 years ago

simco50 commented 3 years ago

I seem to get this error in the output log each time I switch between file. Is this a known/common issue? Any idea what I can do about it?

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at OmniSharp.Extensions.LanguageServer.Server.Matchers.TextDocumentMatcher.GetHandler(IEnumerable`1 descriptors, TextDocumentAttributes attributes)+MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.FindDescriptor(String method, JToken params)
   at OmniSharp.Extensions.JsonRpc.InputHandler.HandleRequest(String request)
   at OmniSharp.Extensions.JsonRpc.InputHandler.ProcessInputStream()
   at System.Threading.Thread.ThreadMain_ThreadStart()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[Info  - 12:47:10] Connection to server got closed. Server will restart.
[Error - 12:47:40] Failed to handle notification textDocument/documentSymbol - System.NullReferenceException: Object reference not set to an instance of an object.
   at ShaderTools.CodeAnalysis.NavigateTo.NavigateToSearchService.SearchDocumentAsync(Document document, String searchPattern, CancellationToken cancellationToken) in D:\a\1\s\src\ShaderTools.CodeAnalysis.Features\NavigateTo\NavigateToSearchService.cs:line 24
   at ShaderTools.LanguageServer.Helpers.FindSymbolsInDocument(INavigateToSearchService searchService, Document document, String searchPattern, CancellationToken cancellationToken, Builder resultsBuilder) in D:\a\1\s\src\ShaderTools.LanguageServer\Helpers.cs:line 111
   at ShaderTools.LanguageServer.Handlers.DocumentSymbolsHandler.Handle(DocumentSymbolParams request, CancellationToken token) in D:\a\1\s\src\ShaderTools.LanguageServer\Handlers\DocumentSymbolsHandler.cs:line 34
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
[Error - 12:47:40] Request textDocument/documentSymbol failed.
  Message: Internal Error - System.NullReferenceException: Object reference not set to an instance of an object.
   at ShaderTools.CodeAnalysis.NavigateTo.NavigateToSearchService.SearchDocumentAsync(Document document, String searchPattern, CancellationToken cancellationToken) in D:\a\1\s\src\ShaderTools.CodeAnalysis.Features\NavigateTo\NavigateToSearchService.cs:line 24
   at ShaderTools.LanguageServer.Helpers.FindSymbolsInDocument(INavigateToSearchService searchService, Document document, String searchPattern, CancellationToken cancellationToken, Builder resultsBuilder) in D:\a\1\s\src\ShaderTools.LanguageServer\Helpers.cs:line 111
   at ShaderTools.LanguageServer.Handlers.DocumentSymbolsHandler.Handle(DocumentSymbolParams request, CancellationToken token) in D:\a\1\s\src\ShaderTools.LanguageServer\Handlers\DocumentSymbolsHandler.cs:line 34
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
  Code: -32602 
simco50 commented 3 years ago

I'm not sure if it's a coincidence but it looks like it has to do with administrator privileges. After reinstalling VSCode as a user instead of system, the errors are gone.

simco50 commented 3 years ago

Actually, I closed this issue too soon. This still happens with a User Install. It's quite annoying because it keeps popping up the output log.

pixtur commented 3 years ago

I have the same (or very similar issue). Opening the HLSL file works fine but on the first save or opening another file, the message is printed on every keystroke or mouse interaction. Also syntax error check stops working.

Edit: Ctrl+Shift+P > Developer: Restart Extension Host fixes the problem until I open another file.

thavide commented 3 years ago

Just bumping this thread as I also face this issue.