提交 3cf56730 编写于 作者: B Brett Forsgren

Merge pull request #656 from brettfo/localized-resources

update Roslyn.Services.Editor.VisualBasic.UnitTests.dll unit tests to use localized resources
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Threading;
using System.Windows.Media;
using System.Windows.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Completion.Providers;
using Microsoft.CodeAnalysis.Editor.Options;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
......@@ -521,7 +517,7 @@ private string GetExpectedOverloadSubstring(int expectedSymbols)
throw new ArgumentOutOfRangeException("expectedSymbols");
}
return "+" + NonBreakingSpace + (expectedSymbols - 1) + NonBreakingSpace + "overload";
return "+" + NonBreakingSpace + (expectedSymbols - 1) + NonBreakingSpace + FeaturesResources.Overload;
}
protected void VerifyItemInLinkedFiles(string xmlString, string expectedItem, string expectedDescription)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Option Strict Off
Imports Microsoft.CodeAnalysis.CodeGeneration
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.IntroduceVariable
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.VisualStudio.Utilities
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.IntroduceVariable
Public Class IntroduceVariableTests
......@@ -74,8 +66,8 @@ index:=3)
TestExactActionSetOffered(
source,
expectedActionSet:={
"Introduce local for 'CType(2.ToString(), T)'",
"Introduce local for all occurrences of 'CType(2.ToString(), T)'"})
String.Format(FeaturesResources.IntroduceLocalFor, "CType(2.ToString(), T)"),
String.Format(FeaturesResources.IntroduceLocalForAllOccurrences, "CType(2.ToString(), T)")})
' Verifies "Introduce field ..." is missing
End Sub
......@@ -86,8 +78,8 @@ index:=3)
TestExactActionSetOffered(
source,
expectedActionSet:={
"Introduce local for 'x.ToString()'",
"Introduce local for all occurrences of 'x.ToString()'"})
String.Format(FeaturesResources.IntroduceLocalFor, "x.ToString()"),
String.Format(FeaturesResources.IntroduceLocalForAllOccurrences, "x.ToString()")})
' Verifies "Introduce field ..." is missing
End Sub
......@@ -207,7 +199,7 @@ End Module
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)>
Public Sub TestNoLocalFromExpressionInField()
Dim source = NewLines("Class Program \n Dim x = Foo([|2 + 2|]) \n End Class")
TestExactActionSetOffered(source, {"Introduce constant for '2 + 2'", "Introduce constant for all occurrences of '2 + 2'"})
TestExactActionSetOffered(source, {String.Format(FeaturesResources.IntroduceConstantFor, "2 + 2"), String.Format(FeaturesResources.IntroduceConstantForAllOccurrences, "2 + 2")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsIntroduceVariable)>
......@@ -985,8 +977,8 @@ End Class
</File>
TestExactActionSetOffered(code.NormalizedValue,
{"Introduce local constant for '5'",
"Introduce local constant for all occurrences of '5'"})
{String.Format(FeaturesResources.IntroduceLocalConstantFor, "5"),
String.Format(FeaturesResources.IntroduceLocalConstantForAll, "5")})
Test(code, expected, compareTokens:=False)
End Sub
......@@ -1008,8 +1000,8 @@ End Class
</Text>
TestExactActionSetOffered(code.NormalizedValue,
{"Introduce local constant for '5'",
"Introduce local constant for all occurrences of '5'"})
{String.Format(FeaturesResources.IntroduceLocalConstantFor, "5"),
String.Format(FeaturesResources.IntroduceLocalConstantForAll, "5")})
End Sub
<WorkItem(545258)>
......@@ -1043,8 +1035,8 @@ End Class
</File>
TestExactActionSetOffered(code.NormalizedValue,
{"Introduce local constant for '5'",
"Introduce local constant for all occurrences of '5'"})
{String.Format(FeaturesResources.IntroduceLocalConstantFor, "5"),
String.Format(FeaturesResources.IntroduceLocalConstantForAll, "5")})
Test(code, expected, compareTokens:=False)
End Sub
......
......@@ -1449,7 +1449,7 @@ Class SomeClass(Of T)
End Class
]]></Text>
VerifyItemExists(test.Value, "T", "T in SomeClass(Of T)")
VerifyItemExists(test.Value, "T", $"T {FeaturesResources.In} SomeClass(Of T)")
End Sub
<WorkItem(542225)>
......@@ -2754,10 +2754,10 @@ Class C
End Function
End Class</Code>.Value
Dim description = <File>&lt;Awaitable&gt; Function C.Foo() As Task
Dim description = <File>&lt;<%= VBFeaturesResources.Awaitable %>&gt; Function C.Foo() As Task
Doc Comment!
Usage:
Await Foo()</File>.ConvertTestSourceTag()
<%= VBFeaturesResources.Await %> Foo()</File>.ConvertTestSourceTag()
VerifyItemWithMscorlib45(code, "Foo", description, LanguageNames.VisualBasic)
End Sub
......@@ -5042,7 +5042,7 @@ end class]]>
</Project>
</Workspace>.ToString().NormalizeLineEndings()
VerifyItemInLinkedFiles(markup, "x", "(field) C.x As Integer")
VerifyItemInLinkedFiles(markup, "x", $"({FeaturesResources.Field}) C.x As Integer")
End Sub
<Fact(), Trait(Traits.Feature, Traits.Features.Completion)>
......@@ -5065,7 +5065,7 @@ Class C
</Project>
</Workspace>.ToString().NormalizeLineEndings()
Dim expectedDescription = "(field) C.x As Integer" + vbCrLf + vbCrLf + " Proj1 - Available" + vbCrLf + " Proj2 - Not Available" + vbCrLf + vbCrLf + "You can use the navigation bar to switch context."
Dim expectedDescription = $"({FeaturesResources.Field}) C.x As Integer" + vbCrLf + vbCrLf + String.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available) + vbCrLf + String.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable) + vbCrLf + vbCrLf + FeaturesResources.UseTheNavigationBarToSwitchContext
VerifyItemInLinkedFiles(markup, "x", expectedDescription)
End Sub
......
......@@ -838,7 +838,7 @@ Class C
End Class
</File>
TestExactActionSetOffered(code.ConvertTestSourceTag(), {"Change 'Function' to 'Sub'.", "Delete the 'Exit Function' statement."})
TestExactActionSetOffered(code.ConvertTestSourceTag(), {String.Format(VBFeaturesResources.ChangeTo, "Function", "Sub"), String.Format(VBFeaturesResources.DeleteTheStatement, "Exit Function")})
End Sub
<WorkItem(531354)>
......@@ -853,7 +853,7 @@ Class C
End Class
</File>
TestExactActionSetOffered(code.ConvertTestSourceTag(), {"Insert 'Sub'.", "Delete the 'Exit' statement."})
TestExactActionSetOffered(code.ConvertTestSourceTag(), {String.Format(VBFeaturesResources.Insert, "Sub"), String.Format(VBFeaturesResources.DeleteTheStatement, "Exit")})
End Sub
End Class
......
......@@ -461,7 +461,7 @@ Class Program
End Class
#End ExternalSource
</text>.NormalizedValue,
{"Generate class for 'Foo' in 'Global Namespace' (in new file)", "Generate class for 'Foo' in 'Program'", "Generate new type..."})
{String.Format(FeaturesResources.GenerateForInNewFile, "class", "Foo", FeaturesResources.GlobalNamespace), String.Format(FeaturesResources.GenerateForIn, "class", "Foo", "Program"), FeaturesResources.GenerateNewType})
End Sub
<WorkItem(545363)>
......@@ -480,7 +480,7 @@ Class Bar
End Class
#End ExternalSource
</text>.NormalizedValue,
{"Generate class for 'Foo' in 'Global Namespace' (in new file)", "Generate class for 'Foo' in 'Global Namespace'", "Generate class for 'Foo' in 'Program'", "Generate new type..."})
{String.Format(FeaturesResources.GenerateForInNewFile, "class", "Foo", FeaturesResources.GlobalNamespace), String.Format(FeaturesResources.GenerateForIn, "class", "Foo", FeaturesResources.GlobalNamespace), String.Format(FeaturesResources.GenerateForIn, "class", "Foo", "Program"), FeaturesResources.GenerateNewType})
End Sub
<WorkItem(545363)>
......
......@@ -179,7 +179,7 @@ NewLines("Class A \n Friend field As Integer \n End Class \n Class B \n Public S
Public Sub TestOnlyGenerateFieldInByRefProperty()
TestExactActionSetOffered(
NewLines("Class A \n End Class \n Class B \n Public Sub Foo(ByRef d As Integer) \n End Sub \n Public Sub Bar() \n Dim s As New A() \n Foo(s.[|field|]) \n End Sub \n End Class"),
{"Generate field 'field' in 'A'"})
{String.Format(FeaturesResources.GenerateFieldIn, "field", "A")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)>
......
......@@ -31,7 +31,7 @@ End Class</File>
Dim a = new [|Fooa|].ToString()
End Sub
End Class</File>
TestExactActionSetOffered(text.NormalizedValue, {"Change 'Fooa' to 'Foo'.", "Change 'Fooa' to 'Boolean'.", "Change 'Fooa' to 'Global'."})
TestExactActionSetOffered(text.NormalizedValue, {String.Format(VBFeaturesResources.ChangeTo, "Fooa", "Foo"), String.Format(VBFeaturesResources.ChangeTo, "Fooa", "Boolean"), String.Format(VBFeaturesResources.ChangeTo, "Fooa", "Global")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
......@@ -41,7 +41,7 @@ End Class</File>
Dim a as [|Foa|]
End Sub
End Class</File>
TestExactActionSetOffered(text.NormalizedValue, {"Change 'Foa' to 'Foo'.", "Change 'Foa' to 'Global'.", "Change 'Foa' to 'Char'."})
TestExactActionSetOffered(text.NormalizedValue, {String.Format(VBFeaturesResources.ChangeTo, "Foa", "Foo"), String.Format(VBFeaturesResources.ChangeTo, "Foa", "Global"), String.Format(VBFeaturesResources.ChangeTo, "Foa", "Char")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
......@@ -51,7 +51,7 @@ End Class</File>
Dim a as [|Foa|]
End Sub
End Class</File>
TestExactActionSetOffered(text.NormalizedValue, {"Change 'Foa' to 'Foo'.", "Change 'Foa' to 'Global'.", "Change 'Foa' to 'Char'."})
TestExactActionSetOffered(text.NormalizedValue, {String.Format(VBFeaturesResources.ChangeTo, "Foa", "Foo"), String.Format(VBFeaturesResources.ChangeTo, "Foa", "Global"), String.Format(VBFeaturesResources.ChangeTo, "Foa", "Char")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
......@@ -60,7 +60,7 @@ End Class</File>
Sub Bar(a as Func(Of [|Foa|]))
End Sub
End Class</File>
TestExactActionSetOffered(text.NormalizedValue, {"Change 'Foa' to 'Foo'.", "Change 'Foa' to 'Global'.", "Change 'Foa' to 'Char'."})
TestExactActionSetOffered(text.NormalizedValue, {String.Format(VBFeaturesResources.ChangeTo, "Foa", "Foo"), String.Format(VBFeaturesResources.ChangeTo, "Foa", "Global"), String.Format(VBFeaturesResources.ChangeTo, "Foa", "Char")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
......@@ -71,7 +71,7 @@ End Class</File>
Dim y = 2 + [|zza|]
End Sub
End Module</File>
TestExactActionSetOffered(text.NormalizedValue, {"Change 'zza' to 'zzz'.", "Change 'zza' to 'Char'.", "Change 'zza' to 'Await'."})
TestExactActionSetOffered(text.NormalizedValue, {String.Format(VBFeaturesResources.ChangeTo, "zza", "zzz"), String.Format(VBFeaturesResources.ChangeTo, "zza", "Char"), String.Format(VBFeaturesResources.ChangeTo, "zza", "Await")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
......@@ -84,7 +84,7 @@ Public Class Class1
End If
End Sub
End Class</File>
TestExactActionSetOffered(text.NormalizedValue, {"Change 'blah' to 'Boolean'.", "Change 'blah' to 'Lazy'.", "Change 'blah' to 'Math'."})
TestExactActionSetOffered(text.NormalizedValue, {String.Format(VBFeaturesResources.ChangeTo, "blah", "Boolean"), String.Format(VBFeaturesResources.ChangeTo, "blah", "Lazy"), String.Format(VBFeaturesResources.ChangeTo, "blah", "Math")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
......@@ -97,7 +97,7 @@ Public Class Class1
End If
End Sub
End Class</File>
TestExactActionSetOffered(text.NormalizedValue, {"Change 'blah' to 'Boolean'.", "Change 'blah' to 'Lazy'.", "Change 'blah' to 'Math'."})
TestExactActionSetOffered(text.NormalizedValue, {String.Format(VBFeaturesResources.ChangeTo, "blah", "Boolean"), String.Format(VBFeaturesResources.ChangeTo, "blah", "Lazy"), String.Format(VBFeaturesResources.ChangeTo, "blah", "Math")})
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSpellcheck)>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.VisualStudio.Text
Imports Roslyn.Test.EditorUtilities
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGeneration
Public Class MethodBlockTests
<Fact, Trait(Traits.Feature, Traits.Features.EndConstructGeneration)>
......@@ -56,10 +47,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera
"Class c1",
" Sub New()",
"",
" ' This call is required by the designer.",
$" ' {ThisCallIsRequiredByTheDesigner}",
" InitializeComponent()",
"",
" ' Add any initialization after the InitializeComponent() call.",
$" ' {AddAnyInitializationAfter}",
"",
" End Sub",
"",
......
......@@ -77,7 +77,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Alpha", "Class Beta", "Class Gamma", "Sub DoSomething()", "End Sub", "End Class", "End Class", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("DS").Single()
VerifyNavigateToResultItem(item, "DoSomething", MatchKind.Regular, NavigateToItemKind.Method, "DoSomething()", "type Alpha.Beta.Gamma")
VerifyNavigateToResultItem(item, "DoSomething", MatchKind.Regular, NavigateToItemKind.Method, "DoSomething()", $"{EditorFeaturesResources.Type}Alpha.Beta.Gamma")
End Using
End Sub
......@@ -95,7 +95,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo(Of M As IComparable)", "Public Sub Bar(Of T As IComparable)()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("Bar").Single()
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar(Of T)()", "type Foo(Of M)")
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar(Of T)()", $"{EditorFeaturesResources.Type}Foo(Of M)")
End Using
End Sub
......@@ -157,7 +157,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private Bar As Integer", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("Ba").Single()
VerifyNavigateToResultItem(item, "Bar", MatchKind.Prefix, NavigateToItemKind.Field, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "Bar", MatchKind.Prefix, NavigateToItemKind.Field, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -166,7 +166,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private Bar As Integer", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("ba").Single()
VerifyNavigateToResultItem(item, "Bar", MatchKind.Prefix, NavigateToItemKind.Field, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "Bar", MatchKind.Prefix, NavigateToItemKind.Field, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -183,10 +183,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private [string] As String", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("string").Single()
VerifyNavigateToResultItem(item, "string", MatchKind.Exact, NavigateToItemKind.Field, displayName:="[string]", additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "string", MatchKind.Exact, NavigateToItemKind.Field, displayName:="[string]", additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
item = _aggregator.GetItems("[string]").Single()
VerifyNavigateToResultItem(item, "string", MatchKind.Exact, NavigateToItemKind.Field, displayName:="[string]", additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "string", MatchKind.Exact, NavigateToItemKind.Field, displayName:="[string]", additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -195,7 +195,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private Const bar As String = ""bar""", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupConstant, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("bar").Single()
VerifyNavigateToResultItem(item, "bar", MatchKind.Exact, NavigateToItemKind.Constant, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "bar", MatchKind.Exact, NavigateToItemKind.Constant, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -208,7 +208,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
"End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("Item").Single()
VerifyNavigateToResultItem(item, "Item", MatchKind.Exact, NavigateToItemKind.Property, "Item(Integer)", "type Foo")
VerifyNavigateToResultItem(item, "Item", MatchKind.Exact, NavigateToItemKind.Property, "Item(Integer)", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -217,7 +217,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Public Event Bar as EventHandler", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupEvent, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("Bar").Single()
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Event, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Event, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -228,7 +228,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
"Set(value As String)", "End Set", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("Name").Single()
VerifyNavigateToResultItem(item, "Name", MatchKind.Exact, NavigateToItemKind.Property, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "Name", MatchKind.Exact, NavigateToItemKind.Property, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -237,7 +237,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Property Name As String", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("Name").Single()
VerifyNavigateToResultItem(item, "Name", MatchKind.Exact, NavigateToItemKind.Property, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "Name", MatchKind.Exact, NavigateToItemKind.Property, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -246,7 +246,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private Sub DoSomething()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("DS").Single()
VerifyNavigateToResultItem(item, "DoSomething", MatchKind.Regular, NavigateToItemKind.Method, "DoSomething()", "type Foo")
VerifyNavigateToResultItem(item, "DoSomething", MatchKind.Regular, NavigateToItemKind.Method, "DoSomething()", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -255,10 +255,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private Sub [Sub]()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("sub").Single()
VerifyNavigateToResultItem(item, "Sub", MatchKind.Exact, NavigateToItemKind.Method, "[Sub]()", "type Foo")
VerifyNavigateToResultItem(item, "Sub", MatchKind.Exact, NavigateToItemKind.Method, "[Sub]()", $"{EditorFeaturesResources.Type}Foo")
item = _aggregator.GetItems("[sub]").Single()
VerifyNavigateToResultItem(item, "Sub", MatchKind.Exact, NavigateToItemKind.Method, "[Sub]()", "type Foo")
VerifyNavigateToResultItem(item, "Sub", MatchKind.Exact, NavigateToItemKind.Method, "[Sub]()", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -267,7 +267,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private Sub DoSomething(ByVal i As Integer, s As String)", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("DS").Single()
VerifyNavigateToResultItem(item, "DoSomething", MatchKind.Regular, NavigateToItemKind.Method, "DoSomething(Integer, String)", "type Foo")
VerifyNavigateToResultItem(item, "DoSomething", MatchKind.Regular, NavigateToItemKind.Method, "DoSomething(Integer, String)", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -276,7 +276,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Sub New()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("Foo").Single(Function(i) i.Kind = NavigateToItemKind.Method)
VerifyNavigateToResultItem(item, "Foo", MatchKind.Exact, NavigateToItemKind.Method, "New()", "type Foo")
VerifyNavigateToResultItem(item, "Foo", MatchKind.Exact, NavigateToItemKind.Method, "New()", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -285,7 +285,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Shared Sub New()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("Foo").Single(Function(i) i.Kind = NavigateToItemKind.Method)
VerifyNavigateToResultItem(item, "Foo", MatchKind.Exact, NavigateToItemKind.Method, "Shared New()", "type Foo")
VerifyNavigateToResultItem(item, "Foo", MatchKind.Exact, NavigateToItemKind.Method, "Shared New()", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -296,11 +296,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
"Protected Overrides Sub Finalize()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemProtected)
Dim item As NavigateToItem = _aggregator.GetItems("Finalize").Single()
VerifyNavigateToResultItem(item, "Finalize", MatchKind.Exact, NavigateToItemKind.Method, "Finalize()", "type Foo")
VerifyNavigateToResultItem(item, "Finalize", MatchKind.Exact, NavigateToItemKind.Method, "Finalize()", $"{EditorFeaturesResources.Type}Foo")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic)
item = _aggregator.GetItems("Dispose").Single()
VerifyNavigateToResultItem(item, "Dispose", MatchKind.Exact, NavigateToItemKind.Method, "Dispose()", "type Foo")
VerifyNavigateToResultItem(item, "Dispose", MatchKind.Exact, NavigateToItemKind.Method, "Dispose()", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -328,7 +328,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Partial Class Foo", "Partial Private Sub Bar()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("Bar").Single()
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar()", "type Foo")
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar()", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -337,7 +337,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Partial Class Foo", "Private Sub Bar()", "End Sub", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("Bar").Single()
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar()", "type Foo")
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar()", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -474,7 +474,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Dim sqr As Func(Of Integer, Integer) = Function(x) x*x", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("sqr").Single()
VerifyNavigateToResultItem(item, "sqr", MatchKind.Exact, NavigateToItemKind.Field, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "sqr", MatchKind.Exact, NavigateToItemKind.Field, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -492,7 +492,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Public Sub Bar(x as Integer,", "y as Integer)", "End Sub")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic)
Dim item As NavigateToItem = _aggregator.GetItems("Bar").Single()
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar(Integer, Integer)", "type Foo")
VerifyNavigateToResultItem(item, "Bar", MatchKind.Exact, NavigateToItemKind.Method, "Bar(Integer, Integer)", $"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......@@ -501,7 +501,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.NavigateTo
Using worker = SetupWorkspace("Class Foo", "Private itemArray as object()", "End Class")
SetupVerifableGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPrivate)
Dim item As NavigateToItem = _aggregator.GetItems("itemArray").Single
VerifyNavigateToResultItem(item, "itemArray", MatchKind.Exact, NavigateToItemKind.Field, additionalInfo:="type Foo")
VerifyNavigateToResultItem(item, "itemArray", MatchKind.Exact, NavigateToItemKind.Field, additionalInfo:=$"{EditorFeaturesResources.Type}Foo")
End Using
End Sub
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Imports Xunit
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.EventHandling
Public Class AddHandlerKeywordRecommenderTests
<Fact>
<Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub AddHandlerHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>|</MethodBody>, "AddHandler",
<Text><![CDATA[
AddHandler statement
Associates an event with an event handler, delegate or lambda expression at run time.
AddHandler <event>, <handler>]]></Text>)
$"{VBFeaturesResources.AddhandlerStatement}
{AssociatesAnEvent}
AddHandler {Event1}, {Handler}")
End Sub
<Fact>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Imports Xunit
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.EventHandling
Public Class RemoveHandlerKeywordRecommenderTests
<Fact>
<Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub RemoveHandlerHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>|</MethodBody>, "RemoveHandler",
<Text><![CDATA[
RemoveHandler statement
Removes the association between an event and an event handler or delegate at run time.
RemoveHandler <event>, <handler>]]></Text>)
$"{VBFeaturesResources.RemovehandlerStatement}
{RemovesEventAssociation}
RemoveHandler {Event1}, {Handler}")
End Sub
<Fact>
......
......@@ -19,37 +19,33 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Ex
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub DirectCastHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>Return |</MethodBody>, "DirectCast",
<Text><![CDATA[
DirectCast function
Introduces a type conversion operation similar to CType. The difference is that CType succeeds as long as there is a valid conversion, whereas DirectCast requires that one type inherit from or implement the other type.
DirectCast(<expression>, <typeName>) As <result>]]></Text>)
$"{VBFeaturesResources.DirectcastFunction}
{IntroducesTypeConversion}
DirectCast({Expression1}, {VBWorkspaceResources.Typename}) As {Result}")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub TryCastHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>Return |</MethodBody>, "TryCast",
<Text><![CDATA[
TryCast function
Introduces a type conversion operation that does not throw an exception. If an attempted conversion fails, TryCast returns Nothing, which your program can test for.
TryCast(<expression>, <typeName>) As <result>]]></Text>)
$"{VBFeaturesResources.TrycastFunction}
{IntroducesSafeTypeConversion}
TryCast({Expression1}, {VBWorkspaceResources.Typename}) As {Result}")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub CTypeHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>Return |</MethodBody>, "CType",
<Text><![CDATA[
CType function
Returns the result of explicitly converting an expression to a specified data type.
CType(<expression>, <typeName>) As <result>]]></Text>)
$"{VBFeaturesResources.CtypeFunction}
{ReturnsConvertResult}
CType({Expression1}, {VBWorkspaceResources.Typename}) As {Result}")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub CBoolHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>Return |</MethodBody>, "CBool",
<Text><![CDATA[
CBool function
Converts an expression to the Boolean data type.
CBool(<expression>) As Boolean]]></Text>)
$"{String.Format(VBFeaturesResources.Function1, "CBool")}
{String.Format(ConvertsToDataType, "Boolean")}
CBool({Expression1}) As Boolean")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Text
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Expressions
Public Class GetTypeKeywordRecommenderTests
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub GetTypeHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>Return |</MethodBody>, "GetType",
<Text><![CDATA[
GetType function
Returns a System.Type object for the specified type name.
GetType(<typeName>) As Type]]></Text>)
$"{VBFeaturesResources.GettypeFunction}
{ReturnsSystemTypeObject}
GetType({VBWorkspaceResources.Typename}) As Type")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Text
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Expressions
Public Class GetXmlNamespaceKeywordRecommenderTests
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub GetXmlNamespaceHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>Return |</MethodBody>, "GetXmlNamespace",
<Text><![CDATA[
GetXmlNamespace function
Returns the System.Xml.Linq.XNamespace object corresponding to the specified XML namespace prefix.
GetXmlNamespace([<xmlNamespacePrefix>]) As System.Xml.Linq.XNamespace]]></Text>)
$"{VBFeaturesResources.GetxmlnamespaceFunction}
{ReturnsXNamespaceObject}
GetXmlNamespace([{XmlNamespacePrefix}]) As System.Xml.Linq.XNamespace")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Text
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Expressions
Public Class IfKeywordRecommenderTests
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub IfHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>Return |</MethodBody>, "If",
<Text><![CDATA[
If function (+1 overload)
If <condition> returns True, the function calculates and returns <expressionIfTrue>. Otherwise, it returns <expressionIfFalse>.
If(<condition> As Boolean, <expressionIfTrue>, <expressionIfFalse>) As <result>
]]></Text>)
$"{String.Format(VBFeaturesResources.Function1, "If")} (+1 {FeaturesResources.Overload})
{IfConditionReturnsResults}
If({Condition} As Boolean, {ExpressionIfTrue}, {ExpressionIfFalse}) As {Result}")
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
......
......@@ -42,10 +42,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations
Assert.Equal(recommendations.OrderBy(Function(recommendation) recommendation).ToArray(), recommendedKeywords)
End Sub
Friend Sub VerifyRecommendationDescriptionTextIs(testSource As XElement, keyword As String, text As XElement)
Friend Sub VerifyRecommendationDescriptionTextIs(testSource As XElement, keyword As String, text As String)
Dim source = ConvertTestSourceTag(testSource)
Dim recommendedKeyword = GetRecommendedKeywords(source.Replace("|", ""), source.IndexOf("|")).Single(Function(r) r.Keyword = keyword)
Dim expectedText = text.Value.Replace(vbLf, vbCrLf).Trim()
Dim expectedText = text.Trim()
Assert.Equal(expectedText, recommendedKeyword.DescriptionFactory(CancellationToken.None).GetFullText())
End Sub
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Text
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Statements
Public Class MidKeywordRecommenderTests
<Fact>
<Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Sub MidHelpText()
VerifyRecommendationDescriptionTextIs(<MethodBody>|</MethodBody>, "Mid",
<Text><![CDATA[
Mid statement
Replaces a specified number of characters in a String variable with characters from another string.
Mid(<stringName>, <startIndex>, [<length>]) = <stringExpression>]]></Text>)
$"{VBFeaturesResources.MidStatement}
{ReplacesChars}
Mid({StringName}, {StartIndex}, [{Length}]) = {StringExpression}")
End Sub
<Fact>
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -24,9 +23,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"AddHandler <event>, <handler>",
"Associates an event with an event handler, delegate or lambda expression at run time.",
"The event to associate an event handler, delegate or lambda expression with.",
$"AddHandler {Event1}, {Handler}",
AssociatesAnEvent,
EventToAssociate,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
......@@ -44,9 +43,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"AddHandler <event>, <handler>",
"Associates an event with an event handler, delegate or lambda expression at run time.",
"The event handler to associate with the event. This may take the form of { AddressOf <eventHandler> | <delegate> | <lambdaExpression> }.",
$"AddHandler {Event1}, {Handler}",
AssociatesAnEvent,
EventHandlerToAssociate,
currentParameterIndex:=1))
Test(markup, expectedOrderedItems)
......@@ -66,9 +65,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"RemoveHandler <event>, <handler>",
"Removes the association between an event and an event handler or delegate at run time.",
"The event to disassociate an event handler or delegate from.",
$"RemoveHandler {Event1}, {Handler}",
RemovesEventAssociation,
EventToDisassociate,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
......@@ -86,9 +85,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"RemoveHandler <event>, <handler>",
"Removes the association between an event and an event handler or delegate at run time.",
"The event handler to disassociate from the event. This may take the form of { AddressOf <eventHandler> | <delegate> }.",
$"RemoveHandler {Event1}, {Handler}",
RemovesEventAssociation,
EventHandlerToDisassociate,
currentParameterIndex:=1))
Test(markup, expectedOrderedItems)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -24,9 +23,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"CType(<expression>, <typeName>) As <result>",
"Returns the result of explicitly converting an expression to a specified data type.",
"The expression to be evaluated and converted.",
$"CType({Expression1}, {VBWorkspaceResources.Typename}) As {Result}",
ReturnsConvertResult,
ExpressionToConvert,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
......@@ -44,9 +43,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"CType(<expression>, <typeName>) As <result>",
"Returns the result of explicitly converting an expression to a specified data type.",
"The name of the data type to which the value of expression will be converted.",
$"CType({Expression1}, {VBWorkspaceResources.Typename}) As {Result}",
ReturnsConvertResult,
NameOfTypeToConvert,
currentParameterIndex:=1))
Test(markup, expectedOrderedItems)
......@@ -65,9 +64,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"DirectCast(<expression>, <typeName>) As <result>",
"Introduces a type conversion operation similar to CType. The difference is that CType succeeds as long as there is a valid conversion, whereas DirectCast requires that one type inherit from or implement the other type.",
"The expression to be evaluated and converted.",
$"DirectCast({Expression1}, {VBWorkspaceResources.Typename}) As {Result}",
IntroducesTypeConversion,
ExpressionToConvert,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
......@@ -86,9 +85,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"TryCast(<expression>, <typeName>) As <result>",
"Introduces a type conversion operation that does not throw an exception. If an attempted conversion fails, TryCast returns Nothing, which your program can test for.",
"The expression to be evaluated and converted.",
$"TryCast({Expression1}, {VBWorkspaceResources.Typename}) As {Result}",
IntroducesSafeTypeConversion,
ExpressionToConvert,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -24,14 +23,14 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"If(<expression>, <expressionIfNothing>) As <result>",
"If <expression> evaluates to a reference or Nullable value that is not Nothing, the function returns that value. Otherwise, it calculates and returns <expressionIfNothing>.",
"Returned if it evaluates to a reference or nullable type that is not Nothing.",
$"If({Expression1}, {ExpressionIfNothing}) As {Result}",
ExpressionEvalReturns,
ReturnedIfINotNothing,
currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem(
"If(<condition> As Boolean, <expressionIfTrue>, <expressionIfFalse>) As <result>",
"If <condition> returns True, the function calculates and returns <expressionIfTrue>. Otherwise, it returns <expressionIfFalse>.",
"The expression to evaluate.",
$"If({Condition} As Boolean, {ExpressionIfTrue}, {ExpressionIfFalse}) As {Result}",
IfConditionReturnsResults,
ExpressionToEvaluate,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
End Sub
......@@ -48,14 +47,14 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"If(<expression>, <expressionIfNothing>) As <result>",
"If <expression> evaluates to a reference or Nullable value that is not Nothing, the function returns that value. Otherwise, it calculates and returns <expressionIfNothing>.",
"Evaluated and returned if <expression> evaluates to Nothing.",
$"If({Expression1}, {ExpressionIfNothing}) As {Result}",
ExpressionEvalReturns,
ReturnedIfNothing,
currentParameterIndex:=1))
expectedOrderedItems.Add(New SignatureHelpTestItem(
"If(<condition> As Boolean, <expressionIfTrue>, <expressionIfFalse>) As <result>",
"If <condition> returns True, the function calculates and returns <expressionIfTrue>. Otherwise, it returns <expressionIfFalse>.",
"Evaluated and returned if <condition> evaluates to True.",
$"If({Condition} As Boolean, {ExpressionIfTrue}, {ExpressionIfFalse}) As {Result}",
IfConditionReturnsResults,
EvaluatedAndReturnedIfTrue,
currentParameterIndex:=1))
Test(markup, expectedOrderedItems)
End Sub
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -26,8 +25,8 @@ End Module
]]></Text>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem("<Extension> Count() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem("<Extension> Count(<expression> As Boolean) As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem($"<{Extension}> Count() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem($"<{Extension}> Count({Expression1} As Boolean) As Integer", String.Empty, Nothing, currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
End Sub
......@@ -62,7 +61,7 @@ Public Module Foo
End Module
]]></Text>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem("<Extension> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem($"<{Extension}> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
TestSignatureHelpInEditorBrowsableContexts(markup:=markup,
referencedCode:=referencedCode,
......@@ -101,7 +100,7 @@ Public Module Foo
End Module
]]></Text>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem("<Extension> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem($"<{Extension}> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
TestSignatureHelpInEditorBrowsableContexts(markup:=markup,
referencedCode:=referencedCode,
......@@ -140,7 +139,7 @@ Public Module Foo
End Module
]]></Text>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem("<Extension> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem($"<{Extension}> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
TestSignatureHelpInEditorBrowsableContexts(markup:=markup,
referencedCode:=referencedCode,
......@@ -194,11 +193,11 @@ Public Module Foo
End Module
]]></Text>.Value
Dim expectedOrderedItemsMetadataOnly = New List(Of SignatureHelpTestItem)()
expectedOrderedItemsMetadataOnly.Add(New SignatureHelpTestItem("<Extension> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItemsMetadataOnly.Add(New SignatureHelpTestItem($"<{Extension}> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
Dim expectedOrderedItemsSameSolution = New List(Of SignatureHelpTestItem)()
expectedOrderedItemsSameSolution.Add(New SignatureHelpTestItem("<Extension> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItemsSameSolution.Add(New SignatureHelpTestItem("<Extension> GetRandomNumber(<expression> As Double) As Integer", String.Empty, String.Empty, currentParameterIndex:=0))
expectedOrderedItemsSameSolution.Add(New SignatureHelpTestItem($"<{Extension}> GetRandomNumber() As Integer", String.Empty, Nothing, currentParameterIndex:=0))
expectedOrderedItemsSameSolution.Add(New SignatureHelpTestItem($"<{Extension}> GetRandomNumber({Expression1} As Double) As Integer", String.Empty, String.Empty, currentParameterIndex:=0))
TestSignatureHelpInEditorBrowsableContexts(markup:=markup,
referencedCode:=referencedCode,
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -569,7 +568,7 @@ End Class
]]></a>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem("<Extension> D.Foo(Of S, T)(objS As S, objT As T) As S", String.Empty, String.Empty, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem($"<{Extension}> D.Foo(Of S, T)(objS As S, objT As T) As S", String.Empty, String.Empty, currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
End Sub
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -24,9 +23,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"GetType(<typeName>) As System.Type",
"Returns a System.Type object for the specified type name.",
"The type name to return a System.Type object for.",
$"GetType({VBWorkspaceResources.Typename}) As System.Type",
ReturnsSystemTypeObject,
TypeToReturnObjectFor,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
End Sub
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -24,9 +23,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"GetXmlNamespace([<xmlNamespacePrefix>]) As System.Xml.Linq.XNamespace",
"Returns the System.Xml.Linq.XNamespace object corresponding to the specified XML namespace prefix.",
"The XML namespace prefix to return a System.Xml.Linq.XNamespace object for. If this is omitted, the object for the default XML namespace is returned.",
$"GetXmlNamespace([{XmlNamespacePrefix}]) As System.Xml.Linq.XNamespace",
ReturnsXNamespaceObject,
XMLNSToReturnObjectFor,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
End Sub
......
......@@ -2,7 +2,6 @@
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
Imports Microsoft.VisualStudio.Composition
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SignatureHelp
Public Class InvocationExpressionSignatureHelpProviderTests
......@@ -551,7 +550,7 @@ End Module
]]></a>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem("<Extension> MyExtension.ExtensionMethod(x As Integer) As Integer", String.Empty, String.Empty, currentParameterIndex:=0))
expectedOrderedItems.Add(New SignatureHelpTestItem($"<{Extension}> MyExtension.ExtensionMethod(x As Integer) As Integer", String.Empty, String.Empty, currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
End Sub
......@@ -595,7 +594,7 @@ End Module
]]></a>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)() From {
New SignatureHelpTestItem("<Extension> SomeModule.ExtensionMethod()", String.Empty, Nothing, currentParameterIndex:=0)
New SignatureHelpTestItem($"<{Extension}> SomeModule.ExtensionMethod()", String.Empty, Nothing, currentParameterIndex:=0)
}
Test(markup, expectedOrderedItems)
......@@ -618,17 +617,17 @@ End Module]]></a>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
<d>List(Of 'a).Add(item As 'a)
$"List(Of 'a).Add(item As 'a)
Anonymous Types:
'a is New With { .A As Integer, .B As Integer }</d>.Value.Replace(vbLf, vbCrLf),
{FeaturesResources.AnonymousTypes}
'a {FeaturesResources.Is} New With {{ .A As Integer, .B As Integer }}",
String.Empty,
String.Empty,
currentParameterIndex:=0,
description:=<d>
description:=$"
Anonymous Types:
'a is New With { .A As Integer, .B As Integer }</d>.Value.Replace(vbLf, vbCrLf)))
{FeaturesResources.AnonymousTypes}
'a {FeaturesResources.Is} New With {{ .A As Integer, .B As Integer }}"))
Test(markup, expectedOrderedItems)
End Sub
......@@ -1707,7 +1706,7 @@ end class
<Document IsLinkFile="true" LinkAssemblyName="Proj1" LinkFilePath="SourceDocument"/>
</Project>
</Workspace>]]></text>.Value.NormalizeLineEndings()
Dim expectedDescription = New SignatureHelpTestItem("C.bar()" + vbCrLf + vbCrLf + " Proj1 - Available" + vbCrLf + " Proj2 - Not Available" + vbCrLf + vbCrLf + "You can use the navigation bar to switch context.", currentParameterIndex:=0)
Dim expectedDescription = New SignatureHelpTestItem("C.bar()" + vbCrLf + vbCrLf + String.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available) + vbCrLf + String.Format(FeaturesResources.ProjectAvailability, "Proj2", FeaturesResources.NotAvailable) + vbCrLf + vbCrLf + FeaturesResources.UseTheNavigationBarToSwitchContext, currentParameterIndex:=0)
VerifyItemWithReferenceWorker(markup, {expectedDescription}, False)
End Sub
......@@ -1737,7 +1736,7 @@ class C
</Project>
</Workspace>]]></text>.Value.NormalizeLineEndings()
Dim expectedDescription = New SignatureHelpTestItem("C.bar()" + "\r\n\r\n Proj1 - Available\r\n Proj3 - Not Available\r\n\r\nYou can use the navigation bar to switch context.".Replace("\r\n", vbCrLf), currentParameterIndex:=0)
Dim expectedDescription = New SignatureHelpTestItem("C.bar()" + $"\r\n\r\n{String.Format(FeaturesResources.ProjectAvailability, "Proj1", FeaturesResources.Available)}\r\n{String.Format(FeaturesResources.ProjectAvailability, "Proj3", FeaturesResources.NotAvailable)}\r\n\r\n{FeaturesResources.UseTheNavigationBarToSwitchContext}".Replace("\r\n", vbCrLf), currentParameterIndex:=0)
VerifyItemWithReferenceWorker(markup, {expectedDescription}, False)
End Sub
End Class
......
......@@ -2,7 +2,6 @@
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
Imports Microsoft.VisualStudio.Composition
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SignatureHelp
Public Class MidAssignmentSignatureHelpProviderTests
......@@ -24,9 +23,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"Mid(<stringName>, <startIndex>, [<length>]) = <stringExpression>",
"Replaces a specified number of characters in a String variable with characters from another string.",
"The name of the string variable to modify.",
$"Mid({StringName}, {StartIndex}, [{Length}]) = {StringExpression}",
ReplacesChars,
NameOfStringVariable,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
Test(markup, expectedOrderedItems, usePreviousCharAsTrigger:=True)
......@@ -44,9 +43,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"Mid(<stringName>, <startIndex>, [<length>]) = <stringExpression>",
"Replaces a specified number of characters in a String variable with characters from another string.",
"The one-based character position in the string where the replacement of text begins.",
$"Mid({StringName}, {StartIndex}, [{Length}]) = {StringExpression}",
ReplacesChars,
OneBasedStartPos,
currentParameterIndex:=1))
Test(markup, expectedOrderedItems)
Test(markup, expectedOrderedItems, usePreviousCharAsTrigger:=True)
......@@ -64,9 +63,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"Mid(<stringName>, <startIndex>, [<length>]) = <stringExpression>",
"Replaces a specified number of characters in a String variable with characters from another string.",
"The number of characters to replace. If omitted, the length of <stringExpression> is used.",
$"Mid({StringName}, {StartIndex}, [{Length}]) = {StringExpression}",
ReplacesChars,
NumberOfCharsToReplace,
currentParameterIndex:=2))
Test(markup, expectedOrderedItems)
Test(markup, expectedOrderedItems, usePreviousCharAsTrigger:=True)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.ComponentModel.Composition.Hosting
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
......@@ -24,9 +23,9 @@ End Class
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
"CBool(<expression>) As Boolean",
"Converts an expression to the Boolean data type.",
"The expression to be evaluated and converted.",
$"CBool({Expression1}) As Boolean",
String.Format(ConvertsToDataType, "Boolean"),
ExpressionToConvert,
currentParameterIndex:=0))
Test(markup, expectedOrderedItems)
End Sub
......
......@@ -2,9 +2,6 @@
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators
......@@ -62,7 +59,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators
Return suffixParts
End If
suffixParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.Text, Nothing, "<result>"))
suffixParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.Text, Nothing, Result))
End If
Return suffixParts
......
......@@ -358,6 +358,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
'''<summary>
''' Looks up a localized string similar to &lt;result&gt;.
'''</summary>
Friend ReadOnly Property Result() As String
Get
Return ResourceManager.GetString("Result", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Returned if it evaluates to a reference or nullable type that is not Nothing..
'''</summary>
......
......@@ -261,4 +261,7 @@
<data name="NameOfDocumentation" xml:space="preserve">
<value>Produces a string for the name of the specified type or member.</value>
</data>
<data name="Result" xml:space="preserve">
<value>&lt;result&gt;</value>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册