|
' 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.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_Inheritdoc
Inherits AbstractIntellisenseQuickInfoBuilderTests
<WpfFact>
Public Async Function NoImplicitInheritedQuickInfoForType() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
/// <summary>
/// This is the base class.
/// </summary>
class BaseClass
{
}
class My$$Class : BaseClass {
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Assert.NotNull(intellisenseQuickInfo)
Dim container = Assert.IsType(Of ContainerElement)(intellisenseQuickInfo.Item)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.ClassInternal)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "class"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"))))
ToolTipAssert.EqualContent(expected, container)
End Function
<WpfFact>
Public Async Function ExplicitInheritedQuickInfoForType() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
/// <summary>
/// This is the base class.
/// </summary>
class BaseClass
{
}
/// <inheritdoc cref="BaseClass"/>
class My$$Class {
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Assert.NotNull(intellisenseQuickInfo)
Dim container = Assert.IsType(Of ContainerElement)(intellisenseQuickInfo.Item)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.ClassInternal)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "class"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "This is the base class."))))
ToolTipAssert.EqualContent(expected, container)
End Function
<WpfFact>
Public Async Function ExplicitInheritedQuickInfoForSummary1() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
/// <summary>
/// This is the base class.
/// </summary>
class BaseClass
{
}
/// <summary>
/// <inheritdoc cref="BaseClass"/>
/// </summary>
class My$$Class {
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Assert.NotNull(intellisenseQuickInfo)
Dim container = Assert.IsType(Of ContainerElement)(intellisenseQuickInfo.Item)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.ClassInternal)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "class"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "This is the base class."))))
ToolTipAssert.EqualContent(expected, container)
End Function
<WpfFact>
Public Async Function ExplicitInheritedQuickInfoForSummary2() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
/// <summary>
/// This is the base class.
/// </summary>
class BaseClass
{
}
/// <summary>
/// This is not the base class.
/// </summary>
class NotBaseClass
{
}
/// <summary>
/// <inheritdoc cref="BaseClass"/>
/// <inheritdoc cref="NotBaseClass"/>
/// </summary>
class My$$Class {
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Assert.NotNull(intellisenseQuickInfo)
Dim container = Assert.IsType(Of ContainerElement)(intellisenseQuickInfo.Item)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.ClassInternal)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "class"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "This is the base class. This is not the base class."))))
ToolTipAssert.EqualContent(expected, container)
End Function
<WpfFact>
Public Async Function ExplicitInheritedQuickInfoForSummary3() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
/// <summary>
/// <code>
/// Dim test = 0
/// </code>
/// </summary>
class BaseClass
{
}
/// <inheritdoc cref="BaseClass"/>
class My$$Class {
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Assert.NotNull(intellisenseQuickInfo)
Dim container = Assert.IsType(Of ContainerElement)(intellisenseQuickInfo.Item)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.ClassInternal)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "class"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ClassName, "MyClass", navigationAction:=Sub() Return, "MyClass"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "Dim test = 0", ClassifiedTextRunStyle.UseClassificationFont))))
ToolTipAssert.EqualContent(expected, container)
End Function
<WpfFact>
Public Async Function InheritedQuickInfoForParameterButNotSummary1() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
abstract class BaseClass
{
/// <summary>
/// Base summary.
/// </summary>
/// <param name="x">A parameter.</param>
protected abstract void Method(int x);
}
/// <inheritdoc cref="BaseClass"/>
class MyClass : BaseClass {
/// <summary>
/// Override summary.
/// </summary>
/// <inheritdoc/>
protected override void Met$$hod(int x) { }
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Assert.NotNull(intellisenseQuickInfo)
Dim container = Assert.IsType(Of ContainerElement)(intellisenseQuickInfo.Item)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.MethodProtected)),
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, "Method", navigationAction:=Sub() Return, "void MyClass.Method(int x)"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "("),
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "int", navigationAction:=Sub() Return, "int"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ParameterName, "x", navigationAction:=Sub() Return, "int x"),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, ")"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "Override summary."))))
ToolTipAssert.EqualContent(expected, container)
End Function
<WpfFact>
Public Async Function InheritedQuickInfoForParameterButNotSummary2() As Task
Dim workspace =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
using System.Threading;
abstract class BaseClass
{
/// <summary>
/// Base summary.
/// </summary>
/// <param name="x">A parameter.</param>
protected abstract void Method(int x);
}
/// <inheritdoc cref="BaseClass"/>
class MyClass : BaseClass {
/// <summary>
/// Override summary.
/// </summary>
/// <inheritdoc/>
protected override void Method(int $$x) { }
}
</Document>
</Project>
</Workspace>
Dim intellisenseQuickInfo = Await GetQuickInfoItemAsync(workspace, LanguageNames.CSharp)
Assert.NotNull(intellisenseQuickInfo)
Dim container = Assert.IsType(Of ContainerElement)(intellisenseQuickInfo.Item)
Dim expected = New ContainerElement(
ContainerElementStyle.Stacked Or ContainerElementStyle.VerticalPadding,
New ContainerElement(
ContainerElementStyle.Stacked,
New ContainerElement(
ContainerElementStyle.Wrapped,
New ImageElement(New ImageId(KnownImageIds.ImageCatalogGuid, KnownImageIds.LocalVariable)),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, "("),
New ClassifiedTextRun(ClassificationTypeNames.Text, FeaturesResources.parameter),
New ClassifiedTextRun(ClassificationTypeNames.Punctuation, ")"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.Keyword, "int", navigationAction:=Sub() Return, "int"),
New ClassifiedTextRun(ClassificationTypeNames.WhiteSpace, " "),
New ClassifiedTextRun(ClassificationTypeNames.ParameterName, "x", navigationAction:=Sub() Return, "int x"))),
New ClassifiedTextElement(
New ClassifiedTextRun(ClassificationTypeNames.Text, "A parameter."))))
ToolTipAssert.EqualContent(expected, container)
End Function
End Class
End Namespace
|