提交 71b47d09 编写于 作者: J Jason Malinowski

Move SymbolDescriptionServiceTests.vb over to SymbolFinder.FindSymbolAtPositionAsync

I'm guessing these tests originated originally as the Quick Info tests,
and then at some point we broke Quick Info into two pieces: the part
that finds the symbol, and then the conversion of that symbol to the
display form for it. These tests are (nominally) the tests for just the
display service, but it was also testing some Quick Info-specific
behavior making sure we find the symbol in certain edge cases. But it
wasn't doing this by calling into Quick Info: it was doing with a
reimplementation of the first part of Quick Info (namely, finding the
symbol). In short: it wasn't actually testing product behavior, it was
just testing the test's ability to implement its random copy of the
product behavior.

As a result, I'm deleting all the tests out of
SymbolDescriptionServiceTests.vb that were really just testing our
ability to find the symbol; I've verified that there were tests for
the actual product Quick Info for all the scenarios and added the ones
that were missing. This is also good, because it means we have actual
test coverage for product behavior which we didn't before.
上级 d2e20660
......@@ -1251,6 +1251,12 @@ public async Task TestNullLiteral()
MainDescription("class System.String"));
}
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task TestNullLiteralWithVar()
{
await TestInMethodAsync(@"var f = null$$");
}
[WorkItem(26027, "https://github.com/dotnet/roslyn/issues/26027")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task TestDefaultLiteral()
......
......@@ -3,6 +3,7 @@
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.FindSymbols
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.LanguageServices
......@@ -19,21 +20,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Dim cursorBuffer = cursorDocument.TextBuffer
Dim document = workspace.CurrentSolution.GetDocument(cursorDocument.Id)
' using GetTouchingWord instead of FindToken allows us to test scenarios where cursor is at the end of token (E.g: Goo$$)
Dim tree = Await document.GetSyntaxTreeAsync()
Dim commonSyntaxToken = Await tree.GetTouchingWordAsync(cursorPosition, languageServiceProvider.GetService(Of ISyntaxFactsService), Nothing)
' For String Literals GetTouchingWord returns Nothing, we still need this for Quick Info. Quick Info code does exactly the following.
' caveat: The comment above the previous line of code. Do not put the cursor at the end of the token.
If commonSyntaxToken = Nothing Then
commonSyntaxToken = (Await document.GetSyntaxRootAsync()).FindToken(cursorPosition)
End If
Dim semanticModel = Await document.GetSemanticModelAsync()
Dim symbol = semanticModel.GetSemanticInfo(commonSyntaxToken, document.Project.Solution.Workspace, CancellationToken.None).
GetSymbols(includeType:=True).
AsImmutable()
Dim symbol = Await SymbolFinder.FindSymbolAtPositionAsync(document, cursorPosition)
Dim symbolDescriptionService = languageServiceProvider.GetService(Of ISymbolDisplayService)()
......@@ -108,44 +96,6 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Await TestCSharpAsync(workspace, $"({FeaturesResources.local_constant}) int x = 2")
End Function
<Fact>
Public Async Function TestCSharpNullLiteralVar() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Goo
{
void Method()
{
var x = nu$$ll
}
}
</Document>
</Project>
</Workspace>
Await TestCSharpAsync(workspace, "")
End Function
<Fact>
Public Async Function TestCSharpNullLiteralString() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class Goo
{
void Method()
{
string x = nu$$ll
}
}
</Document>
</Project>
</Workspace>
Await TestCSharpAsync(workspace, "class System.String")
End Function
<Fact>
Public Async Function TestCSharpStaticField() As Task
Dim workspace =
......@@ -649,125 +599,6 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Await TestBasicAsync(workspace, $"({FeaturesResources.local_variable}) x As String")
End Function
<Fact>
Public Async Function TestStringLiteral() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
Sub Method()
Dim x As String = "Hel$$lo"
End Sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, "Class System.String")
End Function
<Fact>
Public Async Function TestIntegerLiteral() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
Sub Method()
Dim x = 4$$2
End Sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, "Structure System.Int32")
End Function
<Fact>
Public Async Function TestDateLiteral() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
Sub Method()
Dim d As Date
d = #8/23/1970 $$3:45:39 AM#
End Sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, "Structure System.DateTime")
End Function
<Fact>
Public Async Function TestNothingLiteralDim() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
Sub Method()
Dim x = Nothin$$g
End Sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, "Class System.Object")
End Function
<Fact>
Public Async Function TestNothingLiteralDimAsString() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
Sub Method()
Dim x As String = Nothin$$g
End Sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, "Class System.String")
End Function
<Fact>
Public Async Function TestNothingLiteralFieldDimOptionStrict() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Option Strict On
Class Goo
Dim x = Nothin$$g
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, "Class System.Object")
End Function
<Fact>
Public Async Function TestTrueKeyword() As Task
Dim workspace =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Class Goo
Sub Method()
Dim x = Tr$$ue
End Sub
End Class
</Document>
</Project>
</Workspace>
Await TestBasicAsync(workspace, "Structure System.Boolean")
End Function
<WorkItem(538732, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538732")>
<Fact>
Public Async Function TestMethod() As Task
......
......@@ -1751,6 +1751,12 @@ End Class]]></text>.NormalizedValue(),
MainDescription("Structure System.Int32"))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Async Function TestDateLiteral() As Task
Await TestInMethodAsync("Dim f = #8/23/1970 $$3:45:39 AM#",
MainDescription("Structure System.DateTime"))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Async Function TestTrueKeyword() As Task
Await TestInMethodAsync("Dim f = True$$",
......@@ -1770,6 +1776,22 @@ End Class]]></text>.NormalizedValue(),
MainDescription("Class System.String"))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Async Function TestNothingLiteralWithNoType() As Task
Await TestInMethodAsync("Dim f = Nothing$$",
MainDescription("Class System.Object"))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Async Function TestNothingLiteralFieldDimOptionStrict() As Task
Await TestAsync("
Option Strict On
Class C
Dim f = Nothing$$
End Class",
MainDescription("Class System.Object"))
End Function
''' <Remarks>
''' As a part of fix for 756226, quick info for VB Await keyword now displays the type inferred from the AwaitExpression. This is C# behavior.
''' In Dev12, quick info for VB Await keyword was the syntactic help "Await &lt;expression&gt;".
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册