Skip to content

NullReferenceException is thrown when caret touches orderby in LINQ expression #76972

Closed
@jhinder

Description

@jhinder

Version Used: VS 17.12.4

Steps to Reproduce:
Place the caret on the orderby token.

_ = from n in Enumerable.Empty<int>()
    orderby n descending
    select n;

Expected Behavior: No exception.

Actual Behavior:
Gold bar "Feature 'Document highlights' is currently unavailable due to an internal error" with the following stacktrace:

StreamJsonRpc.RemoteInvocationException: Object reference not set to an instance of an object.
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__156`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Remote.BrokeredServiceConnection`1.<TryInvokeAsync>d__20`1.MoveNext()
RPC server exception:
System.NullReferenceException: Object reference not set to an instance of an object.
      at Microsoft.CodeAnalysis.ImmutableArrayExtensions.WhereAsArrayImpl[T,TArg](ImmutableArray`1 array, Func`2 predicateWithoutArg, Func`3 predicateWithArg, TArg arg)
      at Microsoft.CodeAnalysis.Shared.Extensions.SemanticModelExtensions.GetSemanticInfo(SemanticModel semanticModel, SyntaxToken token, SolutionServices services, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.GetSemanticInfoAtPositionAsync(SemanticModel semanticModel, Int32 position, SolutionServices services, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.FindSymbols.SymbolFinder.FindSymbolAtPositionAsync(SemanticModel semanticModel, Int32 position, SolutionServices services, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.GetDocumentHighlightsInCurrentProcessAsync(Document document, Int32 position, IImmutableSet`1 documentsToSearch, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.DocumentHighlighting.AbstractDocumentHighlightsService.GetDocumentHighlightsAsync(Document document, Int32 position, IImmutableSet`1 documentsToSearch, HighlightingOptions options, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteDocumentHighlightsService.<>c__DisplayClass2_0.<<GetDocumentHighlightsAsync>b__0>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.<>c__DisplayClass7_0`1.<<RunWithSolutionAsync>g__ProcessSolutionAsync|1>d.MoveNext()
   --- End of stack trace from previous location ---
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.RemoteWorkspace.RunWithSolutionAsync[T](AssetProvider assetProvider, Checksum solutionChecksum, Boolean updatePrimaryBranch, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunWithSolutionAsync[T](Checksum solutionChecksum, Func`2 implementation, CancellationToken cancellationToken)
      at Microsoft.CodeAnalysis.Remote.BrokeredServiceBase.RunServiceImplAsync[T](Func`2 implementation, CancellationToken cancellationToken)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions