diff --git a/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs b/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs
index 50c7c4155..1ed34dc96 100644
--- a/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs
+++ b/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs
@@ -25,7 +25,7 @@ internal static class AstOperations
{
// TODO: When netstandard is upgraded to 2.0, see if
// Delegate.CreateDelegate can be used here instead
- private static readonly MethodInfo s_extentCloneWithNewOffset = typeof(PSObject).GetTypeInfo().Assembly
+ private static readonly MethodInfo s_extentCloneWithNewOffset = typeof(PSObject).Assembly
.GetType("System.Management.Automation.Language.InternalScriptPosition")
.GetMethod("CloneWithNewOffset", BindingFlags.Instance | BindingFlags.NonPublic);
diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs
index 421f766a3..188a97ce3 100644
--- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs
+++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs
@@ -251,6 +251,8 @@ private static CompletionItem CreateCompletionItem(
switch (completionDetails.CompletionType)
{
+ case CompletionType.Type:
+ case CompletionType.Namespace:
case CompletionType.ParameterValue:
case CompletionType.Method:
case CompletionType.Property:
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteNamespace.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteNamespace.cs
new file mode 100644
index 000000000..5a0e3bb7c
--- /dev/null
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteNamespace.cs
@@ -0,0 +1,30 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
+namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
+{
+ internal class CompleteNamespace
+ {
+ public static readonly ScriptRegion SourceDetails =
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
+ text: string.Empty,
+ startLineNumber: 22,
+ startColumnNumber: 15,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
+
+ public static readonly CompletionDetails ExpectedCompletion =
+ CompletionDetails.Create(
+ "System.Collections",
+ CompletionType.Namespace,
+ "System.Collections"
+ );
+ }
+}
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompleteTypeName.cs b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteTypeName.cs
new file mode 100644
index 000000000..bcb2cda0c
--- /dev/null
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompleteTypeName.cs
@@ -0,0 +1,30 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+
+namespace Microsoft.PowerShell.EditorServices.Test.Shared.Completion
+{
+ internal class CompleteTypeName
+ {
+ public static readonly ScriptRegion SourceDetails =
+ new ScriptRegion(
+ file: TestUtilities.NormalizePath("Completion/CompletionExamples.psm1"),
+ text: string.Empty,
+ startLineNumber: 21,
+ startColumnNumber: 25,
+ startOffset: 0,
+ endLineNumber: 0,
+ endColumnNumber: 0,
+ endOffset: 0);
+
+ public static readonly CompletionDetails ExpectedCompletion =
+ CompletionDetails.Create(
+ "System.Collections.ArrayList",
+ CompletionType.Type,
+ "System.Collections.ArrayList"
+ );
+ }
+}
diff --git a/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1 b/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1
index ee3dd9098..a4ce41222 100644
--- a/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1
+++ b/test/PowerShellEditorServices.Test.Shared/Completion/CompletionExamples.psm1
@@ -17,3 +17,6 @@ function Test-Completion {
}
Get-ChildItem /
+
+[System.Collections.ArrayList].GetType()
+[System.Collect
diff --git a/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs b/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs
index 346fdd841..63e5a126d 100644
--- a/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs
+++ b/test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs
@@ -3,6 +3,18 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging.Abstractions;
+using Microsoft.PowerShell.EditorServices.Handlers;
+using Microsoft.PowerShell.EditorServices.Services;
+using Microsoft.PowerShell.EditorServices.Services.Symbols;
+using Microsoft.PowerShell.EditorServices.Services.TextDocument;
+using Microsoft.PowerShell.EditorServices.Test.Shared;
using Microsoft.PowerShell.EditorServices.Test.Shared.Completion;
using Microsoft.PowerShell.EditorServices.Test.Shared.Definition;
using Microsoft.PowerShell.EditorServices.Test.Shared.Occurrences;
@@ -10,18 +22,9 @@
using Microsoft.PowerShell.EditorServices.Test.Shared.References;
using Microsoft.PowerShell.EditorServices.Test.Shared.SymbolDetails;
using Microsoft.PowerShell.EditorServices.Test.Shared.Symbols;
-using System;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
+using Microsoft.PowerShell.EditorServices.Utility;
using Xunit;
-using Microsoft.PowerShell.EditorServices.Services;
-using Microsoft.Extensions.Logging.Abstractions;
-using Microsoft.PowerShell.EditorServices.Services.TextDocument;
-using Microsoft.PowerShell.EditorServices.Services.Symbols;
-using System.Collections.Generic;
-using Microsoft.PowerShell.EditorServices.Handlers;
-using System.Runtime.InteropServices;
+using Xunit.Abstractions;
namespace Microsoft.PowerShell.EditorServices.Test.Language
{
@@ -33,7 +36,7 @@ public class LanguageServiceTests : IDisposable
private readonly PowerShellContextService powerShellContext;
private static readonly string s_baseSharedScriptPath =
Path.Combine(
- Path.GetDirectoryName(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ Path.GetDirectoryName(VersionUtils.IsWindows
// On non-Windows platforms, CodeBase has file:// in it.
// On Windows, Location points to a temp directory.
? typeof(LanguageServiceTests).Assembly.CodeBase
@@ -92,6 +95,60 @@ await this.GetCompletionResults(
Assert.NotNull(completionResults.Completions[0].ToolTipText);
}
+ [Trait("Category", "Completions")]
+ [SkippableFact]
+ public async Task LanguageServiceCompletesTypeName()
+ {
+ Skip.If(
+ !VersionUtils.IsNetCore,
+ "Windows PowerShell return no results from CommandCompletion in the test harness. Since it works in PS7 and works manually when I run the extension, I'm skipping this test");
+
+ CompletionResults completionResults =
+ await this.GetCompletionResults(
+ CompleteTypeName.SourceDetails);
+
+ Assert.NotEmpty(completionResults.Completions);
+
+ Assert.Equal(
+ CompleteTypeName.ExpectedCompletion.CompletionText,
+ completionResults.Completions[0].CompletionText
+ );
+
+ Assert.Equal(
+ CompleteTypeName.ExpectedCompletion.CompletionType,
+ completionResults.Completions[0].CompletionType
+ );
+
+ Assert.NotNull(completionResults.Completions[0].ToolTipText);
+ }
+
+ [Trait("Category", "Completions")]
+ [SkippableFact]
+ public async Task LanguageServiceCompletesNamespace()
+ {
+ Skip.If(
+ !VersionUtils.IsNetCore,
+ "Windows PowerShell return no results from CommandCompletion in the test harness. Since it works in PS7 and works manually when I run the extension, I'm skipping this test");
+
+ CompletionResults completionResults =
+ await this.GetCompletionResults(
+ CompleteNamespace.SourceDetails);
+
+ Assert.NotEmpty(completionResults.Completions);
+
+ Assert.Equal(
+ CompleteNamespace.ExpectedCompletion.CompletionText,
+ completionResults.Completions[0].CompletionText
+ );
+
+ Assert.Equal(
+ CompleteNamespace.ExpectedCompletion.CompletionType,
+ completionResults.Completions[0].CompletionType
+ );
+
+ Assert.NotNull(completionResults.Completions[0].ToolTipText);
+ }
+
[Trait("Category", "Completions")]
[Fact]
public async Task LanguageServiceCompletesVariableInFile()
diff --git a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj
index 61ccf16d2..2d0796479 100644
--- a/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj
+++ b/test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj
@@ -3,6 +3,7 @@
net5.0;netcoreapp3.1;net461
Microsoft.PowerShell.EditorServices.Test
+ x64
true
@@ -28,6 +29,7 @@
+