From 57235f4910b84366472d796f7f92ff4a7fbf840a Mon Sep 17 00:00:00 2001 From: Ben Lichtman Date: Mon, 6 Apr 2020 17:17:19 -0700 Subject: [PATCH] Handle null IGoToDefinitionService in peek Currently, the `PeekableItemSource` assumes that if a language exports an `IGoToDefinitionService`, then it's non-null - however, this is incorrect, and can cause a null reference exception dialog in VS. Here, we gracefully handle the potential null. --- .../Core/Implementation/Peek/PeekableItemSource.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs index 3798c1a3344..4f988f07be1 100644 --- a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs +++ b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs @@ -67,6 +67,11 @@ public void AugmentPeekSession(IPeekSession session, IList peekab // For documents without semantic models, just try to use the goto-def service // as a reasonable place to peek at. var goToDefinitionService = document.GetLanguageService(); + if (goToDefinitionService == null) + { + return; + } + var navigableItems = goToDefinitionService.FindDefinitionsAsync(document, triggerPoint.Value.Position, cancellationToken) .WaitAndGetResult(cancellationToken); -- GitLab