diff --git a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs index 1dd9dc4d54b62bb1fd3c24080022884ab1b086e5..0d847ff5fc202b49876b11d1d39fa643ad92b77a 100644 --- a/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs +++ b/src/EditorFeatures/Core/Implementation/ReferenceHighlighting/AbstractDocumentHighlightsService.cs @@ -130,12 +130,17 @@ private bool ShouldConsiderSymbol(ISymbol symbol) bool addAllDefinitions = true; // Add definitions + // Filter out definitions that cannot be highlighted. e.g: alias symbols defined via project property pages. if (symbol.Kind == SymbolKind.Alias && symbol.Locations.Length > 0) { - // For alias symbol we want to get the tag only for the alias definition, not the target symbol's definition. - await AddLocationSpan(symbol.Locations.First(), solution, spanSet, tagMap, HighlightSpanKind.Definition, cancellationToken).ConfigureAwait(false); addAllDefinitions = false; + + if (symbol.Locations.First().IsInSource) + { + // For alias symbol we want to get the tag only for the alias definition, not the target symbol's definition. + await AddLocationSpan(symbol.Locations.First(), solution, spanSet, tagMap, HighlightSpanKind.Definition, cancellationToken).ConfigureAwait(false); + } } // Add references and definitions diff --git a/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb b/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb index 955310e4766f109178de24bbd6c535664e47daac..878578000ca1700752a473ceaf018937078ca736 100644 --- a/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb +++ b/src/EditorFeatures/Test2/ReferenceHighlighting/VisualBasicReferenceHighlightingTests.vb @@ -272,5 +272,27 @@ End Class VerifyHighlights(input) End Sub + + + + + Public Sub VerifyHighlightsForVisualBasicGlobalImportAliasedNamespace() + VerifyHighlights( + + + VB = Microsoft.VisualBasic + + Class Test + Public Sub TestMethod() + ' Add reference tags to verify after #2079 is fixed + Console.Write(NameOf($$VB)) + Console.Write(NameOf(VB)) + Console.Write(NameOf(Microsoft.VisualBasic)) + End Sub + End Class + + + ) + End Sub End Class End Namespace