diff --git a/src/EditorFeatures/CSharpTest/SignatureHelp/AttributeSignatureHelpProviderTests.cs b/src/EditorFeatures/CSharpTest/SignatureHelp/AttributeSignatureHelpProviderTests.cs index 6b8ccee8cad0e..916e5470af372 100644 --- a/src/EditorFeatures/CSharpTest/SignatureHelp/AttributeSignatureHelpProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/SignatureHelp/AttributeSignatureHelpProviderTests.cs @@ -26,6 +26,11 @@ internal override Type GetSignatureHelpProviderType() [Fact] public async Task TestInvocationWithoutParameters() { + var expectedOrderedItems = new List + { + new("SomethingAttribute()", string.Empty, null, currentParameterIndex: 0) + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -35,13 +40,17 @@ class SomethingAttribute : System.Attribute class D { } - """, - [new("SomethingAttribute()", string.Empty, null, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithoutParametersMethodXmlComments() { + var expectedOrderedItems = new List + { + new("SomethingAttribute()", "Summary For Attribute", null, currentParameterIndex: 0) + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -53,13 +62,18 @@ public SomethingAttribute() { } class D { } - """, - [new("SomethingAttribute()", "Summary For Attribute", null, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/25830")] public async Task PickCorrectOverload_PickInt() { + var expectedOrderedItems = new List + { + new("SomethingAttribute(int i)", currentParameterIndex: 0, isSelected: true), + new("SomethingAttribute(string i)", currentParameterIndex: 0), + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -69,14 +83,18 @@ class SomethingAttribute : System.Attribute } [[|Something(i: 1$$|])] class D { } - """, [ - new("SomethingAttribute(int i)", currentParameterIndex: 0, isSelected: true), - new("SomethingAttribute(string i)", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/25830")] public async Task PickCorrectOverload_PickString() { + var expectedOrderedItems = new List + { + new("SomethingAttribute(int i)", currentParameterIndex: 0), + new("SomethingAttribute(string i)", currentParameterIndex: 0, isSelected: true), + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -86,14 +104,17 @@ class SomethingAttribute : System.Attribute } [[|Something(i: null$$|])] class D { } - """, [ - new("SomethingAttribute(int i)", currentParameterIndex: 0), - new("SomethingAttribute(string i)", currentParameterIndex: 0, isSelected: true)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersOn1() { + var expectedOrderedItems = new List + { + new("SomethingAttribute(int someInteger, string someString)", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -104,13 +125,17 @@ public SomethingAttribute(int someInteger, string someString) { } class D { } - """, - [new("SomethingAttribute(int someInteger, string someString)", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersXmlCommentsOn1() { + var expectedOrderedItems = new List + { + new("SomethingAttribute(int someInteger, string someString)", "Summary For Attribute", "Param someInteger", currentParameterIndex: 0) + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -126,13 +151,17 @@ public SomethingAttribute(int someInteger, string someString) { } |]class D { } - """, - [new("SomethingAttribute(int someInteger, string someString)", "Summary For Attribute", "Param someInteger", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersOn2() { + var expectedOrderedItems = new List + { + new("SomethingAttribute(int someInteger, string someString)", string.Empty, string.Empty, currentParameterIndex: 1) + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -143,13 +172,17 @@ public SomethingAttribute(int someInteger, string someString) { } class D { } - """, - [new("SomethingAttribute(int someInteger, string someString)", string.Empty, string.Empty, currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersXmlComentsOn2() { + var expectedOrderedItems = new List + { + new("SomethingAttribute(int someInteger, string someString)", "Summary For Attribute", "Param someString", currentParameterIndex: 1) + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -165,13 +198,17 @@ public SomethingAttribute(int someInteger, string someString) { } |]class D { } - """, - [new("SomethingAttribute(int someInteger, string someString)", "Summary For Attribute", "Param someString", currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithClosingParen() { + var expectedOrderedItems = new List + { + new("SomethingAttribute()", string.Empty, null, currentParameterIndex: 0) + }; + await TestAsync(""" class SomethingAttribute : System.Attribute { } @@ -180,8 +217,7 @@ class SomethingAttribute : System.Attribute class D { } - """, - [new("SomethingAttribute()", string.Empty, null, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] @@ -961,6 +997,7 @@ public Task InvokedWithNoToken() [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1081535")] public async Task TestInvocationWithBadParameterList() { + var expectedOrderedItems = new List(); await TestAsync(""" class SomethingAttribute : System.Attribute { @@ -970,6 +1007,6 @@ class SomethingAttribute : System.Attribute class D { } - """, []); + """, expectedOrderedItems); } } diff --git a/src/EditorFeatures/CSharpTest/SignatureHelp/ConstructorInitializerSignatureHelpProviderTests.cs b/src/EditorFeatures/CSharpTest/SignatureHelp/ConstructorInitializerSignatureHelpProviderTests.cs index 9a458567c7dae..ccb177b567b21 100644 --- a/src/EditorFeatures/CSharpTest/SignatureHelp/ConstructorInitializerSignatureHelpProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/SignatureHelp/ConstructorInitializerSignatureHelpProviderTests.cs @@ -26,6 +26,11 @@ internal override Type GetSignatureHelpProviderType() [Fact] public async Task TestInvocationWithoutParameters() { + var expectedOrderedItems = new List + { + new("BaseClass()", string.Empty, null, currentParameterIndex: 0) + }; + await TestAsync(""" class BaseClass { @@ -37,13 +42,17 @@ class Derived : BaseClass public Derived() [|: base($$|]) { } } - """, - [new("BaseClass()", string.Empty, null, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithoutParametersMethodXmlComments() { + var expectedOrderedItems = new List + { + new("BaseClass()", "Summary for BaseClass", null, currentParameterIndex: 0) + }; + await TestAsync(""" class BaseClass { @@ -56,13 +65,17 @@ class Derived : BaseClass public Derived() [|: base($$|]) { } } - """, - [new("BaseClass()", "Summary for BaseClass", null, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersOn1() { + var expectedOrderedItems = new List + { + new("BaseClass(int a, int b)", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class BaseClass { @@ -74,13 +87,17 @@ class Derived : BaseClass public Derived() [|: base($$2, 3|]) { } } - """, - [new("BaseClass(int a, int b)", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersXmlCommentsOn1() { + var expectedOrderedItems = new List + { + new("BaseClass(int a, int b)", "Summary for BaseClass", "Param a", currentParameterIndex: 0) + }; + await TestAsync(""" class BaseClass { @@ -95,13 +112,17 @@ class Derived : BaseClass public Derived() [|: base($$2, 3|]) { } } - """, - [new("BaseClass(int a, int b)", "Summary for BaseClass", "Param a", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersOn2() { + var expectedOrderedItems = new List + { + new("BaseClass(int a, int b)", "Summary for BaseClass", "Param b", currentParameterIndex: 1) + }; + await TestAsync(""" class BaseClass { @@ -117,13 +138,17 @@ class Derived : BaseClass public Derived() [|: base(2, $$3|]) { } } - """, - [new("BaseClass(int a, int b)", "Summary for BaseClass", "Param b", currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact] public async Task TestInvocationWithParametersXmlComentsOn2() { + var expectedOrderedItems = new List + { + new("BaseClass(int a, int b)", "Summary for BaseClass", "Param b", currentParameterIndex: 1) + }; + await TestAsync(""" class BaseClass { @@ -138,65 +163,86 @@ class Derived : BaseClass public Derived() [|: base(2, $$3|]) { } } - """, - [new("BaseClass(int a, int b)", "Summary for BaseClass", "Param b", currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/2579")] public async Task TestThisInvocation() { + var expectedOrderedItems = new List + { + new("Goo(int a, int b)", string.Empty, string.Empty, currentParameterIndex: 1) + }; + await TestAsync(""" class Goo { public Goo(int a, int b) { } public Goo() [|: this(2, $$3|]) { } } - """, - [new("Goo(int a, int b)", string.Empty, string.Empty, currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/2579")] public async Task TestThisInvocationWithNonEmptyArgumentList() { + var expectedOrderedItems = new List + { + new("Foo()", string.Empty, null, currentParameterIndex: 0), + }; + await TestAsync(""" class Foo { public Foo(int a, int b) [|: this($$|]) { } public Foo() { } } - """, - [new("Foo()", string.Empty, null, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/2579")] public async Task TestInvocationWithoutClosingParen() { + var expectedOrderedItems = new List + { + new("Goo(int a, int b)", string.Empty, string.Empty, currentParameterIndex: 1) + }; + await TestAsync(""" class Goo { public Goo(int a, int b) { } public Goo() [|: this(2, $$ |]} - """, - [new("Goo(int a, int b)", string.Empty, string.Empty, currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/2579")] public async Task TestThisInvocationWithoutClosingParenWithNonEmptyArgumentList() { + var expectedOrderedItems = new List + { + new("Foo()", string.Empty, null, currentParameterIndex: 0), + }; + await TestAsync(""" class Foo { public Foo() { } public Foo(int a, int b) [|: this($$ |]} - """, - [new("Foo()", string.Empty, null, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/25830")] public async Task PickCorrectOverload_PickInt() { + var expectedOrderedItems = new List + { + new("D(int i)", currentParameterIndex: 0, isSelected: true), + new("D(string i)", currentParameterIndex: 0), + }; + await TestAsync(""" class D { @@ -206,14 +252,18 @@ class D D(string i) => throw null; D(int i) => throw null; } - """, [ - new("D(int i)", currentParameterIndex: 0, isSelected: true), - new("D(string i)", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/25830")] public async Task PickCorrectOverload_PickString() { + var expectedOrderedItems = new List + { + new("D(int i)", currentParameterIndex: 0), + new("D(string i)", currentParameterIndex: 0, isSelected: true), + }; + await TestAsync(""" class D { @@ -223,9 +273,7 @@ class D D(string i) => throw null; D(int i) => throw null; } - """, [ - new("D(int i)", currentParameterIndex: 0), - new("D(string i)", currentParameterIndex: 0, isSelected: true)]); + """, expectedOrderedItems); } #endregion diff --git a/src/EditorFeatures/CSharpTest/SignatureHelp/GenericNameFullyWrittenSignatureHelpProviderTests.cs b/src/EditorFeatures/CSharpTest/SignatureHelp/GenericNameFullyWrittenSignatureHelpProviderTests.cs index dbef426582d89..3f48441f2e27d 100644 --- a/src/EditorFeatures/CSharpTest/SignatureHelp/GenericNameFullyWrittenSignatureHelpProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/SignatureHelp/GenericNameFullyWrittenSignatureHelpProviderTests.cs @@ -27,6 +27,11 @@ internal override Type GetSignatureHelpProviderType() [Fact] public async Task NestedGenericTerminated() { + var expectedOrderedItems = new List + { + new("G", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G { }; @@ -37,13 +42,17 @@ void Goo() G$$> } } - """, - [new("G", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWith1ParameterTerminated() { + var expectedOrderedItems = new List + { + new("G", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G { }; @@ -54,13 +63,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWith2ParametersOn1() { + var expectedOrderedItems = new List + { + new("G", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G { }; @@ -71,13 +84,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWith2ParametersOn2() { + var expectedOrderedItems = new List + { + new("G", string.Empty, string.Empty, currentParameterIndex: 1) + }; + await TestAsync(""" class G { }; @@ -88,13 +105,20 @@ void Goo() [|G } } - """, - [new("G", string.Empty, string.Empty, currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWith2ParametersOn1XmlDoc() { + var expectedOrderedItems = new List + { + new("G", + "Summary for G", + "TypeParamS. Also see T", + currentParameterIndex: 0) + }; + await TestAsync(""" /// /// Summary for G @@ -110,16 +134,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G", - "Summary for G", - "TypeParamS. Also see T", - currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWith2ParametersOn2XmlDoc() { + var expectedOrderedItems = new List + { + new("G", "Summary for G", "TypeParamT. Also see S", currentParameterIndex: 1) + }; + await TestAsync(""" /// /// Summary for G @@ -135,8 +160,7 @@ void Goo() [|G } } - """, - [new("G", "Summary for G", "TypeParamT. Also see S", currentParameterIndex: 1)]); + """, expectedOrderedItems); } #endregion @@ -146,6 +170,11 @@ void Goo() [Fact] public async Task DeclaringGenericTypeWithConstraintsStruct() { + var expectedOrderedItems = new List + { + new("G where S : struct", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G where S : struct { }; @@ -157,13 +186,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : struct", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsClass() { + var expectedOrderedItems = new List + { + new("G where S : class", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G where S : class { }; @@ -175,13 +208,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : class", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsNew() { + var expectedOrderedItems = new List + { + new("G where S : new()", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G where S : new() { }; @@ -193,13 +230,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : new()", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsBase() { + var expectedOrderedItems = new List + { + new("G where S : Base", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class Base { } @@ -213,13 +254,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : Base", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsBaseGenericWithGeneric() { + var expectedOrderedItems = new List + { + new("G where S : Base", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class Base { } @@ -233,13 +278,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : Base", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsBaseGenericWithNonGeneric() { + var expectedOrderedItems = new List + { + new("G where S : Base", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class Base { } @@ -253,13 +302,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : Base", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsBaseGenericNested() { + var expectedOrderedItems = new List + { + new("G where S : Base>", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class Base { } @@ -273,13 +326,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : Base>", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsDeriveFromAnotherGenericParameter() { + var expectedOrderedItems = new List + { + new("G where S : T", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G where S : T { }; @@ -291,13 +348,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : T", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsMixed1() { + var expectedOrderedItems = new List + { + new("G where S : Base, new()", "Summary1", "SummaryS", currentParameterIndex: 0) + }; + await TestAsync(""" /// /// Summary1 @@ -320,13 +381,17 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : Base, new()", "Summary1", "SummaryS", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsMixed2() { + var expectedOrderedItems = new List + { + new("G where T : class, S, IGoo, new()", "Summary1", "SummaryT", currentParameterIndex: 1) + }; + await TestAsync(""" /// /// Summary1 @@ -349,13 +414,17 @@ void Goo() [|G } } - """, - [new("G where T : class, S, IGoo, new()", "Summary1", "SummaryT", currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact] public async Task DeclaringGenericTypeWithConstraintsAllowRefStruct() { + var expectedOrderedItems = new List + { + new("G where S : allows ref struct", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class G where S : allows ref struct { }; @@ -367,8 +436,7 @@ void Goo() [|G<$$|]> } } - """, - [new("G where S : allows ref struct", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } #endregion @@ -378,6 +446,11 @@ void Goo() [Fact] public async Task InvokingGenericMethodWith1ParameterTerminated() { + var expectedOrderedItems = new List + { + new("void C.Goo()", string.Empty, string.Empty, currentParameterIndex: 0) + }; + await TestAsync(""" class C { @@ -388,13 +461,18 @@ void Bar() [|Goo<$$|]> } } - """, - [new("void C.Goo()", string.Empty, string.Empty, currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544091")] public async Task InvokingGenericMethodWith2ParametersOn1() { + var expectedOrderedItems = new List + { + new("void C.Goo(S s, T t)", + "Method summary", "type param S. see T", currentParameterIndex: 0) + }; + await TestAsync(""" class C { @@ -412,14 +490,17 @@ void Bar() [|Goo<$$|]> } } - """, - [new("void C.Goo(S s, T t)", - "Method summary", "type param S. see T", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544091")] public async Task InvokingGenericMethodWith2ParametersOn2() { + var expectedOrderedItems = new List + { + new("void C.Goo(S s, T t)", string.Empty, string.Empty, currentParameterIndex: 1) + }; + await TestAsync(""" class C { @@ -430,13 +511,17 @@ void Bar() [|Goo } } - """, - [new("void C.Goo(S s, T t)", string.Empty, string.Empty, currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544091")] public async Task InvokingGenericMethodWith2ParametersOn1XmlDoc() { + var expectedOrderedItems = new List + { + new("void C.Goo(S s, T t)", "SummaryForGoo", "SummaryForS", currentParameterIndex: 0) + }; + await TestAsync(""" class C { @@ -452,13 +537,17 @@ void Bar() [|Goo<$$|]> } } - """, - [new("void C.Goo(S s, T t)", "SummaryForGoo", "SummaryForS", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544091")] public async Task InvokingGenericMethodWith2ParametersOn2XmlDoc() { + var expectedOrderedItems = new List + { + new("void C.Goo(S s, T t)", "SummaryForGoo", "SummaryForT", currentParameterIndex: 1) + }; + await TestAsync(""" class C { @@ -474,13 +563,17 @@ void Bar() [|Goo } } - """, - [new("void C.Goo(S s, T t)", "SummaryForGoo", "SummaryForT", currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact] public async Task CallingGenericExtensionMethod() { + var expectedOrderedItems = new List + { + new($"({CSharpFeaturesResources.extension}) void G.Goo()", string.Empty, string.Empty, currentParameterIndex: 0) + }; + // TODO: Enable the script case when we have support for extension methods in scripts await TestAsync(""" class G @@ -499,9 +592,7 @@ static class GooClass { public static void Goo(this G g) { } } - """, - [new($"({CSharpFeaturesResources.extension}) void G.Goo()", string.Empty, string.Empty, currentParameterIndex: 0)], - usePreviousCharAsTrigger: false, sourceCodeKind: SourceCodeKind.Regular); + """, expectedOrderedItems, usePreviousCharAsTrigger: false, sourceCodeKind: Microsoft.CodeAnalysis.SourceCodeKind.Regular); } #endregion @@ -511,6 +602,11 @@ public static void Goo(this G g) { } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544091")] public async Task InvokingGenericMethodWithConstraintsMixed1() { + var expectedOrderedItems = new List + { + new("S C.Goo(S s, T t) where S : Base, new()", "GooSummary", "ParamS", currentParameterIndex: 0) + }; + await TestAsync(""" class Base { } interface IGoo { } @@ -532,12 +628,17 @@ void Bar() [|Goo<$$|]> } } - """, [new("S C.Goo(S s, T t) where S : Base, new()", "GooSummary", "ParamS", currentParameterIndex: 0)]); + """, expectedOrderedItems); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544091")] public async Task InvokingGenericMethodWithConstraintsMixed2() { + var expectedOrderedItems = new List + { + new("S C.Goo(S s, T t) where T : class, S, IGoo, new()", "GooSummary", "ParamT", currentParameterIndex: 1) + }; + await TestAsync(""" class Base { } interface IGoo { } @@ -559,7 +660,7 @@ void Bar() [|Goo } } - """, [new("S C.Goo(S s, T t) where T : class, S, IGoo, new()", "GooSummary", "ParamT", currentParameterIndex: 1)]); + """, expectedOrderedItems); } [Fact] @@ -581,7 +682,9 @@ void Bar() } } """, - [new SignatureHelpTestItem("void C.M(T arg) where T : unmanaged", "summary headline", "T documentation", currentParameterIndex: 0)]); + [ + new SignatureHelpTestItem("void C.M(T arg) where T : unmanaged", "summary headline", "T documentation", currentParameterIndex: 0) + ]); #endregion @@ -792,6 +895,7 @@ await TestSignatureHelpInEditorBrowsableContextsAsync(markup: markup, [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1083601")] public async Task DeclaringGenericTypeWithBadTypeArgumentList() { + var expectedOrderedItems = new List(); await TestAsync(""" class G { }; @@ -802,12 +906,28 @@ void Goo() G{$$> } } - """, []); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/50114")] public async Task DeclaringGenericTypeWithDocCommentList() { + var expectedOrderedItems = new List + { + new("G", """ + List: + + Item 1. + """, + classificationTypeNames: ImmutableArray.Create( + ClassificationTypeNames.Text, + ClassificationTypeNames.WhiteSpace, + ClassificationTypeNames.WhiteSpace, + ClassificationTypeNames.WhiteSpace, + ClassificationTypeNames.Text, + ClassificationTypeNames.WhiteSpace)) + }; + await TestAsync(""" /// /// List: @@ -828,19 +948,7 @@ void Goo() [|G } } - """, - [new("G", """ - List: - - Item 1. - """, - classificationTypeNames: ImmutableArray.Create( - ClassificationTypeNames.Text, - ClassificationTypeNames.WhiteSpace, - ClassificationTypeNames.WhiteSpace, - ClassificationTypeNames.WhiteSpace, - ClassificationTypeNames.Text, - ClassificationTypeNames.WhiteSpace))]); + """, expectedOrderedItems); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/80233")] diff --git a/src/EditorFeatures/Test2/IntelliSense/SignatureHelpControllerTests.vb b/src/EditorFeatures/Test2/IntelliSense/SignatureHelpControllerTests.vb index 7ab56ceb38b9b..9af6ff6690eab 100644 --- a/src/EditorFeatures/Test2/IntelliSense/SignatureHelpControllerTests.vb +++ b/src/EditorFeatures/Test2/IntelliSense/SignatureHelpControllerTests.vb @@ -21,7 +21,6 @@ Imports Microsoft.VisualStudio.Text.Editor Imports Microsoft.VisualStudio.Text.Editor.Commanding.Commands Imports Microsoft.VisualStudio.Text.Projection Imports Moq -Imports Roslyn.Utilities Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense @@ -152,7 +151,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense If provider Is Nothing Then items = If(items, CreateItems(1)) - provider = New MockSignatureHelpProvider(items.ToImmutableArray()) + provider = New MockSignatureHelpProvider(items) End If Dim presenter = New Mock(Of IIntelliSensePresenter(Of ISignatureHelpPresenterSession, ISignatureHelpSession))(MockBehavior.Strict) With {.DefaultValue = DefaultValue.Mock} @@ -195,16 +194,16 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense Return controller End Function - Private Shared Function CreateItems(count As Integer) As ImmutableArray(Of SignatureHelpItem) - Return Enumerable.Range(0, count).SelectAsArray(Function(i) New SignatureHelpItem(isVariadic:=False, documentationFactory:=Nothing, prefixParts:=New List(Of TaggedText), separatorParts:={}, suffixParts:={}, parameters:={}, descriptionParts:={})) + Private Shared Function CreateItems(count As Integer) As IList(Of SignatureHelpItem) + Return Enumerable.Range(0, count).Select(Function(i) New SignatureHelpItem(isVariadic:=False, documentationFactory:=Nothing, prefixParts:=New List(Of TaggedText), separatorParts:={}, suffixParts:={}, parameters:={}, descriptionParts:={})).ToList() End Function Friend Class MockSignatureHelpProvider Implements ISignatureHelpProvider - Private ReadOnly _items As ImmutableArray(Of SignatureHelpItem) + Private ReadOnly _items As IList(Of SignatureHelpItem) - Public Sub New(items As ImmutableArray(Of SignatureHelpItem)) + Public Sub New(items As IList(Of SignatureHelpItem)) Me._items = items End Sub @@ -213,8 +212,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense Public Function GetItemsAsync(document As Document, position As Integer, triggerInfo As SignatureHelpTriggerInfo, options As MemberDisplayOptions, cancellationToken As CancellationToken) As Task(Of SignatureHelpItems) Implements ISignatureHelpProvider.GetItemsAsync GetItemsCount += 1 Return Task.FromResult(If(_items.Any(), - New SignatureHelpItems(_items, TextSpan.FromBounds(position, position), selectedItem:=0, semanticParameterIndex:=0, syntacticArgumentCount:=0, argumentName:=Nothing), - Nothing)) + New SignatureHelpItems(_items, TextSpan.FromBounds(position, position), selectedItem:=0, semanticParameterIndex:=0, syntacticArgumentCount:=0, argumentName:=Nothing), + Nothing)) End Function Public ReadOnly Property TriggerCharacters As ImmutableArray(Of Char) Implements ISignatureHelpProvider.TriggerCharacters diff --git a/src/EditorFeatures/TestUtilities/SignatureHelp/AbstractSignatureHelpProviderTests.cs b/src/EditorFeatures/TestUtilities/SignatureHelp/AbstractSignatureHelpProviderTests.cs index c4baf9342ce5e..9c3b93cf5bfc1 100644 --- a/src/EditorFeatures/TestUtilities/SignatureHelp/AbstractSignatureHelpProviderTests.cs +++ b/src/EditorFeatures/TestUtilities/SignatureHelp/AbstractSignatureHelpProviderTests.cs @@ -181,7 +181,7 @@ private async Task VerifyCurrentParameterNameWorkerAsync(string markup, string e private static void CompareAndAssertCollectionsAndCurrentParameter( IEnumerable expectedTestItems, SignatureHelpItems actualSignatureHelpItems) { - Assert.True(expectedTestItems.Count() == actualSignatureHelpItems.Items.Length, $"Expected {expectedTestItems.Count()} items, but got {actualSignatureHelpItems.Items.Length}"); + Assert.True(expectedTestItems.Count() == actualSignatureHelpItems.Items.Count, $"Expected {expectedTestItems.Count()} items, but got {actualSignatureHelpItems.Items.Count}"); for (var i = 0; i < expectedTestItems.Count(); i++) { diff --git a/src/Features/CSharp/Portable/ExternalAccess/Pythia/Api/PythiaSignatureHelpItemWrapper.cs b/src/Features/CSharp/Portable/ExternalAccess/Pythia/Api/PythiaSignatureHelpItemWrapper.cs index cc50e0915d45e..5fbac117c5f38 100644 --- a/src/Features/CSharp/Portable/ExternalAccess/Pythia/Api/PythiaSignatureHelpItemWrapper.cs +++ b/src/Features/CSharp/Portable/ExternalAccess/Pythia/Api/PythiaSignatureHelpItemWrapper.cs @@ -21,5 +21,5 @@ public static PythiaSignatureHelpItemWrapper CreateFromMethodGroupMethod( int position, SemanticModel semanticModel, IList descriptionParts) - => new(AbstractOrdinaryMethodSignatureHelpProvider.ConvertMethodGroupMethod(document, method, position, semanticModel, [.. descriptionParts])); + => new(AbstractOrdinaryMethodSignatureHelpProvider.ConvertMethodGroupMethod(document, method, position, semanticModel, descriptionParts)); } diff --git a/src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs index d6ce004565d49..48a9e6f023864 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/AbstractCSharpSignatureHelpProvider.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using Microsoft.CodeAnalysis.DocumentationComments; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SignatureHelp; @@ -34,13 +33,13 @@ protected static SymbolDisplayPart Space() protected static SymbolDisplayPart NewLine() => new(SymbolDisplayPartKind.LineBreak, null, "\r\n"); - private static readonly ImmutableArray _separatorParts = + private static readonly IList _separatorParts = [ Punctuation(SyntaxKind.CommaToken), Space() ]; - protected static ImmutableArray GetSeparatorParts() => _separatorParts; + protected static IList GetSeparatorParts() => _separatorParts; protected static SignatureHelpSymbolParameter Convert( IParameterSymbol parameter, diff --git a/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider.cs index 095d961810442..de6a1bb133478 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Threading; @@ -13,7 +14,6 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.DocumentationComments; using Microsoft.CodeAnalysis.LanguageService; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SignatureHelp; using Microsoft.CodeAnalysis.Text; @@ -156,9 +156,9 @@ private static SignatureHelpItem Convert( throw ExceptionUtilities.UnexpectedValue(symbol); } - ImmutableArray GetTypeArguments(IMethodSymbol method) + IList GetTypeArguments(IMethodSymbol method) { - using var _ = ArrayBuilder.GetInstance(out var result); + var result = new List(); // Signature help for generic modern extensions must include the generic type *arguments* for the containing // extension as well. These are fixed given the receiver, and need to be repeated in the method type argument @@ -173,7 +173,7 @@ ImmutableArray GetTypeArguments(IMethodSymbol meth result.AddRange(method.TypeParameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService))); - return result.ToImmutableAndClear(); + return result; } } @@ -195,12 +195,12 @@ private static SignatureHelpSymbolParameter Convert( selectedDisplayParts: GetSelectedDisplayParts(parameter, semanticModel, position)); } - private static ImmutableArray GetSelectedDisplayParts( + private static IList GetSelectedDisplayParts( ITypeParameterSymbol typeParam, SemanticModel semanticModel, int position) { - using var _ = ArrayBuilder.GetInstance(out var parts); + var parts = new List(); if (TypeParameterHasConstraints(typeParam)) { @@ -276,7 +276,7 @@ private static ImmutableArray GetSelectedDisplayParts( } } - return parts.ToImmutableAndClear(); + return parts; } private static bool TypeParameterHasConstraints(ITypeParameterSymbol typeParam) diff --git a/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_Method.cs b/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_Method.cs index 79fce86ad22d1..38690a5a7def4 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_Method.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_Method.cs @@ -2,20 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Immutable; -using Microsoft.CodeAnalysis.PooledObjects; +using System.Collections.Generic; using Microsoft.CodeAnalysis.Shared.Extensions; namespace Microsoft.CodeAnalysis.CSharp.SignatureHelp; internal partial class AbstractGenericNameSignatureHelpProvider { - private static ImmutableArray GetPreambleParts( + private static IList GetPreambleParts( IMethodSymbol method, SemanticModel semanticModel, int position) { - using var _ = ArrayBuilder.GetInstance(out var result); + var result = new List(); var awaitable = method.GetOriginalUnreducedDefinition().IsAwaitableNonDynamic(semanticModel, position); var extension = method.GetOriginalUnreducedDefinition().IsExtensionMethod(); @@ -56,7 +55,7 @@ private static ImmutableArray GetPreambleParts( result.Add(new SymbolDisplayPart(SymbolDisplayPartKind.MethodName, method, method.Name)); result.Add(Punctuation(SyntaxKind.LessThanToken)); - return result.ToImmutableAndClear(); + return result; } private static ITypeSymbol? GetContainingType(IMethodSymbol method) @@ -72,11 +71,13 @@ private static ImmutableArray GetPreambleParts( } } - private static ImmutableArray GetPostambleParts(IMethodSymbol method, SemanticModel semanticModel, int position) + private static IList GetPostambleParts(IMethodSymbol method, SemanticModel semanticModel, int position) { - using var _ = ArrayBuilder.GetInstance(out var result); - result.Add(Punctuation(SyntaxKind.GreaterThanToken)); - result.Add(Punctuation(SyntaxKind.OpenParenToken)); + var result = new List + { + Punctuation(SyntaxKind.GreaterThanToken), + Punctuation(SyntaxKind.OpenParenToken) + }; var first = true; foreach (var parameter in method.Parameters) @@ -92,6 +93,6 @@ private static ImmutableArray GetPostambleParts(IMethodSymbol } result.Add(Punctuation(SyntaxKind.CloseParenToken)); - return result.ToImmutableAndClear(); + return result; } } diff --git a/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_NamedType.cs b/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_NamedType.cs index d90fa2f98c200..834a77dd75536 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_NamedType.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/AbstractGenericNameSignatureHelpProvider_NamedType.cs @@ -2,13 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Immutable; +using System.Collections.Generic; namespace Microsoft.CodeAnalysis.CSharp.SignatureHelp; internal partial class AbstractGenericNameSignatureHelpProvider { - private static ImmutableArray GetPreambleParts( + private static IList GetPreambleParts( INamedTypeSymbol namedType, SemanticModel semanticModel, int position) @@ -16,6 +16,6 @@ private static ImmutableArray GetPreambleParts( return [.. namedType.ToMinimalDisplayParts(semanticModel, position, MinimallyQualifiedWithoutTypeParametersFormat), Punctuation(SyntaxKind.LessThanToken)]; } - private static ImmutableArray GetPostambleParts() + private static IList GetPostambleParts() => [Punctuation(SyntaxKind.GreaterThanToken)]; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.cs index de801fca0b063..290c2cc2d1d8b 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.cs @@ -2,11 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Immutable; +using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis.DocumentationComments; using Microsoft.CodeAnalysis.LanguageService; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SignatureHelp; @@ -28,7 +27,7 @@ internal static SignatureHelpItem ConvertMethodGroupMethod( IMethodSymbol method, int position, SemanticModel semanticModel, - ImmutableArray? descriptionParts) + IList? descriptionParts) { var structuralTypeDisplayService = document.GetRequiredLanguageService(); var documentationCommentFormattingService = document.GetRequiredLanguageService(); @@ -45,12 +44,12 @@ [.. method.Parameters.Select(p => Convert(p, semanticModel, position, documentat descriptionParts: descriptionParts); } - private static ImmutableArray GetMethodGroupPreambleParts( + private static IList GetMethodGroupPreambleParts( IMethodSymbol method, SemanticModel semanticModel, int position) { - using var _ = ArrayBuilder.GetInstance(out var result); + var result = new List(); var awaitable = method.GetOriginalUnreducedDefinition().IsAwaitableNonDynamic(semanticModel, position); var extension = method.GetOriginalUnreducedDefinition().IsExtensionMethod(); @@ -82,9 +81,9 @@ private static ImmutableArray GetMethodGroupPreambleParts( result.AddRange(method.ToMinimalDisplayParts(semanticModel, position, MinimallyQualifiedWithoutParametersFormat)); result.Add(Punctuation(SyntaxKind.OpenParenToken)); - return result.ToImmutableAndClear(); + return result; } - private static ImmutableArray GetMethodGroupPostambleParts() + private static IList GetMethodGroupPostambleParts() => [Punctuation(SyntaxKind.CloseParenToken)]; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/AttributeSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/AttributeSignatureHelpProvider.cs index 30c34711fd57b..bb27965b2b009 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/AttributeSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/AttributeSignatureHelpProvider.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Diagnostics.CodeAnalysis; @@ -15,7 +16,6 @@ using Microsoft.CodeAnalysis.DocumentationComments; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageService; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SignatureHelp; using Microsoft.CodeAnalysis.Text; @@ -135,10 +135,10 @@ private static SignatureHelpItem Convert( var position = attribute.SpanStart; var namedParameters = constructor.ContainingType.GetAttributeNamedParameters(semanticModel.Compilation, within) .OrderBy(s => s.Name) - .ToImmutableArray(); + .ToList(); var isVariadic = - constructor.Parameters is [.., { IsParams: true }] && namedParameters.IsEmpty; + constructor.Parameters is [.., { IsParams: true }] && namedParameters.Count == 0; var item = CreateItem( constructor, semanticModel, position, @@ -152,45 +152,51 @@ private static SignatureHelpItem Convert( return item; } - private static ImmutableArray GetParameters( + private static IList GetParameters( IMethodSymbol constructor, SemanticModel semanticModel, int position, - ImmutableArray namedParameters, + IList namedParameters, IDocumentationCommentFormattingService documentationCommentFormatter, CancellationToken cancellationToken) { - using var _ = ArrayBuilder.GetInstance(out var result); + var result = new List(); foreach (var parameter in constructor.Parameters) + { result.Add(Convert(parameter, semanticModel, position, documentationCommentFormatter)); + } - for (var i = 0; i < namedParameters.Length; i++) + for (var i = 0; i < namedParameters.Count; i++) { cancellationToken.ThrowIfCancellationRequested(); var namedParameter = namedParameters[i]; - var type = namedParameter is IFieldSymbol field ? field.Type : ((IPropertySymbol)namedParameter).Type; + var type = namedParameter is IFieldSymbol ? ((IFieldSymbol)namedParameter).Type : ((IPropertySymbol)namedParameter).Type; + + var displayParts = new List + { + new( + namedParameter is IFieldSymbol ? SymbolDisplayPartKind.FieldName : SymbolDisplayPartKind.PropertyName, + namedParameter, namedParameter.Name.ToIdentifierToken().ToString()), + Space(), + Punctuation(SyntaxKind.EqualsToken), + Space() + }; + displayParts.AddRange(type.ToMinimalDisplayParts(semanticModel, position)); + result.Add(new SignatureHelpSymbolParameter( namedParameter.Name, isOptional: true, documentationFactory: namedParameter.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormatter), - displayParts: - [ - new(namedParameter is IFieldSymbol ? SymbolDisplayPartKind.FieldName : SymbolDisplayPartKind.PropertyName, - namedParameter, namedParameter.Name.ToIdentifierToken().ToString()), - Space(), - Punctuation(SyntaxKind.EqualsToken), - Space(), - .. type.ToMinimalDisplayParts(semanticModel, position), - ], + displayParts: displayParts, prefixDisplayParts: GetParameterPrefixDisplayParts(i))); } - return result.ToImmutableAndClear(); + return result; } - private static ImmutableArray? GetParameterPrefixDisplayParts(int i) + private static List? GetParameterPrefixDisplayParts(int i) { if (i == 0) { @@ -205,7 +211,7 @@ .. type.ToMinimalDisplayParts(semanticModel, position), return null; } - private static ImmutableArray GetPreambleParts( + private static IList GetPreambleParts( IMethodSymbol method, SemanticModel semanticModel, int position) @@ -213,6 +219,6 @@ private static ImmutableArray GetPreambleParts( return [.. method.ContainingType.ToMinimalDisplayParts(semanticModel, position), Punctuation(SyntaxKind.OpenParenToken)]; } - private static ImmutableArray GetPostambleParts() + private static IList GetPostambleParts() => [Punctuation(SyntaxKind.CloseParenToken)]; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/ConstructorInitializerSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/ConstructorInitializerSignatureHelpProvider.cs index 06576d60e5db8..9e87eba563fbb 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/ConstructorInitializerSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/ConstructorInitializerSignatureHelpProvider.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Linq; @@ -147,7 +148,7 @@ private static SignatureHelpItem Convert( return item; } - private static ImmutableArray GetPreambleParts( + private static IList GetPreambleParts( IMethodSymbol method, SemanticModel semanticModel, int position) @@ -155,6 +156,6 @@ private static ImmutableArray GetPreambleParts( return [.. method.ContainingType.ToMinimalDisplayParts(semanticModel, position), Punctuation(SyntaxKind.OpenParenToken)]; } - private static ImmutableArray GetPostambleParts() + private static IList GetPostambleParts() => [Punctuation(SyntaxKind.CloseParenToken)]; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs index 4480f8fcad5fe..16b7815d93d4c 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/ElementAccessExpressionSignatureHelpProvider.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Diagnostics.CodeAnalysis; @@ -15,7 +16,6 @@ using Microsoft.CodeAnalysis.DocumentationComments; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageService; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SignatureHelp; using Microsoft.CodeAnalysis.Text; @@ -234,12 +234,12 @@ private static SignatureHelpItem Convert( return item; } - private static ImmutableArray GetPreambleParts( + private static IList GetPreambleParts( IPropertySymbol indexer, int position, SemanticModel semanticModel) { - using var _ = ArrayBuilder.GetInstance(out var result); + var result = new List(); if (indexer.ReturnsByRef) { @@ -266,10 +266,10 @@ private static ImmutableArray GetPreambleParts( result.Add(Punctuation(SyntaxKind.OpenBracketToken)); - return result.ToImmutableAndClear(); + return result; } - private static ImmutableArray GetPostambleParts() + private static IList GetPostambleParts() => [Punctuation(SyntaxKind.CloseBracketToken)]; private static class CompleteElementAccessExpression diff --git a/src/Features/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProviderBase_DelegateAndFunctionPointerInvoke.cs b/src/Features/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProviderBase_DelegateAndFunctionPointerInvoke.cs index 9b2b5143924f0..5b6dcce2a531f 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProviderBase_DelegateAndFunctionPointerInvoke.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/InvocationExpressionSignatureHelpProviderBase_DelegateAndFunctionPointerInvoke.cs @@ -2,13 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Immutable; +using System.Collections.Generic; using System.Threading; using Microsoft.CodeAnalysis.CSharp.Extensions; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.DocumentationComments; using Microsoft.CodeAnalysis.LanguageService; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SignatureHelp; @@ -37,7 +36,7 @@ internal abstract partial class InvocationExpressionSignatureHelpProviderBase return invokeMethod; } - private static ImmutableArray GetDelegateOrFunctionPointerInvokeItems(InvocationExpressionSyntax invocationExpression, IMethodSymbol invokeMethod, SemanticModel semanticModel, IStructuralTypeDisplayService structuralTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, out int? selectedItem, CancellationToken cancellationToken) + private static IList GetDelegateOrFunctionPointerInvokeItems(InvocationExpressionSyntax invocationExpression, IMethodSymbol invokeMethod, SemanticModel semanticModel, IStructuralTypeDisplayService structuralTypeDisplayService, IDocumentationCommentFormattingService documentationCommentFormattingService, out int? selectedItem, CancellationToken cancellationToken) { var position = invocationExpression.SpanStart; var item = CreateItem( @@ -56,9 +55,9 @@ private static ImmutableArray GetDelegateOrFunctionPointerInv return [item]; } - private static ImmutableArray GetDelegateOrFunctionPointerInvokePreambleParts(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position) + private static IList GetDelegateOrFunctionPointerInvokePreambleParts(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position) { - using var _ = ArrayBuilder.GetInstance(out var displayParts); + var displayParts = new List(); displayParts.AddRange(invokeMethod.ReturnType.ToMinimalDisplayParts(semanticModel, position)); displayParts.Add(Space()); @@ -74,13 +73,13 @@ private static ImmutableArray GetDelegateOrFunctionPointerInv displayParts.Add(Punctuation(SyntaxKind.OpenParenToken)); - return displayParts.ToImmutableAndClear(); + return displayParts; } - private static ImmutableArray GetDelegateOrFunctionPointerInvokeParameters( + private static IList GetDelegateOrFunctionPointerInvokeParameters( IMethodSymbol invokeMethod, SemanticModel semanticModel, int position, IDocumentationCommentFormattingService formattingService, CancellationToken cancellationToken) { - using var _ = ArrayBuilder.GetInstance(out var result); + var result = new List(); foreach (var parameter in invokeMethod.Parameters) { @@ -92,9 +91,9 @@ private static ImmutableArray GetDelegateOrFunctio parameter.ToMinimalDisplayParts(semanticModel, position))); } - return result.ToImmutableAndClear(); + return result; } - private static ImmutableArray GetDelegateOrFunctionPointerInvokePostambleParts() + private static IList GetDelegateOrFunctionPointerInvokePostambleParts() => [Punctuation(SyntaxKind.CloseParenToken)]; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs b/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs index e46a14aafe5d4..b25747835e5af 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.LanguageService; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.SignatureHelp; namespace Microsoft.CodeAnalysis.CSharp.SignatureHelp; @@ -33,17 +33,21 @@ private static ImmutableArray ConvertDelegateTypeConstructor( return [item]; } - private static ImmutableArray GetDelegateTypePreambleParts(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position) - => [ - .. invokeMethod.ContainingType.ToMinimalDisplayParts(semanticModel, position), - Punctuation(SyntaxKind.OpenParenToken), - ]; + private static IList GetDelegateTypePreambleParts(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position) + { + var result = new List(); + + result.AddRange(invokeMethod.ContainingType.ToMinimalDisplayParts(semanticModel, position)); + result.Add(Punctuation(SyntaxKind.OpenParenToken)); + + return result; + } - private static ImmutableArray GetDelegateTypeParameters(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position) + private static IList GetDelegateTypeParameters(IMethodSymbol invokeMethod, SemanticModel semanticModel, int position) { const string TargetName = "target"; - using var _ = ArrayBuilder.GetInstance(out var parts); + var parts = new List(); parts.AddRange(invokeMethod.ReturnType.ToMinimalDisplayParts(semanticModel, position)); parts.Add(Space()); parts.Add(Punctuation(SyntaxKind.OpenParenToken)); @@ -69,9 +73,9 @@ private static ImmutableArray GetDelegateTypeParam TargetName, isOptional: false, documentationFactory: null, - displayParts: parts.ToImmutableAndClear())]; + displayParts: parts)]; } - private static ImmutableArray GetDelegateTypePostambleParts() + private static IList GetDelegateTypePostambleParts() => [Punctuation(SyntaxKind.CloseParenToken)]; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_NormalType.cs b/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_NormalType.cs index c93262a9f2264..01e6979432a4e 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_NormalType.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_NormalType.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Immutable; +using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -36,13 +36,19 @@ private static SignatureHelpItem ConvertNormalTypeConstructor( return item; } - private static ImmutableArray GetNormalTypePreambleParts( - IMethodSymbol method, SemanticModel semanticModel, int position) - => [ - .. method.ContainingType.ToMinimalDisplayParts(semanticModel, position), - Punctuation(SyntaxKind.OpenParenToken), - ]; + private static IList GetNormalTypePreambleParts( + IMethodSymbol method, + SemanticModel semanticModel, + int position) + { + var result = new List(); + + result.AddRange(method.ContainingType.ToMinimalDisplayParts(semanticModel, position)); + result.Add(Punctuation(SyntaxKind.OpenParenToken)); + + return result; + } - private static ImmutableArray GetNormalTypePostambleParts() + private static IList GetNormalTypePostambleParts() => [Punctuation(SyntaxKind.CloseParenToken)]; } diff --git a/src/Features/CSharp/Portable/SignatureHelp/PrimaryConstructorBaseTypeSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/PrimaryConstructorBaseTypeSignatureHelpProvider.cs index 3e61af4945b5b..a836df057d065 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/PrimaryConstructorBaseTypeSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/PrimaryConstructorBaseTypeSignatureHelpProvider.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Diagnostics.CodeAnalysis; @@ -127,16 +128,26 @@ private static SignatureHelpItem Convert( structuralTypeDisplayService, constructor.IsParams(), constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), - GetPreambleParts(), + GetPreambleParts(constructor, semanticModel, position), GetSeparatorParts(), GetPostambleParts(), [.. constructor.Parameters.Select(p => Convert(p, semanticModel, position, documentationCommentFormattingService))]); return item; - ImmutableArray GetPreambleParts() - => [.. constructor.ContainingType.ToMinimalDisplayParts(semanticModel, position), Punctuation(SyntaxKind.OpenParenToken)]; + static IList GetPreambleParts( + IMethodSymbol method, + SemanticModel semanticModel, + int position) + { + var result = new List(); + + result.AddRange(method.ContainingType.ToMinimalDisplayParts(semanticModel, position)); + result.Add(Punctuation(SyntaxKind.OpenParenToken)); + + return result; + } - static ImmutableArray GetPostambleParts() + static IList GetPostambleParts() => [Punctuation(SyntaxKind.CloseParenToken)]; } } diff --git a/src/Features/CSharp/Portable/SignatureHelp/TupleConstructionSignatureHelpProvider.cs b/src/Features/CSharp/Portable/SignatureHelp/TupleConstructionSignatureHelpProvider.cs index f5aef35c99ccc..9b63703f76e2b 100644 --- a/src/Features/CSharp/Portable/SignatureHelp/TupleConstructionSignatureHelpProvider.cs +++ b/src/Features/CSharp/Portable/SignatureHelp/TupleConstructionSignatureHelpProvider.cs @@ -153,8 +153,9 @@ private bool GetOuterMostParenthesizedExpressionInSpan(SyntaxNode root, int posi var suffixParts = SpecializedCollections.SingletonEnumerable(new SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, null, ")")).ToTaggedText(); var separatorParts = GetSeparatorParts().ToTaggedText(); - var items = tupleTypes.SelectAsArray(tupleType => Convert( - tupleType, prefixParts, suffixParts, separatorParts, semanticModel, position)); + var items = tupleTypes.Select(tupleType => Convert( + tupleType, prefixParts, suffixParts, separatorParts, semanticModel, position)) + .ToList(); var state = GetCurrentArgumentState(root, position, syntaxFacts, targetExpression.FullSpan, cancellationToken); return CreateSignatureHelpItems(items, targetExpression.Span, state, selectedItemIndex: null, parameterIndexOverride: -1); @@ -191,7 +192,7 @@ private static IEnumerable ConvertTupleMembers(INamedTyp typeParts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.PropertyName, null, elementName)); } - result.Add(new SignatureHelpParameter(name: string.Empty, isOptional: false, documentationFactory: null, displayParts: [.. typeParts])); + result.Add(new SignatureHelpParameter(name: string.Empty, isOptional: false, documentationFactory: null, displayParts: typeParts)); } return result; diff --git a/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/AbstractStructuralTypeDisplayService.cs b/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/AbstractStructuralTypeDisplayService.cs index 20230877da842..a8e57e9361cc9 100644 --- a/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/AbstractStructuralTypeDisplayService.cs +++ b/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/AbstractStructuralTypeDisplayService.cs @@ -66,12 +66,16 @@ public StructuralTypeDisplayInfo GetTypeDisplayInfo( int position) { if (directStructuralTypeReferences.Length == 0) - return StructuralTypeDisplayInfo.Empty; + { + return new StructuralTypeDisplayInfo( + SpecializedCollections.EmptyDictionary(), + SpecializedCollections.EmptyList()); + } var transitiveStructuralTypeReferences = GetTransitiveStructuralTypeReferences(directStructuralTypeReferences); transitiveStructuralTypeReferences = OrderStructuralTypes(transitiveStructuralTypeReferences, orderSymbol); - using var _ = ArrayBuilder.GetInstance(out var typeParts); + IList typeParts = []; if (transitiveStructuralTypeReferences.Length > 0) { @@ -108,10 +112,10 @@ public StructuralTypeDisplayInfo GetTypeDisplayInfo( // Finally, assign a name to all the anonymous types. var structuralTypeToName = GenerateStructuralTypeNames(transitiveStructuralTypeReferences); - var typePartsArray = StructuralTypeDisplayInfo.ReplaceStructuralTypes( - typeParts.ToImmutableAndClear(), structuralTypeToName, semanticModel, position); + typeParts = StructuralTypeDisplayInfo.ReplaceStructuralTypes( + typeParts, structuralTypeToName, semanticModel, position); - return new StructuralTypeDisplayInfo(structuralTypeToName, typePartsArray); + return new StructuralTypeDisplayInfo(structuralTypeToName, typeParts); } private static Dictionary GenerateStructuralTypeNames( diff --git a/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/StructuralTypeDisplayInfo.cs b/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/StructuralTypeDisplayInfo.cs index 9784d4e6333c4..813d2eff75a5c 100644 --- a/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/StructuralTypeDisplayInfo.cs +++ b/src/Features/Core/Portable/LanguageServices/AnonymousTypeDisplayService/StructuralTypeDisplayInfo.cs @@ -3,26 +3,28 @@ // See the LICENSE file in the project root for more information. using System.Collections.Generic; -using System.Collections.Immutable; -using Microsoft.CodeAnalysis.Collections; -using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis.LanguageService; -internal readonly struct StructuralTypeDisplayInfo( - IDictionary structuralTypeToName, - ImmutableArray typesParts) +internal readonly struct StructuralTypeDisplayInfo { - public static readonly StructuralTypeDisplayInfo Empty = default; + public IDictionary StructuralTypeToName { get; } + public IList TypesParts { get; } - public IDictionary StructuralTypeToName => structuralTypeToName ?? SpecializedCollections.EmptyDictionary(); - public ImmutableArray TypesParts => typesParts.NullToEmpty(); + public StructuralTypeDisplayInfo( + IDictionary structuralTypeToName, + IList typesParts) + : this() + { + StructuralTypeToName = structuralTypeToName; + TypesParts = typesParts; + } - public ImmutableArray ReplaceStructuralTypes(ImmutableArray parts, SemanticModel semanticModel, int position) + public IList ReplaceStructuralTypes(IList parts, SemanticModel semanticModel, int position) => ReplaceStructuralTypes(parts, StructuralTypeToName, semanticModel, position); - public static ImmutableArray ReplaceStructuralTypes( - ImmutableArray parts, + public static IList ReplaceStructuralTypes( + IList parts, IDictionary structuralTypeToName, SemanticModel semanticModel, int position) @@ -35,14 +37,14 @@ public static ImmutableArray ReplaceStructuralTypes( } public static bool ReplaceStructuralTypes( - ImmutableArray parts, + IList parts, IDictionary structuralTypeToName, SemanticModel semanticModel, int position, - out ImmutableArray newParts) + out List newParts) { var changed = false; - using var _ = ArrayBuilder.GetInstance(out var newPartsBuilder); + newParts = []; foreach (var part in parts) { @@ -51,7 +53,7 @@ public static bool ReplaceStructuralTypes( if (structuralTypeToName.TryGetValue(type, out var name) && part.ToString() != name) { - newPartsBuilder.Add(new SymbolDisplayPart(part.Kind, symbol: null, name)); + newParts.Add(new SymbolDisplayPart(part.Kind, symbol: null, name)); changed = true; continue; } @@ -60,22 +62,15 @@ public static bool ReplaceStructuralTypes( if (type.IsTupleType && part.ToString() == "") { var displayParts = type.ToMinimalDisplayParts(semanticModel, position); - newPartsBuilder.AddRange(displayParts); + newParts.AddRange(displayParts); changed = true; continue; } } - newPartsBuilder.Add(part); - } - - if (!changed) - { - newParts = []; - return false; + newParts.Add(part); } - newParts = newPartsBuilder.ToImmutableAndClear(); - return true; + return changed; } } diff --git a/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs b/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs index 8f9c1c2549e6f..ce70ce3816c83 100644 --- a/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs +++ b/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AbstractSymbolDescriptionBuilder.cs @@ -80,7 +80,7 @@ protected abstract partial class AbstractSymbolDescriptionBuilder private readonly SemanticModel _semanticModel; private readonly int _position; - private readonly Dictionary> _groupMap = []; + private readonly Dictionary> _groupMap = []; private readonly Dictionary> _documentationMap = []; private readonly Func _getNavigationHint; @@ -450,7 +450,7 @@ private async Task AddDescriptionPartAsync(ISymbol symbol) private ImmutableArray BuildDescription(SymbolDescriptionGroups groups) { - using var _ = ArrayBuilder.GetInstance(out var finalParts); + var finalParts = new List(); var orderedGroups = _groupMap.Keys.OrderBy((g1, g2) => g1 - g2); foreach (var group in orderedGroups) @@ -460,13 +460,14 @@ private ImmutableArray BuildDescription(SymbolDescriptionGrou continue; } - if (!finalParts.IsEmpty) + if (!finalParts.IsEmpty()) { var newLines = GetPrecedingNewLineCount(group); finalParts.AddRange(LineBreak(newLines)); } - finalParts.AddRange(_groupMap[group]); + var parts = _groupMap[group]; + finalParts.AddRange(parts); } return finalParts.AsImmutable(); @@ -832,12 +833,16 @@ protected void AddToGroup(SymbolDescriptionGroups group, params SymbolDisplayPar protected void AddToGroup(SymbolDescriptionGroups group, params IEnumerable[] partsArray) { - var partsList = partsArray.Flatten().ToImmutableArray(); - if (partsList.Length > 0) + var partsList = partsArray.Flatten().ToList(); + if (partsList.Count > 0) { - var existingParts = _groupMap.TryGetValue(group, out var temp) ? temp : []; - existingParts = existingParts.AddRange(partsList); - _groupMap[group] = existingParts; + if (!_groupMap.TryGetValue(group, out var existingParts)) + { + existingParts = []; + _groupMap.Add(group, existingParts); + } + + existingParts.AddRange(partsList); } } diff --git a/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AnonymousTypes.cs b/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AnonymousTypes.cs index 64d8eae556699..91405a4dc2354 100644 --- a/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AnonymousTypes.cs +++ b/src/Features/Core/Portable/LanguageServices/SymbolDisplayService/AbstractSymbolDisplayService.AnonymousTypes.cs @@ -33,7 +33,7 @@ where part.Symbol.IsAnonymousType() || part.Symbol.IsTupleType() var info = LanguageServices.GetRequiredService().GetTypeDisplayInfo( firstSymbol, directStructuralTypes.ToImmutableArrayOrEmpty(), _semanticModel, _position); - if (info.TypesParts.Length > 0) + if (info.TypesParts.Count > 0) AddToGroup(SymbolDescriptionGroups.StructuralTypes, info.TypesParts); foreach (var (group, parts) in _groupMap.ToArray()) diff --git a/src/Features/Core/Portable/SignatureHelp/AbstractSignatureHelpProvider.cs b/src/Features/Core/Portable/SignatureHelp/AbstractSignatureHelpProvider.cs index d12319bb6dd0b..21fa27cee0639 100644 --- a/src/Features/Core/Portable/SignatureHelp/AbstractSignatureHelpProvider.cs +++ b/src/Features/Core/Portable/SignatureHelp/AbstractSignatureHelpProvider.cs @@ -38,9 +38,9 @@ protected AbstractSignatureHelpProvider() protected abstract Task GetItemsWorkerAsync(Document document, int position, SignatureHelpTriggerInfo triggerInfo, MemberDisplayOptions options, CancellationToken cancellationToken); protected static SignatureHelpItems? CreateSignatureHelpItems( - ImmutableArray items, TextSpan applicableSpan, SignatureHelpState? state, int? selectedItemIndex, int parameterIndexOverride) + IList items, TextSpan applicableSpan, SignatureHelpState? state, int? selectedItemIndex, int parameterIndexOverride) { - if (items.IsDefaultOrEmpty || state == null) + if (items is null || items.Count == 0 || state == null) return null; if (selectedItemIndex < 0) @@ -70,7 +70,7 @@ protected AbstractSignatureHelpProvider() } protected static SignatureHelpItems? CreateCollectionInitializerSignatureHelpItems( - ImmutableArray items, TextSpan applicableSpan, SignatureHelpState? state) + IList items, TextSpan applicableSpan, SignatureHelpState? state) { // We will have added all the accessible '.Add' methods that take at least one // arguments. However, in general the one-arg Add method is the least likely for the @@ -94,15 +94,15 @@ protected AbstractSignatureHelpProvider() items, applicableSpan, state, items.IndexOf(i => i.Parameters.Length >= 2), parameterIndexOverride: -1); } - private static (ImmutableArray items, int? selectedItem) Filter(ImmutableArray items, ImmutableArray parameterNames, int? selectedItem) + private static (IList items, int? selectedItem) Filter(IList items, ImmutableArray parameterNames, int? selectedItem) { if (parameterNames.IsDefault) - return (items, selectedItem); + return (items.ToList(), selectedItem); - var filteredList = items.WhereAsArray(i => Include(i, parameterNames)); - var isEmpty = filteredList.IsEmpty; + var filteredList = items.Where(i => Include(i, parameterNames)).ToList(); + var isEmpty = filteredList.Count == 0; if (!selectedItem.HasValue || isEmpty) - return (isEmpty ? items : filteredList, selectedItem); + return (isEmpty ? [.. items] : filteredList, selectedItem); // adjust the selected item var selection = items[selectedItem.Value]; @@ -138,11 +138,11 @@ protected SignatureHelpItem CreateItem( IStructuralTypeDisplayService structuralTypeDisplayService, bool isVariadic, Func> documentationFactory, - ImmutableArray prefixParts, - ImmutableArray separatorParts, - ImmutableArray suffixParts, - ImmutableArray parameters, - ImmutableArray? descriptionParts = null) + IList prefixParts, + IList separatorParts, + IList suffixParts, + IList parameters, + IList? descriptionParts = null) { return CreateItem(orderSymbol, semanticModel, position, structuralTypeDisplayService, isVariadic, documentationFactory, prefixParts, separatorParts, suffixParts, parameters, descriptionParts); @@ -155,11 +155,11 @@ protected static SignatureHelpItem CreateItem( IStructuralTypeDisplayService structuralTypeDisplayService, bool isVariadic, Func>? documentationFactory, - ImmutableArray prefixParts, - ImmutableArray separatorParts, - ImmutableArray suffixParts, - ImmutableArray parameters, - ImmutableArray? descriptionParts = null) + IList prefixParts, + IList separatorParts, + IList suffixParts, + IList parameters, + IList? descriptionParts = null) { return CreateItemImpl(orderSymbol, semanticModel, position, structuralTypeDisplayService, isVariadic, documentationFactory, prefixParts, separatorParts, suffixParts, parameters, descriptionParts); @@ -172,13 +172,15 @@ protected static SignatureHelpItem CreateItemImpl( IStructuralTypeDisplayService structuralTypeDisplayService, bool isVariadic, Func>? documentationFactory, - ImmutableArray prefixParts, - ImmutableArray separatorParts, - ImmutableArray suffixParts, - ImmutableArray parameters, - ImmutableArray? descriptionParts) + IList prefixParts, + IList separatorParts, + IList suffixParts, + IList parameters, + IList? descriptionParts) { - descriptionParts ??= []; + descriptionParts = descriptionParts == null + ? SpecializedCollections.EmptyList() + : descriptionParts; var allParts = prefixParts.Concat(separatorParts) .Concat(suffixParts) @@ -193,7 +195,7 @@ where part.Symbol.IsAnonymousType() || part.Symbol.IsTupleType() var info = structuralTypeDisplayService.GetTypeDisplayInfo( orderSymbol, [.. structuralTypes], semanticModel, position); - if (info.TypesParts.Length > 0) + if (info.TypesParts.Count > 0) { var structuralTypeParts = new List { @@ -258,7 +260,7 @@ private static SignatureHelpSymbolParameter ReplaceStructuralTypes( var semanticModel = await document.ReuseExistingSpeculativeModelAsync(position, cancellationToken).ConfigureAwait(false); var compilation = semanticModel.Compilation; - using var _1 = ArrayBuilder.GetInstance(out var finalItems); + var finalItems = new List(); foreach (var item in itemsForCurrentDocument.Items) { if (item is not SymbolKeySignatureHelpItem symbolKeyItem || @@ -276,7 +278,7 @@ symbolKeyItem.SymbolKey is not SymbolKey symbolKey || symbolKey = SymbolKey.Create(methodSymbol.OriginalDefinition, cancellationToken); } - using var _2 = ArrayBuilder.GetInstance(out var invalidProjectsForCurrentSymbol); + using var _ = ArrayBuilder.GetInstance(out var invalidProjectsForCurrentSymbol); foreach (var relatedDocument in relatedDocuments) { // Try to resolve symbolKey in each related compilation, @@ -293,7 +295,7 @@ symbolKeyItem.SymbolKey is not SymbolKey symbolKey || } return new SignatureHelpItems( - finalItems.ToImmutableAndClear(), + finalItems, itemsForCurrentDocument.ApplicableSpan, itemsForCurrentDocument.SemanticParameterIndex, itemsForCurrentDocument.SyntacticArgumentCount, diff --git a/src/Features/Core/Portable/SignatureHelp/SignatureHelpItems.cs b/src/Features/Core/Portable/SignatureHelp/SignatureHelpItems.cs index c135184eaba29..179ea67ea04f3 100644 --- a/src/Features/Core/Portable/SignatureHelp/SignatureHelpItems.cs +++ b/src/Features/Core/Portable/SignatureHelp/SignatureHelpItems.cs @@ -4,10 +4,10 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis.Text; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.SignatureHelp; @@ -16,7 +16,7 @@ internal sealed class SignatureHelpItems /// /// The list of items to present to the user. /// - public ImmutableArray Items { get; } + public IList Items { get; } /// /// The span this session applies to. @@ -59,22 +59,23 @@ internal sealed class SignatureHelpItems public int? SelectedItemIndex { get; } public SignatureHelpItems( - ImmutableArray items, + IList items, TextSpan applicableSpan, int semanticParameterIndex, int syntacticArgumentCount, string? argumentName, int? selectedItem = null) { - Contract.ThrowIfTrue(items.IsDefaultOrEmpty); - Contract.ThrowIfTrue(selectedItem.HasValue && selectedItem.Value >= items.Length); + Contract.ThrowIfNull(items); + Contract.ThrowIfTrue(items.IsEmpty()); + Contract.ThrowIfTrue(selectedItem.HasValue && selectedItem.Value >= items.Count); if (semanticParameterIndex < 0) throw new ArgumentException($"{nameof(semanticParameterIndex)} < 0. {semanticParameterIndex} < 0", nameof(semanticParameterIndex)); // Adjust the `selectedItem` index if duplicates are able to be removed. - var distinctItems = items.Distinct(); - if (selectedItem.HasValue && items.Length != distinctItems.Length) + var distinctItems = items.Distinct().ToList(); + if (selectedItem.HasValue && items.Count != distinctItems.Count) { // `selectedItem` index has already been determined to be valid, it now needs to be adjusted to point // to the equivalent item in the reduced list to account for duplicates being removed diff --git a/src/Features/Core/Portable/SignatureHelp/SignatureHelpParameter.cs b/src/Features/Core/Portable/SignatureHelp/SignatureHelpParameter.cs index f4066e7a45c15..408f15cf50de5 100644 --- a/src/Features/Core/Portable/SignatureHelp/SignatureHelpParameter.cs +++ b/src/Features/Core/Portable/SignatureHelp/SignatureHelpParameter.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; +using System.Linq; using System.Threading; +using Microsoft.CodeAnalysis; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.SignatureHelp; @@ -19,10 +21,10 @@ internal sealed class SignatureHelpSymbolParameter( string? name, bool isOptional, Func>? documentationFactory, - ImmutableArray displayParts, - ImmutableArray? prefixDisplayParts = null, - ImmutableArray? suffixDisplayParts = null, - ImmutableArray? selectedDisplayParts = null) + IEnumerable displayParts, + IEnumerable? prefixDisplayParts = null, + IEnumerable? suffixDisplayParts = null, + IEnumerable? selectedDisplayParts = null) { /// /// The name of this parameter. @@ -38,18 +40,18 @@ internal sealed class SignatureHelpSymbolParameter( /// /// Display parts to show before the normal display parts for the parameter. /// - public ImmutableArray PrefixDisplayParts { get; } = prefixDisplayParts.NullToEmpty(); + public IList PrefixDisplayParts { get; } = prefixDisplayParts.ToImmutableArrayOrEmpty(); /// /// Display parts to show after the normal display parts for the parameter. /// - public ImmutableArray SuffixDisplayParts { get; } = suffixDisplayParts ?? []; + public IList SuffixDisplayParts { get; } = suffixDisplayParts.ToImmutableArrayOrEmpty(); /// /// Display parts for this parameter. This should normally be presented to the user as part /// of the entire signature display. /// - public ImmutableArray DisplayParts { get; } = displayParts.NullToEmpty(); + public IList DisplayParts { get; } = displayParts.ToImmutableArrayOrEmpty(); /// /// True if this parameter is optional or not. Optional parameters may be presented in a @@ -61,12 +63,16 @@ internal sealed class SignatureHelpSymbolParameter( /// Display parts for this parameter that should be presented to the user when this /// parameter is selected. /// - public ImmutableArray SelectedDisplayParts { get; } = selectedDisplayParts ?? []; + public IList SelectedDisplayParts { get; } = selectedDisplayParts.ToImmutableArrayOrEmpty(); private static readonly Func> s_emptyDocumentationFactory = _ => []; - internal ImmutableArray GetAllParts() - => [.. PrefixDisplayParts, .. DisplayParts, .. SuffixDisplayParts, .. SelectedDisplayParts]; + internal IEnumerable GetAllParts() + { + return PrefixDisplayParts.Concat(DisplayParts) + .Concat(SuffixDisplayParts) + .Concat(SelectedDisplayParts); + } public static explicit operator SignatureHelpParameter(SignatureHelpSymbolParameter parameter) { @@ -83,10 +89,10 @@ internal sealed class SignatureHelpParameter( string? name, bool isOptional, Func>? documentationFactory, - ImmutableArray displayParts, - ImmutableArray? prefixDisplayParts = null, - ImmutableArray? suffixDisplayParts = null, - ImmutableArray? selectedDisplayParts = null) + IEnumerable displayParts, + IEnumerable? prefixDisplayParts = null, + IEnumerable? suffixDisplayParts = null, + IEnumerable? selectedDisplayParts = null) { /// /// The name of this parameter. @@ -102,18 +108,18 @@ internal sealed class SignatureHelpParameter( /// /// Display parts to show before the normal display parts for the parameter. /// - public ImmutableArray PrefixDisplayParts { get; } = prefixDisplayParts ?? []; + public IList PrefixDisplayParts { get; } = prefixDisplayParts.ToImmutableArrayOrEmpty(); /// /// Display parts to show after the normal display parts for the parameter. /// - public ImmutableArray SuffixDisplayParts { get; } = suffixDisplayParts ?? []; + public IList SuffixDisplayParts { get; } = suffixDisplayParts.ToImmutableArrayOrEmpty(); /// /// Display parts for this parameter. This should normally be presented to the user as part /// of the entire signature display. /// - public ImmutableArray DisplayParts { get; } = displayParts.NullToEmpty(); + public IList DisplayParts { get; } = displayParts.ToImmutableArrayOrEmpty(); /// /// True if this parameter is optional or not. Optional parameters may be presented in a @@ -125,7 +131,7 @@ internal sealed class SignatureHelpParameter( /// Display parts for this parameter that should be presented to the user when this /// parameter is selected. /// - public ImmutableArray SelectedDisplayParts { get; } = selectedDisplayParts ?? []; + public IList SelectedDisplayParts { get; } = selectedDisplayParts.ToImmutableArrayOrEmpty(); private static readonly Func> s_emptyDocumentationFactory = _ => []; @@ -134,10 +140,10 @@ public SignatureHelpParameter( string name, bool isOptional, Func>? documentationFactory, - ImmutableArray displayParts, - ImmutableArray? prefixDisplayParts = null, - ImmutableArray? suffixDisplayParts = null, - ImmutableArray? selectedDisplayParts = null) + IEnumerable displayParts, + IEnumerable? prefixDisplayParts = null, + IEnumerable? suffixDisplayParts = null, + IEnumerable? selectedDisplayParts = null) : this(name, isOptional, documentationFactory is null ? null : c => documentationFactory(c).ToTaggedText(), displayParts.ToTaggedText(), @@ -147,8 +153,12 @@ public SignatureHelpParameter( { } - internal ImmutableArray GetAllParts() - => [.. PrefixDisplayParts, .. DisplayParts, .. SuffixDisplayParts, .. SelectedDisplayParts]; + internal IEnumerable GetAllParts() + { + return PrefixDisplayParts.Concat(DisplayParts) + .Concat(SuffixDisplayParts) + .Concat(SelectedDisplayParts); + } public override string ToString() { diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/AbstractIntrinsicOperatorSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/AbstractIntrinsicOperatorSignatureHelpProvider.vb index ca9c3bd2fa902..ed3d8826fd253 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/AbstractIntrinsicOperatorSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/AbstractIntrinsicOperatorSignatureHelpProvider.vb @@ -5,7 +5,6 @@ Imports System.Threading Imports Microsoft.CodeAnalysis.Collections Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators @@ -38,7 +37,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Return Nothing End If - Dim items = ArrayBuilder(Of SignatureHelpItem).GetInstance() + Dim items As New List(Of SignatureHelpItem) Dim semanticModel = Await document.ReuseExistingSpeculativeModelAsync(node, cancellationToken).ConfigureAwait(False) For Each documentation In Await GetIntrinsicOperatorDocumentationAsync(node, document, cancellationToken).ConfigureAwait(False) @@ -50,12 +49,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim syntaxFacts = document.GetLanguageService(Of ISyntaxFactsService) Return CreateSignatureHelpItems( - items.ToImmutableAndFree(), textSpan, + items, textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), selectedItemIndex:=Nothing, parameterIndexOverride:=-1) End Function Friend Shared Function GetSignatureHelpItemForIntrinsicOperator(document As Document, semanticModel As SemanticModel, position As Integer, documentation As AbstractIntrinsicOperatorDocumentation, cancellationToken As CancellationToken) As SignatureHelpItem - Dim parameters = ArrayBuilder(Of SignatureHelpSymbolParameter).GetInstance() + Dim parameters As New List(Of SignatureHelpSymbolParameter) For i = 0 To documentation.ParameterCount - 1 Dim capturedIndex = i @@ -79,7 +78,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp prefixParts:=documentation.PrefixParts, separatorParts:=GetSeparatorParts(), suffixParts:=suffixParts, - parameters:=parameters.ToImmutableAndFree()) + parameters:=parameters) End Function Protected Overridable Function GetCurrentArgumentStateWorker(node As SyntaxNode, position As Integer) As SignatureHelpState diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.vb index c2d65fab1d1c5..7ff272a7a8f25 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/AbstractOrdinaryMethodSignatureHelpProvider.vb @@ -2,15 +2,13 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp - Friend MustInherit Class AbstractOrdinaryMethodSignatureHelpProvider - Inherits AbstractVisualBasicSignatureHelpProvider + friend MustInherit class AbstractOrdinaryMethodSignatureHelpProvider + inherits AbstractVisualBasicSignatureHelpProvider Protected Shared Function ConvertMemberGroupMember(document As Document, member As ISymbol, @@ -28,11 +26,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp GetMemberGroupPreambleParts(member, semanticModel, position), GetSeparatorParts(), GetMemberGroupPostambleParts(member, semanticModel, position), - member.GetParameters().SelectAsArray(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService))) + member.GetParameters().Select(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList()) End Function - Private Shared Function GetMemberGroupPreambleParts(symbol As ISymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetMemberGroupPreambleParts(symbol As ISymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() AddExtensionPreamble(symbol, result) @@ -46,14 +44,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp result.AddRange(symbol.ToMinimalDisplayParts(semanticModel, position, format)) result.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetMemberGroupPostambleParts( - symbol As ISymbol, - semanticModel As SemanticModel, - position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim parts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetMemberGroupPostambleParts(symbol As ISymbol, + semanticModel As SemanticModel, + position As Integer) As IList(Of SymbolDisplayPart) + Dim parts = New List(Of SymbolDisplayPart) parts.Add(Punctuation(SyntaxKind.CloseParenToken)) If TypeOf symbol Is IMethodSymbol Then @@ -73,7 +70,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parts.AddRange([property].Type.ToMinimalDisplayParts(semanticModel, position)) End If - Return parts.ToImmutableAndFree() + Return parts End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/AbstractVisualBasicSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/AbstractVisualBasicSignatureHelpProvider.vb index cce684ddaf9d5..1421a16fd87ef 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/AbstractVisualBasicSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/AbstractVisualBasicSignatureHelpProvider.vb @@ -2,9 +2,7 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis.DocumentationComments -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp @@ -36,8 +34,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Return New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, vbCrLf) End Function - Protected Shared Function GetSeparatorParts() As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create(Punctuation(SyntaxKind.CommaToken), Space()) + Protected Shared Function GetSeparatorParts() As IList(Of SymbolDisplayPart) + Return {Punctuation(SyntaxKind.CommaToken), Space()} End Function Protected Shared Function Convert(parameter As IParameterSymbol, @@ -50,7 +48,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parameter.ToMinimalDisplayParts(semanticModel, position)) End Function - Protected Shared Sub AddExtensionPreamble(symbol As ISymbol, result As ArrayBuilder(Of SymbolDisplayPart)) + Protected Shared Sub AddExtensionPreamble(symbol As ISymbol, result As IList(Of SymbolDisplayPart)) If symbol.GetOriginalUnreducedDefinition().IsExtensionMethod() Then result.Add(Punctuation(SyntaxKind.LessThanToken)) result.Add(Text(VBFeaturesResources.Extension)) diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/AttributeSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/AttributeSignatureHelpProvider.vb index 5e9c39a25533e..e5e5f91776863 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/AttributeSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/AttributeSignatureHelpProvider.vb @@ -9,7 +9,6 @@ Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -85,8 +84,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim symbolInfo = semanticModel.GetSymbolInfo(attribute, cancellationToken) Dim selectedItem = TryGetSelectedIndex(accessibleConstructors, symbolInfo.Symbol) - Return CreateSignatureHelpItems(accessibleConstructors.SelectAsArray( - Function(c) Convert(c, within, attribute, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)), + Return CreateSignatureHelpItems(accessibleConstructors.Select( + Function(c) Convert(c, within, attribute, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)).ToList(), textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), selectedItem, parameterIndexOverride:=-1) End Function @@ -110,7 +109,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim position = attribute.SpanStart Dim namedParameters = constructor.ContainingType.GetAttributeNamedParameters(semanticModel.Compilation, within). OrderBy(Function(s) s.Name). - ToImmutableArray() + ToList() Dim isVariadic = constructor.Parameters.Length > 0 AndAlso constructor.Parameters.Last().IsParams AndAlso namedParameters.Count = 0 @@ -127,13 +126,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Return item End Function - Private Shared Function GetParameters( - constructor As IMethodSymbol, - semanticModel As SemanticModel, - position As Integer, - namedParameters As ImmutableArray(Of ISymbol), - documentationCommentFormattingService As IDocumentationCommentFormattingService) As ImmutableArray(Of SignatureHelpSymbolParameter) - Dim result = ArrayBuilder(Of SignatureHelpSymbolParameter).GetInstance() + Private Shared Function GetParameters(constructor As IMethodSymbol, + semanticModel As SemanticModel, + position As Integer, + namedParameters As List(Of ISymbol), + documentationCommentFormattingService As IDocumentationCommentFormattingService) As IList(Of SignatureHelpSymbolParameter) + Dim result = New List(Of SignatureHelpSymbolParameter) For Each parameter In constructor.Parameters result.Add(Convert(parameter, semanticModel, position, documentationCommentFormattingService)) @@ -146,7 +144,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp DirectCast(namedParameter, IFieldSymbol).Type, DirectCast(namedParameter, IPropertySymbol).Type) - Dim displayParts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Dim displayParts = New List(Of SymbolDisplayPart) displayParts.Add(New SymbolDisplayPart( If(TypeOf namedParameter Is IFieldSymbol, SymbolDisplayPartKind.FieldName, SymbolDisplayPartKind.PropertyName), @@ -158,33 +156,34 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp namedParameter.Name, isOptional:=True, documentationFactory:=namedParameter.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), - displayParts:=displayParts.ToImmutableAndFree(), + displayParts:=displayParts, prefixDisplayParts:=GetParameterPrefixDisplayParts(i))) Next - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetParameterPrefixDisplayParts(i As Integer) As ImmutableArray(Of SymbolDisplayPart) + Private Shared Function GetParameterPrefixDisplayParts(i As Integer) As List(Of SymbolDisplayPart) If i = 0 Then - Return ImmutableArray.Create( + Return New List(Of SymbolDisplayPart) From { New SymbolDisplayPart(SymbolDisplayPartKind.Text, Nothing, FeaturesResources.Properties), Punctuation(SyntaxKind.ColonToken), - Space()) + Space() + } End If Return Nothing End Function - Private Shared Function GetPreambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetPreambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() result.AddRange(method.ContainingType.ToMinimalDisplayParts(semanticModel, position)) result.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetPostambleParts() As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create(Punctuation(SyntaxKind.CloseParenToken)) + Private Shared Function GetPostambleParts() As IList(Of SymbolDisplayPart) + Return {Punctuation(SyntaxKind.CloseParenToken)} End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/CollectionInitializerSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/CollectionInitializerSignatureHelpProvider.vb index 1f79cf7cb1ec2..56acafe0aa155 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/CollectionInitializerSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/CollectionInitializerSignatureHelpProvider.vb @@ -60,7 +60,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim semanticModel = Await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(False) Return CreateCollectionInitializerSignatureHelpItems( - addMethods.SelectAsArray(Function(s) ConvertMemberGroupMember(document, s, collectionInitializer.OpenBraceToken.SpanStart, semanticModel)), + addMethods.Select(Function(s) ConvertMemberGroupMember(document, s, collectionInitializer.OpenBraceToken.SpanStart, semanticModel)).ToList(), textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken)) End Function diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/FunctionAggregationSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/FunctionAggregationSignatureHelpProvider.vb index fe9493630613f..f99edead13eef 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/FunctionAggregationSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/FunctionAggregationSignatureHelpProvider.vb @@ -9,7 +9,6 @@ Imports Microsoft.CodeAnalysis.Collections Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -87,7 +86,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim syntaxFacts = document.GetLanguageService(Of ISyntaxFactsService) Return CreateSignatureHelpItems( - accessibleMethods.SelectAsArray(Function(m) Convert(m, functionAggregation, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)), + accessibleMethods.Select(Function(m) Convert(m, functionAggregation, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)).ToList(), textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), selectedItemIndex:=Nothing, parameterIndexOverride:=-1) End Function @@ -109,19 +108,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Return item End Function - Private Shared Function GetPreambleParts(method As IMethodSymbol) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetPreambleParts(method As IMethodSymbol) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() AddExtensionPreamble(method, result) result.AddMethodName(method.Name) result.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetPostambleParts( - method As IMethodSymbol, - semanticModel As SemanticModel, - position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim parts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetPostambleParts(method As IMethodSymbol, + semanticModel As SemanticModel, + position As Integer) As IList(Of SymbolDisplayPart) + Dim parts = New List(Of SymbolDisplayPart) parts.Add(Punctuation(SyntaxKind.CloseParenToken)) If Not method.ReturnsVoid Then @@ -131,17 +129,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parts.AddRange(method.ReturnType.ToMinimalDisplayParts(semanticModel, position)) End If - Return parts.ToImmutableAndFree() + Return parts End Function - Private Shared Function GetParameterParts( - method As IMethodSymbol, - semanticModel As SemanticModel, - position As Integer, - documentationCommentFormattingService As IDocumentationCommentFormattingService) As ImmutableArray(Of SignatureHelpSymbolParameter) + Private Shared Function GetParameterParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer, + documentationCommentFormattingService As IDocumentationCommentFormattingService) As IList(Of SignatureHelpSymbolParameter) ' Function () As If method.Parameters.Length <> 1 Then - Return ImmutableArray(Of SignatureHelpSymbolParameter).Empty + Return SpecializedCollections.EmptyList(Of SignatureHelpSymbolParameter)() End If ' Function (selector as Func(Of T, R)) As R @@ -153,7 +148,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp delegateInvokeMethod.Parameters.Length = 1 AndAlso Not delegateInvokeMethod.ReturnsVoid Then - Dim parts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Dim parts = New List(Of SymbolDisplayPart) parts.Add(Text(VBWorkspaceResources.expression)) parts.Add(Space()) parts.Add(Keyword(SyntaxKind.AsKeyword)) @@ -164,13 +159,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp VBWorkspaceResources.expression, parameter.IsOptional, parameter.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), - parts.ToImmutableAndFree()) + parts) - Return ImmutableArray.Create(sigHelpParameter) + Return {sigHelpParameter} End If End If - Return ImmutableArray(Of SignatureHelpSymbolParameter).Empty + Return SpecializedCollections.EmptyList(Of SignatureHelpSymbolParameter)() End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.Method.vb b/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.Method.vb index ee66f71255869..85fed14828d91 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.Method.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.Method.vb @@ -2,13 +2,12 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable -Imports Microsoft.CodeAnalysis.PooledObjects - Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp + Partial Friend Class GenericNameSignatureHelpProvider - Private Shared Function GetPreambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + + Private Shared Function GetPreambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() AddExtensionPreamble(method, result) @@ -23,7 +22,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp result.Add(Punctuation(SyntaxKind.OpenParenToken)) result.Add(Keyword(SyntaxKind.OfKeyword)) result.Add(Space()) - Return result.ToImmutableAndFree() + Return result End Function Private Shared Function GetContainingType(method As IMethodSymbol) As ITypeSymbol @@ -36,8 +35,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp End If End Function - Private Shared Function GetPostambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetPostambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() result.Add(Punctuation(SyntaxKind.CloseParenToken)) result.Add(Punctuation(SyntaxKind.OpenParenToken)) @@ -61,7 +60,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp result.AddRange(method.ReturnType.ToMinimalDisplayParts(semanticModel, position)) End If - Return result.ToImmutableAndFree() + Return result End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.NamedType.vb b/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.NamedType.vb index 4dc0f506b400b..48240e10b8756 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.NamedType.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.NamedType.vb @@ -2,15 +2,12 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable -Imports Microsoft.CodeAnalysis.PooledObjects - Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Partial Friend Class GenericNameSignatureHelpProvider - Private Shared Function GetPreambleParts(namedType As INamedTypeSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetPreambleParts(namedType As INamedTypeSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() Dim format = New SymbolDisplayFormat( memberOptions:=SymbolDisplayMemberOptions.IncludeContainingType, miscellaneousOptions:=SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers Or SymbolDisplayMiscellaneousOptions.UseSpecialTypes) @@ -18,11 +15,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp result.Add(Punctuation(SyntaxKind.OpenParenToken)) result.Add(Keyword(SyntaxKind.OfKeyword)) result.Add(Space()) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetPostambleParts() As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create(Punctuation(SyntaxKind.CloseParenToken)) + Private Shared Function GetPostambleParts() As IList(Of SymbolDisplayPart) + Return {Punctuation(SyntaxKind.CloseParenToken)} End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.vb index ca768d60b3ed0..1650b1b6f6865 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/GenericNameSignatureHelpProvider.vb @@ -8,7 +8,6 @@ Imports System.Threading Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -108,7 +107,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim _syntaxFacts = document.GetLanguageService(Of ISyntaxFactsService) Return CreateSignatureHelpItems( - accessibleSymbols.SelectAsArray(Function(s) Convert(s, genericName, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)), + accessibleSymbols.Select(Function(s) Convert(s, genericName, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)).ToList(), textSpan, GetCurrentArgumentState(root, position, _syntaxFacts, textSpan, cancellationToken), selectedItemIndex:=Nothing, parameterIndexOverride:=-1) End Function @@ -125,7 +124,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp GetPreambleParts(namedType, semanticModel, position), GetSeparatorParts(), GetPostambleParts(), - namedType.TypeParameters.SelectAsArray(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService))) + namedType.TypeParameters.Select(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList()) Else Dim method = DirectCast(symbol, IMethodSymbol) item = CreateItem( @@ -136,7 +135,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp GetPreambleParts(method, semanticModel, position), GetSeparatorParts(), GetPostambleParts(method, semanticModel, position), - method.TypeParameters.SelectAsArray(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService))) + method.TypeParameters.Select(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList()) End If Return item @@ -145,7 +144,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Private Shared ReadOnly s_minimallyQualifiedFormat As SymbolDisplayFormat = SymbolDisplayFormat.MinimallyQualifiedFormat.WithGenericsOptions(SymbolDisplayFormat.MinimallyQualifiedFormat.GenericsOptions Or SymbolDisplayGenericsOptions.IncludeVariance) Private Overloads Shared Function Convert(parameter As ITypeParameterSymbol, semanticModel As SemanticModel, position As Integer, documentationCommentFormattingService As IDocumentationCommentFormattingService) As SignatureHelpSymbolParameter - Dim parts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Dim parts = New List(Of SymbolDisplayPart) parts.AddRange(parameter.ToMinimalDisplayParts(semanticModel, position, s_minimallyQualifiedFormat)) AddConstraints(parameter, parts, semanticModel, position) @@ -153,14 +152,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parameter.Name, isOptional:=False, documentationFactory:=parameter.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), - displayParts:=parts.ToImmutableAndFree()) + displayParts:=parts) End Function - Private Shared Sub AddConstraints( - typeParam As ITypeParameterSymbol, - parts As ArrayBuilder(Of SymbolDisplayPart), - semanticModel As SemanticModel, - position As Integer) + Private Shared Function AddConstraints(typeParam As ITypeParameterSymbol, + parts As List(Of SymbolDisplayPart), + semanticModel As SemanticModel, + position As Integer) As IList(Of SymbolDisplayPart) Dim constraintTypes = typeParam.ConstraintTypes Dim constraintCount = TypeParameterSpecialConstraintCount(typeParam) + constraintTypes.Length @@ -205,7 +203,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parts.Add(Punctuation(SyntaxKind.CloseBraceToken)) End If End If - End Sub + + Return parts + End Function Private Shared Function TypeParameterSpecialConstraintCount(typeParam As ITypeParameterSymbol) As Integer Return If(typeParam.HasReferenceTypeConstraint, 1, 0) + diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.DelegateInvoke.vb b/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.DelegateInvoke.vb index 3452cd42c4323..bb409778cc4fd 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.DelegateInvoke.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.DelegateInvoke.vb @@ -2,12 +2,10 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports System.Threading Imports Microsoft.CodeAnalysis.Collections Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -39,8 +37,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Return SpecializedCollections.SingletonEnumerable(item) End Function - Private Shared Function GetDelegateInvokePreambleParts(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim displayParts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetDelegateInvokePreambleParts(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim displayParts = New List(Of SymbolDisplayPart)() If invokeMethod.ContainingType.IsAnonymousType Then displayParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.MethodName, invokeMethod, invokeMethod.Name)) @@ -49,11 +47,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp End If displayParts.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return displayParts.ToImmutableAndFree() + Return displayParts End Function - Private Shared Function GetDelegateInvokeParameters(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer, documentationCommentFormattingService As IDocumentationCommentFormattingService, cancellationToken As CancellationToken) As ImmutableArray(Of SignatureHelpSymbolParameter) - Dim parameters = ArrayBuilder(Of SignatureHelpSymbolParameter).GetInstance() + Private Shared Function GetDelegateInvokeParameters(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer, documentationCommentFormattingService As IDocumentationCommentFormattingService, cancellationToken As CancellationToken) As IList(Of SignatureHelpSymbolParameter) + Dim parameters = New List(Of SignatureHelpSymbolParameter) For Each parameter In invokeMethod.Parameters cancellationToken.ThrowIfCancellationRequested() parameters.Add(New SignatureHelpSymbolParameter( @@ -63,14 +61,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp displayParts:=parameter.ToMinimalDisplayParts(semanticModel, position))) Next - Return parameters.ToImmutableAndFree() + Return parameters End Function - Private Shared Function GetDelegateInvokePostambleParts( - invokeMethod As IMethodSymbol, - semanticModel As SemanticModel, - position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim parts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetDelegateInvokePostambleParts(invokeMethod As IMethodSymbol, + semanticModel As SemanticModel, + position As Integer) As IList(Of SymbolDisplayPart) + Dim parts = New List(Of SymbolDisplayPart) parts.Add(Punctuation(SyntaxKind.CloseParenToken)) @@ -81,7 +78,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parts.AddRange(invokeMethod.ReturnType.ToMinimalDisplayParts(semanticModel, position)) End If - Return parts.ToImmutableAndFree() + Return parts End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.ElementAccess.vb b/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.ElementAccess.vb index e0a4a95021851..3fc0bbf04f980 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.ElementAccess.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.ElementAccess.vb @@ -2,12 +2,10 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports System.Threading Imports Microsoft.CodeAnalysis.Collections Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -15,14 +13,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Partial Friend Class InvocationExpressionSignatureHelpProvider - Private Shared Function GetElementAccessItems( - leftExpression As ExpressionSyntax, - semanticModel As SemanticModel, - structuralTypeDisplayService As IStructuralTypeDisplayService, - documentationCommentFormattingService As IDocumentationCommentFormattingService, - within As ISymbol, - defaultProperties As ImmutableArray(Of IPropertySymbol), - cancellationToken As CancellationToken) As IEnumerable(Of SignatureHelpItem) + Private Shared Function GetElementAccessItems(leftExpression As ExpressionSyntax, + semanticModel As SemanticModel, + structuralTypeDisplayService As IStructuralTypeDisplayService, + documentationCommentFormattingService As IDocumentationCommentFormattingService, + within As ISymbol, + defaultProperties As IList(Of IPropertySymbol), + cancellationToken As CancellationToken) As IEnumerable(Of SignatureHelpItem) Dim throughType As ITypeSymbol = Nothing If leftExpression IsNot Nothing Then throughType = semanticModel.GetTypeInfo(leftExpression, cancellationToken).Type @@ -50,22 +47,21 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp GetIndexerPreambleParts(indexer, semanticModel, position), GetSeparatorParts(), GetIndexerPostambleParts(indexer, semanticModel, position), - indexer.Parameters.SelectAsArray(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService))) + indexer.Parameters.Select(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList()) Return item End Function - Private Shared Function GetIndexerPreambleParts(symbol As IPropertySymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetIndexerPreambleParts(symbol As IPropertySymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() result.AddRange(symbol.ContainingType.ToMinimalDisplayParts(semanticModel, position)) result.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetIndexerPostambleParts( - symbol As IPropertySymbol, - semanticModel As SemanticModel, - position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim parts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetIndexerPostambleParts(symbol As IPropertySymbol, + semanticModel As SemanticModel, + position As Integer) As IList(Of SymbolDisplayPart) + Dim parts = New List(Of SymbolDisplayPart) parts.Add(Punctuation(SyntaxKind.CloseParenToken)) Dim [property] = DirectCast(symbol, IPropertySymbol) @@ -75,7 +71,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parts.Add(Space()) parts.AddRange([property].Type.ToMinimalDisplayParts(semanticModel, position)) - Return parts.ToImmutableAndFree() + Return parts End Function + End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.vb index 1d97feed90612..4d223d56bf7a3 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/InvocationExpressionSignatureHelpProvider.vb @@ -9,7 +9,6 @@ Imports Microsoft.CodeAnalysis.Collections Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -102,18 +101,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim expressionType = If(typeInfo.Type, typeInfo.ConvertedType) Dim defaultProperties = If(expressionType Is Nothing, - ImmutableArray(Of IPropertySymbol).Empty, - semanticModel.LookupSymbols(position, expressionType, includeReducedExtensionMethods:=True). - OfType(Of IPropertySymbol). - ToImmutableArrayOrEmpty(). - WhereAsArray(Function(p) p.IsIndexer). - FilterToVisibleAndBrowsableSymbolsAndNotUnsafeSymbols(options.HideAdvancedMembers, semanticModel.Compilation). - Sort(semanticModel, invocationExpression.SpanStart)) + SpecializedCollections.EmptyList(Of IPropertySymbol), + semanticModel.LookupSymbols(position, expressionType, includeReducedExtensionMethods:=True). + OfType(Of IPropertySymbol). + ToImmutableArrayOrEmpty(). + WhereAsArray(Function(p) p.IsIndexer). + FilterToVisibleAndBrowsableSymbolsAndNotUnsafeSymbols(options.HideAdvancedMembers, semanticModel.Compilation). + Sort(semanticModel, invocationExpression.SpanStart)) Dim structuralTypeDisplayService = document.GetLanguageService(Of IStructuralTypeDisplayService)() Dim documentationCommentFormattingService = document.GetLanguageService(Of IDocumentationCommentFormattingService)() - Dim items = ArrayBuilder(Of SignatureHelpItem).GetInstance() + Dim items = New List(Of SignatureHelpItem) Dim accessibleMembers = ImmutableArray(Of ISymbol).Empty If memberGroup.Length > 0 Then accessibleMembers = GetAccessibleMembers(invocationExpression, semanticModel, within, memberGroup, cancellationToken) @@ -133,7 +132,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim selectedItem = TryGetSelectedIndex(accessibleMembers, symbolInfo.Symbol) Return CreateSignatureHelpItems( - items.ToImmutableAndFree(), textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), + items, textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), selectedItem, parameterIndexOverride:=-1) End Function End Class diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.DelegateType.vb b/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.DelegateType.vb index dadbe719e489a..8936e239cec80 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.DelegateType.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.DelegateType.vb @@ -2,22 +2,21 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis.Collections Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp + Partial Friend Class ObjectCreationExpressionSignatureHelpProvider - Private Shared Function GetDelegateTypeConstructors( - objectCreationExpression As ObjectCreationExpressionSyntax, - semanticModel As SemanticModel, - structuralTypeDisplayService As IStructuralTypeDisplayService, - documentationCommentFormattingService As IDocumentationCommentFormattingService, - delegateType As INamedTypeSymbol) As (items As ImmutableArray(Of SignatureHelpItem), selectedItem As Integer?) + + Private Shared Function GetDelegateTypeConstructors(objectCreationExpression As ObjectCreationExpressionSyntax, + semanticModel As SemanticModel, + structuralTypeDisplayService As IStructuralTypeDisplayService, + documentationCommentFormattingService As IDocumentationCommentFormattingService, + delegateType As INamedTypeSymbol) As (items As IList(Of SignatureHelpItem), selectedItem As Integer?) Dim invokeMethod = delegateType.DelegateInvokeMethod If invokeMethod Is Nothing Then Return (Nothing, Nothing) @@ -34,20 +33,20 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp suffixParts:=GetDelegateTypePostambleParts(), parameters:=GetDelegateTypeParameters(invokeMethod, semanticModel, position)) - Return (ImmutableArray.Create(item), 0) + Return (SpecializedCollections.SingletonList(item), 0) End Function - Private Shared Function GetDelegateTypePreambleParts(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetDelegateTypePreambleParts(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() result.AddRange(invokeMethod.ContainingType.ToMinimalDisplayParts(semanticModel, position)) result.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetDelegateTypeParameters(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SignatureHelpSymbolParameter) + Private Shared Function GetDelegateTypeParameters(invokeMethod As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SignatureHelpSymbolParameter) Const TargetName As String = "target" - Dim parts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Dim parts = New List(Of SymbolDisplayPart)() If invokeMethod.ReturnsVoid Then parts.Add(Keyword(SyntaxKind.SubKeyword)) @@ -78,15 +77,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp parts.AddRange(invokeMethod.ReturnType.ToMinimalDisplayParts(semanticModel, position)) End If - Return ImmutableArray.Create(New SignatureHelpSymbolParameter( + Return {New SignatureHelpSymbolParameter( TargetName, isOptional:=False, documentationFactory:=Nothing, - displayParts:=parts.ToImmutableAndFree())) + displayParts:=parts)} End Function - Private Shared Function GetDelegateTypePostambleParts() As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create(Punctuation(SyntaxKind.CloseParenToken)) + Private Shared Function GetDelegateTypePostambleParts() As IList(Of SymbolDisplayPart) + Return {Punctuation(SyntaxKind.CloseParenToken)} End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.NormalType.vb b/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.NormalType.vb index c1be3d8a9637c..f2b58e7f0026d 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.NormalType.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.NormalType.vb @@ -2,12 +2,10 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports System.Threading Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -22,7 +20,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp structuralTypeDisplayService As IStructuralTypeDisplayService, normalType As INamedTypeSymbol, within As ISymbol, - options As MemberDisplayOptions, cancellationToken As CancellationToken) As (items As ImmutableArray(Of SignatureHelpItem), selectedItem As Integer?) + options As MemberDisplayOptions, cancellationToken As CancellationToken) As (items As IList(Of SignatureHelpItem), selectedItem As Integer?) Dim accessibleConstructors = normalType.InstanceConstructors. WhereAsArray(Function(c) c.IsAccessibleWithin(within)). @@ -35,8 +33,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim documentationCommentFormattingService = document.GetLanguageService(Of IDocumentationCommentFormattingService)() - Dim items = accessibleConstructors.SelectAsArray( - Function(c) ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)) + Dim items = accessibleConstructors.Select( + Function(c) ConvertNormalTypeConstructor(c, objectCreationExpression, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)).ToList() Dim currentConstructor = semanticModel.GetSymbolInfo(objectCreationExpression, cancellationToken) Dim selectedItem = TryGetSelectedIndex(accessibleConstructors, currentConstructor.Symbol) @@ -55,19 +53,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp constructor.GetDocumentationPartsFactory(semanticModel, position, documentationCommentFormattingService), GetNormalTypePreambleParts(constructor, semanticModel, position), GetSeparatorParts(), GetNormalTypePostambleParts(), - constructor.Parameters.SelectAsArray(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService))) + constructor.Parameters.Select(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList()) Return item End Function - Private Shared Function GetNormalTypePreambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As ImmutableArray(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Private Shared Function GetNormalTypePreambleParts(method As IMethodSymbol, semanticModel As SemanticModel, position As Integer) As IList(Of SymbolDisplayPart) + Dim result = New List(Of SymbolDisplayPart)() result.AddRange(method.ContainingType.ToMinimalDisplayParts(semanticModel, position)) result.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetNormalTypePostambleParts() As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create(Punctuation(SyntaxKind.CloseParenToken)) + Private Shared Function GetNormalTypePostambleParts() As IList(Of SymbolDisplayPart) + Return {Punctuation(SyntaxKind.CloseParenToken)} End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/RaiseEventStatementSignatureHelpProvider.vb b/src/Features/VisualBasic/Portable/SignatureHelp/RaiseEventStatementSignatureHelpProvider.vb index d76944bac93c4..acfbe505a74ca 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/RaiseEventStatementSignatureHelpProvider.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/RaiseEventStatementSignatureHelpProvider.vb @@ -8,7 +8,6 @@ Imports System.Threading Imports Microsoft.CodeAnalysis.DocumentationComments Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.LanguageService -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.SignatureHelp Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax @@ -94,7 +93,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp Dim syntaxFacts = document.GetLanguageService(Of ISyntaxFactsService) Return CreateSignatureHelpItems( - allowedEvents.SelectAsArray(Function(e) Convert(e, raiseEventStatement, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)), + allowedEvents.Select(Function(e) Convert(e, raiseEventStatement, semanticModel, structuralTypeDisplayService, documentationCommentFormattingService)).ToList(), textSpan, GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken), selectedItemIndex:=Nothing, parameterIndexOverride:=-1) End Function @@ -118,17 +117,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp GetPreambleParts(eventSymbol, semanticModel, position), GetSeparatorParts(), GetPostambleParts(), - type.DelegateInvokeMethod.GetParameters().SelectAsArray(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService))) + type.DelegateInvokeMethod.GetParameters().Select(Function(p) Convert(p, semanticModel, position, documentationCommentFormattingService)).ToList()) Return item End Function Private Shared Function GetPreambleParts( - eventSymbol As IEventSymbol, - semanticModel As SemanticModel, - position As Integer) As ImmutableArray(Of SymbolDisplayPart) + eventSymbol As IEventSymbol, + semanticModel As SemanticModel, + position As Integer + ) As IList(Of SymbolDisplayPart) - Dim result = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Dim result = New List(Of SymbolDisplayPart)() result.AddRange(eventSymbol.ContainingType.ToMinimalDisplayParts(semanticModel, position)) result.Add(Punctuation(SyntaxKind.DotToken)) @@ -140,11 +140,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp result.AddRange(eventSymbol.ToMinimalDisplayParts(semanticModel, position, format)) result.Add(Punctuation(SyntaxKind.OpenParenToken)) - Return result.ToImmutableAndFree() + Return result End Function - Private Shared Function GetPostambleParts() As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create(Punctuation(SyntaxKind.CloseParenToken)) + Private Shared Function GetPostambleParts() As IList(Of SymbolDisplayPart) + Return {Punctuation(SyntaxKind.CloseParenToken)} End Function End Class End Namespace diff --git a/src/Features/VisualBasic/Portable/SignatureHelp/SignatureHelpUtilities.vb b/src/Features/VisualBasic/Portable/SignatureHelp/SignatureHelpUtilities.vb index 584acf78a4887..816a7fcb4e0b6 100644 --- a/src/Features/VisualBasic/Portable/SignatureHelp/SignatureHelpUtilities.vb +++ b/src/Features/VisualBasic/Portable/SignatureHelp/SignatureHelpUtilities.vb @@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp + Friend Module SignatureHelpUtilities Private ReadOnly s_getArgumentListOpenToken As Func(Of ArgumentListSyntax, SyntaxToken) = Function(list) list.OpenParenToken Private ReadOnly s_getTypeArgumentListOpenToken As Func(Of TypeArgumentListSyntax, SyntaxToken) = Function(list) list.OpenParenToken diff --git a/src/VisualStudio/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs b/src/VisualStudio/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs index c6a503f7769c9..6c4fd7505e3c2 100644 --- a/src/VisualStudio/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs +++ b/src/VisualStudio/ExternalAccess/FSharp/Internal/SignatureHelp/FSharpSignatureHelpProvider.cs @@ -5,12 +5,12 @@ using System; using System.Collections.Immutable; using System.Composition; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.ExternalAccess.FSharp.SignatureHelp; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.SignatureHelp; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.FSharp.Internal.SignatureHelp; @@ -61,23 +61,23 @@ public FSharpSignatureHelpProvider( if (mappedSignatureHelpItems != null) { return new SignatureHelpItems( - mappedSignatureHelpItems.Items.SelectAsArray(x => + mappedSignatureHelpItems.Items.Select(x => new SignatureHelpItem( x.IsVariadic, x.DocumentationFactory, x.PrefixDisplayParts, x.SeparatorDisplayParts, x.SuffixDisplayParts, - x.Parameters.SelectAsArray(y => + x.Parameters.Select(y => new SignatureHelpParameter( y.Name, y.IsOptional, y.DocumentationFactory, - y.DisplayParts.ToImmutableArrayOrEmpty(), - y.PrefixDisplayParts.ToImmutableArrayOrEmpty(), - y.SuffixDisplayParts.ToImmutableArrayOrEmpty(), - y.SelectedDisplayParts.ToImmutableArrayOrEmpty())), - x.DescriptionParts)), + y.DisplayParts, + y.PrefixDisplayParts, + y.SuffixDisplayParts, + y.SelectedDisplayParts)).ToList(), + x.DescriptionParts)).ToList(), mappedSignatureHelpItems.ApplicableSpan, mappedSignatureHelpItems.ArgumentIndex, mappedSignatureHelpItems.ArgumentCount, diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolDisplayPartExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolDisplayPartExtensions.cs index 17060dc98905f..b52deb8b4fcdc 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolDisplayPartExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SymbolDisplayPartExtensions.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis.Shared.Extensions; @@ -16,7 +15,7 @@ public static string GetFullText(this IEnumerable parts) public static void AddLineBreak(this IList parts, string text = "\r\n") => parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.LineBreak, null, text)); - public static void AddMethodName(this ArrayBuilder parts, string text) + public static void AddMethodName(this IList parts, string text) => parts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.MethodName, null, text)); public static void AddPunctuation(this IList parts, string text) diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AbstractIntrinsicOperatorDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AbstractIntrinsicOperatorDocumentation.vb index 0cce47cbe7700..07194defb4c6a 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AbstractIntrinsicOperatorDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AbstractIntrinsicOperatorDocumentation.vb @@ -2,10 +2,8 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports System.Threading Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.PooledObjects Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators @@ -21,20 +19,20 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Get End Property - Public MustOverride ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) + Public MustOverride ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) Public MustOverride Function GetParameterName(index As Integer) As String Public MustOverride Function GetParameterDocumentation(index As Integer) As String - Public Overridable Function GetParameterDisplayParts(index As Integer) As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create(New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, GetParameterName(index))) + Public Overridable Function GetParameterDisplayParts(index As Integer) As IList(Of SymbolDisplayPart) + Return {New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, GetParameterName(index))} End Function Public Overridable Function TryGetTypeNameParameter(syntaxNode As SyntaxNode, index As Integer) As TypeSyntax Return Nothing End Function - Public Overridable Function GetSuffix(semanticModel As SemanticModel, position As Integer, nodeToBind As SyntaxNode, cancellationToken As CancellationToken) As ImmutableArray(Of SymbolDisplayPart) - Dim suffixParts = ArrayBuilder(Of SymbolDisplayPart).GetInstance() + Public Overridable Function GetSuffix(semanticModel As SemanticModel, position As Integer, nodeToBind As SyntaxNode, cancellationToken As CancellationToken) As IList(Of SymbolDisplayPart) + Dim suffixParts As New List(Of SymbolDisplayPart) If IncludeAsType Then suffixParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, ")")) @@ -46,7 +44,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Dim typeInfo = semanticModel.GetTypeInfo(nodeToBind, cancellationToken) If typeInfo.Type IsNot Nothing Then suffixParts.AddRange(typeInfo.Type.ToMinimalDisplayParts(semanticModel, position)) - Return suffixParts.ToImmutableAndFree() + Return suffixParts End If End If @@ -60,13 +58,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators suffixParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.Text, Nothing, ReturnTypeMetadataName)) End If - Return suffixParts.ToImmutableAndFree() + Return suffixParts End If suffixParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.Text, Nothing, VBWorkspaceResources.result)) End If - Return suffixParts.ToImmutableAndFree() + Return suffixParts End Function End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AddHandlerStatementDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AddHandlerStatementDocumentation.vb index 9ec15860e71af..bec3592ac4431 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AddHandlerStatementDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/AddHandlerStatementDocumentation.vb @@ -2,14 +2,15 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class AddHandlerStatementDocumentation Inherits AbstractAddRemoveHandlerStatementDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.Associates_an_event_with_an_event_handler_delegate_or_lambda_expression_at_run_time + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.Associates_an_event_with_an_event_handler_delegate_or_lambda_expression_at_run_time + End Get + End Property Public Overrides Function GetParameterDocumentation(index As Integer) As String Select Case index @@ -22,9 +23,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "AddHandler"), - New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " ")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "AddHandler"), + New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " ")} + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/BinaryConditionalExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/BinaryConditionalExpressionDocumentation.vb index 89ea2262e8d8f..afb48f4e935f7 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/BinaryConditionalExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/BinaryConditionalExpressionDocumentation.vb @@ -2,14 +2,15 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class BinaryConditionalExpressionDocumentation Inherits AbstractIntrinsicOperatorDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.If_expression_evaluates_to_a_reference_or_Nullable_value_that_is_not_Nothing_the_function_returns_that_value_Otherwise_it_calculates_and_returns_expressionIfNothing + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.If_expression_evaluates_to_a_reference_or_Nullable_value_that_is_not_Nothing_the_function_returns_that_value_Otherwise_it_calculates_and_returns_expressionIfNothing + End Get + End Property Public Overrides Function GetParameterDocumentation(index As Integer) As String Select Case index @@ -33,12 +34,23 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property IncludeAsType As Boolean = True - - Public Overrides ReadOnly Property ParameterCount As Integer = 2 - - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "If"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property IncludeAsType As Boolean + Get + Return True + End Get + End Property + + Public Overrides ReadOnly Property ParameterCount As Integer + Get + Return 2 + End Get + End Property + + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "If"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")} + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/CTypeCastExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/CTypeCastExpressionDocumentation.vb index 97a175782454e..0706915921c40 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/CTypeCastExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/CTypeCastExpressionDocumentation.vb @@ -2,17 +2,23 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class CTypeCastExpressionDocumentation Inherits AbstractCastExpressionDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.Returns_the_result_of_explicitly_converting_an_expression_to_a_specified_data_type + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.Returns_the_result_of_explicitly_converting_an_expression_to_a_specified_data_type + End Get + End Property - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "CType"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return { + New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "CType"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(") + } + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/DirectCastExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/DirectCastExpressionDocumentation.vb index c036a33d36c04..5233f539329f1 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/DirectCastExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/DirectCastExpressionDocumentation.vb @@ -2,17 +2,23 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class DirectCastExpressionDocumentation Inherits AbstractCastExpressionDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.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 + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.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 + End Get + End Property - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "DirectCast"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return { + New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "DirectCast"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(") + } + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetTypeExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetTypeExpressionDocumentation.vb index 41202eac35a56..333c15ae53834 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetTypeExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetTypeExpressionDocumentation.vb @@ -2,7 +2,6 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators @@ -27,16 +26,32 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property ParameterCount As Integer = 1 + Public Overrides ReadOnly Property ParameterCount As Integer + Get + Return 1 + End Get + End Property - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.Returns_a_System_Type_object_for_the_specified_type_name + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.Returns_a_System_Type_object_for_the_specified_type_name + End Get + End Property - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "GetType"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return { + New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "GetType"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(") + } + End Get + End Property - Public Overrides ReadOnly Property IncludeAsType As Boolean = True + Public Overrides ReadOnly Property IncludeAsType As Boolean + Get + Return True + End Get + End Property Public Overrides Function TryGetTypeNameParameter(syntaxNode As SyntaxNode, index As Integer) As TypeSyntax Dim getTypeExpression = TryCast(syntaxNode, GetTypeExpressionSyntax) @@ -48,6 +63,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End If End Function - Public Overrides ReadOnly Property ReturnTypeMetadataName As String = "System.Type" + Public Overrides ReadOnly Property ReturnTypeMetadataName As String + Get + Return "System.Type" + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetXmlNamespaceExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetXmlNamespaceExpressionDocumentation.vb index f4637306c4b54..bca09bb0edfd8 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetXmlNamespaceExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/GetXmlNamespaceExpressionDocumentation.vb @@ -2,19 +2,18 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class GetXmlNamespaceExpressionDocumentation Inherits AbstractIntrinsicOperatorDocumentation - Public Overrides Function GetParameterDisplayParts(index As Integer) As ImmutableArray(Of SymbolDisplayPart) + Public Overrides Function GetParameterDisplayParts(index As Integer) As IList(Of SymbolDisplayPart) Select Case index Case 0 - Return ImmutableArray.Create( + Return { New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "["), New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, GetParameterName(index)), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "]")) + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "]") + } Case Else Throw New ArgumentException(NameOf(index)) End Select @@ -38,17 +37,37 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property ParameterCount As Integer = 1 + Public Overrides ReadOnly Property ParameterCount As Integer + Get + Return 1 + End Get + End Property - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.Returns_the_System_Xml_Linq_XNamespace_object_corresponding_to_the_specified_XML_namespace_prefix + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.Returns_the_System_Xml_Linq_XNamespace_object_corresponding_to_the_specified_XML_namespace_prefix + End Get + End Property - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "GetXmlNamespace"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return { + New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "GetXmlNamespace"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(") + } + End Get + End Property - Public Overrides ReadOnly Property IncludeAsType As Boolean = True + Public Overrides ReadOnly Property IncludeAsType As Boolean + Get + Return True + End Get + End Property - Public Overrides ReadOnly Property ReturnTypeMetadataName As String = "System.Xml.Linq.XNamespace" + Public Overrides ReadOnly Property ReturnTypeMetadataName As String + Get + Return "System.Xml.Linq.XNamespace" + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/MidAssignmentDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/MidAssignmentDocumentation.vb index 48d1960c0c21b..d3323a51a2272 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/MidAssignmentDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/MidAssignmentDocumentation.vb @@ -2,15 +2,17 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable Imports System.Threading Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class MidAssignmentDocumentation Inherits AbstractIntrinsicOperatorDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.Replaces_a_specified_number_of_characters_in_a_String_variable_with_characters_from_another_string + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.Replaces_a_specified_number_of_characters_in_a_String_variable_with_characters_from_another_string + End Get + End Property Public Overrides Function GetParameterDocumentation(index As Integer) As String Select Case index @@ -38,29 +40,41 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides Function GetParameterDisplayParts(index As Integer) As ImmutableArray(Of SymbolDisplayPart) + Public Overrides Function GetParameterDisplayParts(index As Integer) As IList(Of SymbolDisplayPart) If index = 2 Then - Return ImmutableArray.Create(New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, "[" + GetParameterName(2) + "]")) + Return {New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, "[" + GetParameterName(2) + "]")} Else Return MyBase.GetParameterDisplayParts(index) End If End Function - Public Overrides ReadOnly Property IncludeAsType As Boolean = False + Public Overrides ReadOnly Property IncludeAsType As Boolean + Get + Return False + End Get + End Property - Public Overrides ReadOnly Property ParameterCount As Integer = 3 + Public Overrides ReadOnly Property ParameterCount As Integer + Get + Return 3 + End Get + End Property - Public Overrides Function GetSuffix(semanticModel As SemanticModel, position As Integer, nodeToBind As SyntaxNode, cancellationToken As CancellationToken) As ImmutableArray(Of SymbolDisplayPart) - Return ImmutableArray.Create( + Public Overrides Function GetSuffix(semanticModel As SemanticModel, position As Integer, nodeToBind As SyntaxNode, cancellationToken As CancellationToken) As IList(Of SymbolDisplayPart) + Return { New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, ")"), New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " "), New SymbolDisplayPart(SymbolDisplayPartKind.Operator, Nothing, "="), New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " "), - New SymbolDisplayPart(SymbolDisplayPartKind.Text, Nothing, VBWorkspaceResources.stringExpression)) + New SymbolDisplayPart(SymbolDisplayPartKind.Text, Nothing, VBWorkspaceResources.stringExpression) + } End Function - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "Mid"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "Mid"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")} + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/NameOfExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/NameOfExpressionDocumentation.vb index 40c585805afc1..30f466aa2aeb2 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/NameOfExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/NameOfExpressionDocumentation.vb @@ -2,22 +2,34 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class NameOfExpressionDocumentation Inherits AbstractIntrinsicOperatorDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.Produces_a_string_for_the_name_of_the_specified_type_or_member - - Public Overrides ReadOnly Property IncludeAsType As Boolean = True - - Public Overrides ReadOnly Property ParameterCount As Integer = 1 - - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "NameOf"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.Produces_a_string_for_the_name_of_the_specified_type_or_member + End Get + End Property + + Public Overrides ReadOnly Property IncludeAsType As Boolean + Get + Return True + End Get + End Property + + Public Overrides ReadOnly Property ParameterCount As Integer + Get + Return 1 + End Get + End Property + + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "NameOf"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")} + End Get + End Property Public Overrides Function GetParameterDocumentation(index As Integer) As String Select Case index @@ -37,6 +49,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property ReturnTypeMetadataName As String = "System.String" + Public Overrides ReadOnly Property ReturnTypeMetadataName As String + Get + Return "System.String" + End Get + End Property + End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/PredefinedCastExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/PredefinedCastExpressionDocumentation.vb index 52189120ce26e..c558b64b8b5a3 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/PredefinedCastExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/PredefinedCastExpressionDocumentation.vb @@ -2,8 +2,6 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class PredefinedCastExpressionDocumentation Inherits AbstractIntrinsicOperatorDocumentation @@ -40,15 +38,22 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property IncludeAsType As Boolean = True + Public Overrides ReadOnly Property IncludeAsType As Boolean + Get + Return True + End Get + End Property - Public Overrides ReadOnly Property ParameterCount As Integer = 1 + Public Overrides ReadOnly Property ParameterCount As Integer + Get + Return 1 + End Get + End Property - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) Get - Return ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, _keywordText), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, _keywordText), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")} End Get End Property diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/RemoveHandlerStatementDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/RemoveHandlerStatementDocumentation.vb index 57938fc18d09d..17f497af4b0c0 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/RemoveHandlerStatementDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/RemoveHandlerStatementDocumentation.vb @@ -2,14 +2,15 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class RemoveHandlerStatementDocumentation Inherits AbstractAddRemoveHandlerStatementDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.Removes_the_association_between_an_event_and_an_event_handler_or_delegate_at_run_time + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.Removes_the_association_between_an_event_and_an_event_handler_or_delegate_at_run_time + End Get + End Property Public Overrides Function GetParameterDocumentation(index As Integer) As String Select Case index @@ -22,8 +23,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "RemoveHandler"), - New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " ")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "RemoveHandler"), + New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " ")} + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TernaryConditionalExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TernaryConditionalExpressionDocumentation.vb index 307e7c1dd5e67..bdcee3f9a58b6 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TernaryConditionalExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TernaryConditionalExpressionDocumentation.vb @@ -2,25 +2,25 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class TernaryConditionalExpressionDocumentation Inherits AbstractIntrinsicOperatorDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.If_condition_returns_True_the_function_calculates_and_returns_expressionIfTrue_Otherwise_it_returns_expressionIfFalse + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.If_condition_returns_True_the_function_calculates_and_returns_expressionIfTrue_Otherwise_it_returns_expressionIfFalse + End Get + End Property - Public Overrides Function GetParameterDisplayParts(index As Integer) As ImmutableArray(Of SymbolDisplayPart) + Public Overrides Function GetParameterDisplayParts(index As Integer) As IList(Of SymbolDisplayPart) If index = 0 Then - Return ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, GetParameterName(index)), - New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " "), - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "As"), - New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " "), - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "Boolean")) + Return {New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, GetParameterName(index)), + New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " "), + New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "As"), + New SymbolDisplayPart(SymbolDisplayPartKind.Space, Nothing, " "), + New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "Boolean")} Else - Return ImmutableArray.Create(New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, GetParameterName(index))) + Return {New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, GetParameterName(index))} End If End Function @@ -50,12 +50,23 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators End Select End Function - Public Overrides ReadOnly Property IncludeAsType As Boolean = True + Public Overrides ReadOnly Property IncludeAsType As Boolean + Get + Return True + End Get + End Property - Public Overrides ReadOnly Property ParameterCount As Integer = 3 + Public Overrides ReadOnly Property ParameterCount As Integer + Get + Return 3 + End Get + End Property - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "If"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "If"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")} + End Get + End Property End Class End Namespace diff --git a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TryCastExpressionDocumentation.vb b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TryCastExpressionDocumentation.vb index 154a906004fc4..1465a18832bcd 100644 --- a/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TryCastExpressionDocumentation.vb +++ b/src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/TryCastExpressionDocumentation.vb @@ -2,17 +2,23 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Collections.Immutable - Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators Friend NotInheritable Class TryCastExpressionDocumentation Inherits AbstractCastExpressionDocumentation - Public Overrides ReadOnly Property DocumentationText As String = - VBWorkspaceResources.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 + Public Overrides ReadOnly Property DocumentationText As String + Get + Return VBWorkspaceResources.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 + End Get + End Property - Public Overrides ReadOnly Property PrefixParts As ImmutableArray(Of SymbolDisplayPart) = ImmutableArray.Create( - New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "TryCast"), - New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")) + Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart) + Get + Return { + New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "TryCast"), + New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(") + } + End Get + End Property End Class End Namespace