|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.Classification
Imports Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
Imports Microsoft.CodeAnalysis.Test.Utilities.QuickInfo
Imports Microsoft.VisualStudio.Core.Imaging
Imports Microsoft.VisualStudio.Imaging
Imports Microsoft.VisualStudio.Text.Adornments
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
<Trait(Traits.Feature, Traits.Features.QuickInfo)>
Public Class IntellisenseQuickInfoBuilderTests_Links
Inherits AbstractIntellisenseQuickInfoBuilderTests
<WpfTheory>
<InlineData("see")>
<InlineData("a")>
Public Async Function QuickInfoForPlainHyperlink(tag As String) As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
class MyClass {
/// <summary>
/// This contains a link to <<%= tag %> href="https://github.com/dotnet/roslyn"/>.
/// </summary>
void MyMethod() {
MyM$$ethod();
}
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.MethodPrivate)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "void"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "."),
New ClassifiedTextRun(ClassificationTypeNames.MethodName, "MyMethod", navigationAction:=Sub() Return, "void MyClass.MyMethod()"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "("),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, ")"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "This contains a link to"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.Text, "https://github.com/dotnet/roslyn", QuickInfoHyperLink.TestAccessor.CreateNavigationAction(New Uri("https://github.com/dotnet/roslyn", UriKind.Absolute)), "https://github.com/dotnet/roslyn"),
New ClassifiedTextRun(ClassificationTypeNames.Text, "."))))
ToolTipAssert.EqualContent(expected, intellisenseQuickInfo.Item)
End Function
<WpfTheory>
<InlineData("see")>
<InlineData("a")>
Public Async Function QuickInfoForHyperlinkWithText(tag As String) As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
class MyClass {
/// <summary>
/// This contains a link to <<%= tag %> href="https://github.com/dotnet/roslyn">dotnet/roslyn</<%= tag %>>.
/// </summary>
void MyMethod() {
MyM$$ethod();
}
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.MethodPrivate)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "void"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "."),
New ClassifiedTextRun(ClassificationTypeNames.MethodName, "MyMethod", navigationAction:=Sub() Return, "void MyClass.MyMethod()"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "("),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, ")"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "This contains a link to"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.Text, "dotnet/roslyn", QuickInfoHyperLink.TestAccessor.CreateNavigationAction(New Uri("https://github.com/dotnet/roslyn", UriKind.Absolute)), "https://github.com/dotnet/roslyn"),
New ClassifiedTextRun(ClassificationTypeNames.Text, "."))))
ToolTipAssert.EqualContent(expected, intellisenseQuickInfo.Item)
End Function
<WpfFact>
Public Async Function QuickInfoForBuiltInTypeReference() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
class MyClass {
/// <summary>
/// This contains a link to <see cref="string"/>.
/// </summary>
void MyMethod() {
MyM$$ethod();
}
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.MethodPrivate)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "void"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "."),
New ClassifiedTextRun(ClassificationTypeNames.MethodName, "MyMethod", navigationAction:=Sub() Return, "void MyClass.MyMethod()"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "("),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, ")"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "This contains a link to"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "string", navigationAction:=Sub() Return, "string"),
New ClassifiedTextRun(ClassificationTypeNames.Text, "."))))
ToolTipAssert.EqualContent(expected, intellisenseQuickInfo.Item)
End Function
End Class
End Namespace
|