-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19873 from CyrusNajmabadi/docHighlightsCrash
Fix crash in DocHighlights when delegating to a different language.
- Loading branch information
Showing
3 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/EditorFeatures/Test2/ReferenceHighlighting/DocumentHighlightsServiceTests.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Imports System.Collections.Immutable | ||
Imports System.Threading | ||
Imports System.Threading.Tasks | ||
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces | ||
|
||
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReferenceHighlighting | ||
Public Class DocumentHighlightsServiceTests | ||
|
||
<WorkItem(441151, "https://devdiv.visualstudio.com/DevDiv/_workitems/edit/441151")> | ||
<Fact, Trait(Traits.Feature, Traits.Features.ReferenceHighlighting)> | ||
Public Async Function TestMultipleLanguagesPassedToAPI() As Task | ||
Dim workspaceElement = | ||
<Workspace> | ||
<Project Language="C#" CommonReferences="true"> | ||
<Document> | ||
class C | ||
{ | ||
$$string Blah() | ||
{ | ||
return null; | ||
} | ||
} | ||
</Document> | ||
</Project> | ||
<Project Language="Visual Basic"> | ||
<Document> | ||
Class VBClass | ||
End Class | ||
</Document> | ||
</Project> | ||
</Workspace> | ||
Using workspace = TestWorkspace.Create(workspaceElement) | ||
Dim position = workspace.DocumentWithCursor.CursorPosition.Value | ||
|
||
Dim solution = workspace.CurrentSolution | ||
Dim csharpDocument = solution.Projects.Single(Function(p) p.Language = LanguageNames.CSharp).Documents.Single() | ||
Dim vbDocument = solution.Projects.Single(Function(p) p.Language = LanguageNames.VisualBasic).Documents.Single() | ||
|
||
Dim service = csharpDocument.GetLanguageService(Of Microsoft.CodeAnalysis.DocumentHighlighting.IDocumentHighlightsService) | ||
Await service.GetDocumentHighlightsAsync( | ||
csharpDocument, position, ImmutableHashSet.Create(csharpDocument, vbDocument), CancellationToken.None) | ||
End Using | ||
End Function | ||
End Class | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters