diff --git a/.editorconfig b/.editorconfig
index 79e4abe9a..8ef84c135 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -116,11 +116,6 @@ dotnet_diagnostic.VSTHRD114.severity = error
# VSTHRD200: Use "Async" suffix for awaitable methods
dotnet_diagnostic.VSTHRD200.severity = silent
-# xUnit2013: Do not use equality check to check for collection size
-dotnet_diagnostic.xUnit2013.severity = error
-# xUnit1004: Test methods should not be skipped
-dotnet_diagnostic.xUnit1004.severity = suggestion
-
# IDE0001: Simplify name
dotnet_diagnostic.IDE0001.severity = error
# IDE0002: Simplify member access
diff --git a/src/PowerShellEditorServices/PowerShellEditorServices.csproj b/src/PowerShellEditorServices/PowerShellEditorServices.csproj
index 68111e381..fb66c0150 100644
--- a/src/PowerShellEditorServices/PowerShellEditorServices.csproj
+++ b/src/PowerShellEditorServices/PowerShellEditorServices.csproj
@@ -54,8 +54,8 @@
-
-
+
+
diff --git a/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs b/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs
index 909a1a2ba..cd45ec1e8 100644
--- a/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs
+++ b/src/PowerShellEditorServices/Services/TextDocument/FoldingReference.cs
@@ -58,22 +58,18 @@ public int CompareTo(FoldingReference that)
if (EndCharacter > that.EndCharacter) { return 1; }
// They're the same range, but what about kind
- if (Kind == null)
+ if (Kind == that.Kind)
{
- if (that.Kind == null)
- {
- return 0;
- }
- // that has a kind but this doesn't.
- return 1;
+ return 0;
}
- if (that.Kind != null)
+ // That has a kind but this doesn't.
+ if (Kind is null && that.Kind is not null)
{
- return that.Kind.Value - Kind.Value;
+ return 1;
}
- // this has a kind but that doesn't.
+ // This has a kind but that doesn't.
return -1;
}
diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs
index c6a24bc1b..f416d7615 100644
--- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs
+++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT License.
using System.Collections.Generic;
-using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
@@ -10,7 +9,6 @@
using Microsoft.PowerShell.EditorServices.Services.Symbols;
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
using Microsoft.PowerShell.EditorServices.Utility;
-using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
@@ -48,7 +46,6 @@ public override async Task Handle(Do
_logger.LogDebug($"Handling document symbols for {request.TextDocument.Uri}");
ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri);
- string containerName = Path.GetFileNameWithoutExtension(scriptFile.FilePath);
List symbols = new();
foreach (SymbolReference r in ProvideDocumentSymbols(scriptFile))
@@ -70,27 +67,15 @@ public override async Task Handle(Do
continue;
}
- // TODO: This should be a DocumentSymbol now as SymbolInformation is deprecated. But
- // this requires figuring out how to populate `children`. Once we do that, the range
- // can be NameRegion.
- //
- // symbols.Add(new SymbolInformationOrDocumentSymbol(new DocumentSymbol
- // {
- // Name = SymbolTypeUtils.GetDecoratedSymbolName(r),
- // Kind = SymbolTypeUtils.GetSymbolKind(r.SymbolType),
- // Range = r.ScriptRegion.ToRange(),
- // SelectionRange = r.NameRegion.ToRange()
- // }));
- symbols.Add(new SymbolInformationOrDocumentSymbol(new SymbolInformation
+ // TODO: This now needs the Children property filled out to support hierarchical
+ // symbols, and we don't have the information nor algorithm to do that currently.
+ // OmniSharp was previously doing this for us based on the range, perhaps we can
+ // find that logic and reuse it.
+ symbols.Add(new SymbolInformationOrDocumentSymbol(new DocumentSymbol
{
- ContainerName = containerName,
Kind = SymbolTypeUtils.GetSymbolKind(r.Type),
- Location = new Location
- {
- Uri = DocumentUri.From(r.FilePath),
- // Jump to name start, but keep whole range to support symbol tree in outline
- Range = new Range(r.NameRegion.ToRange().Start, r.ScriptRegion.ToRange().End)
- },
+ Range = r.ScriptRegion.ToRange(),
+ SelectionRange = r.NameRegion.ToRange(),
Name = r.Name
}));
}
diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs
index d9ece3db5..79af825ed 100644
--- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs
+++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs
@@ -61,7 +61,7 @@ public override Task Handle(DidChangeTextDocumentParams notification, Canc
return Unit.Task;
}
- protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(SynchronizationCapability capability, ClientCapabilities clientCapabilities)
+ protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(TextSynchronizationCapability capability, ClientCapabilities clientCapabilities)
{
_isFileWatcherSupported = clientCapabilities.Workspace.DidChangeWatchedFiles.IsSupported;
return new TextDocumentSyncRegistrationOptions()
diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs
index fa7f1d49a..040a4fe67 100644
--- a/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs
+++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs
@@ -19,7 +19,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers
{
internal class PsesWorkspaceSymbolsHandler : WorkspaceSymbolsHandlerBase
{
- private static readonly Container s_emptySymbolInformationContainer = new();
+ private static readonly Container s_emptySymbolInformationContainer = new();
private readonly ILogger _logger;
private readonly SymbolsService _symbolsService;
private readonly WorkspaceService _workspaceService;
@@ -33,12 +33,12 @@ public PsesWorkspaceSymbolsHandler(ILoggerFactory loggerFactory, SymbolsService
protected override WorkspaceSymbolRegistrationOptions CreateRegistrationOptions(WorkspaceSymbolCapability capability, ClientCapabilities clientCapabilities) => new() { };
- public override async Task> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken)
+ public override async Task> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken)
{
_logger.LogDebug($"Handling workspace symbols request for query {request.Query}");
await _symbolsService.ScanWorkspacePSFiles(cancellationToken).ConfigureAwait(false);
- List symbols = new();
+ List symbols = new();
foreach (ScriptFile scriptFile in _workspaceService.GetOpenedFiles())
{
@@ -84,8 +84,7 @@ public override async Task> Handle(WorkspaceSymbolP
Range = symbol.NameRegion.ToRange()
};
- // TODO: This should be a WorkplaceSymbol now as SymbolInformation is deprecated.
- symbols.Add(new SymbolInformation
+ symbols.Add(new WorkspaceSymbol
{
ContainerName = containerName,
Kind = SymbolTypeUtils.GetSymbolKind(symbol.Type),
diff --git a/src/PowerShellEditorServices/Utility/LspUtils.cs b/src/PowerShellEditorServices/Utility/LspUtils.cs
index 68c5ffb0b..d47f2b6c4 100644
--- a/src/PowerShellEditorServices/Utility/LspUtils.cs
+++ b/src/PowerShellEditorServices/Utility/LspUtils.cs
@@ -7,19 +7,19 @@ namespace Microsoft.PowerShell.EditorServices.Utility
{
internal static class LspUtils
{
- public static DocumentSelector PowerShellDocumentSelector => new(
- DocumentFilter.ForLanguage("powershell"),
- DocumentFilter.ForLanguage("pwsh"),
+ public static TextDocumentSelector PowerShellDocumentSelector => new(
+ TextDocumentFilter.ForLanguage("powershell"),
+ TextDocumentFilter.ForLanguage("pwsh"),
// The vim extension sets all PowerShell files as language "ps1" so this
// makes sure we track those.
- DocumentFilter.ForLanguage("ps1"),
- DocumentFilter.ForLanguage("psm1"),
- DocumentFilter.ForLanguage("psd1"),
+ TextDocumentFilter.ForLanguage("ps1"),
+ TextDocumentFilter.ForLanguage("psm1"),
+ TextDocumentFilter.ForLanguage("psd1"),
// Also specify the file extensions to be thorough
// This won't handle untitled files which is why we have to do the ones above.
- DocumentFilter.ForPattern("**/*.ps*1")
+ TextDocumentFilter.ForPattern("**/*.ps*1")
);
}
}
diff --git a/test/.editorconfig b/test/.editorconfig
new file mode 100644
index 000000000..32a01baf2
--- /dev/null
+++ b/test/.editorconfig
@@ -0,0 +1,15 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+# not the top-most EditorConfig file
+root = false
+
+[*.{cs}]
+# CA2007: Do not directly await a Task
+dotnet_diagnostic.CA2007.severity = none
+
+# xUnit1004: Test methods should not be skipped
+dotnet_diagnostic.xUnit1004.severity = suggestion
+# xUnit1030: Do not call ConfigureAwait in test method
+dotnet_diagnostic.xUnit1030.severity = error
+# xUnit2013: Do not use equality check to check for collection size
+dotnet_diagnostic.xUnit2013.severity = error
diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs
index 3ae9748d1..bdf785ede 100644
--- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs
+++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterClientExtensions.cs
@@ -20,7 +20,7 @@ public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient
Script = script,
Cwd = "",
CreateTemporaryIntegratedConsole = false
- }).ConfigureAwait(true);
+ });
if (launchResponse is null)
{
@@ -28,7 +28,7 @@ public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient
}
// This will check to see if we received the Initialized event from the server.
- await started.Task.ConfigureAwait(true);
+ await started.Task;
}
}
}
diff --git a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs
index a270c694b..bc1ac3435 100644
--- a/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs
+++ b/test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs
@@ -39,7 +39,7 @@ public async Task InitializeAsync()
{
LoggerFactory factory = new();
_psesProcess = new PsesStdioProcess(factory, true);
- await _psesProcess.Start().ConfigureAwait(true);
+ await _psesProcess.Start();
TaskCompletionSource initialized = new();
@@ -91,9 +91,9 @@ public async Task InitializeAsync()
// This tells us that we are ready to send messages to PSES... but are not stuck waiting for
// Initialized.
#pragma warning disable CS4014
- PsesDebugAdapterClient.Initialize(CancellationToken.None).ConfigureAwait(true);
+ PsesDebugAdapterClient.Initialize(CancellationToken.None);
#pragma warning restore CS4014
- await initialized.Task.ConfigureAwait(true);
+ await initialized.Task;
}
public async Task DisposeAsync()
@@ -102,8 +102,8 @@ await PsesDebugAdapterClient.RequestDisconnect(new DisconnectArguments
{
Restart = false,
TerminateDebuggee = true
- }).ConfigureAwait(true);
- await _psesProcess.Stop().ConfigureAwait(true);
+ });
+ await _psesProcess.Stop();
}
public void Dispose()
@@ -164,10 +164,10 @@ private static async Task GetLog()
{
for (int i = 0; !File.Exists(s_testOutputPath) && i < 60; i++)
{
- await Task.Delay(1000).ConfigureAwait(true);
+ await Task.Delay(1000);
}
// Sleep one more time after the file exists so whatever is writing can finish.
- await Task.Delay(1000).ConfigureAwait(true);
+ await Task.Delay(1000);
return File.ReadLines(s_testOutputPath).ToArray();
}
@@ -186,10 +186,10 @@ public void CanInitializeWithCorrectServerSettings()
public async Task UsesDotSourceOperatorAndQuotesAsync()
{
string filePath = NewTestFile(GenerateScriptFromLoggingStatements("$($MyInvocation.Line)"));
- await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(true);
- ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
+ await PsesDebugAdapterClient.LaunchScript(filePath, Started);
+ ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments());
Assert.NotNull(configDoneResponse);
- Assert.Collection(await GetLog().ConfigureAwait(true),
+ Assert.Collection(await GetLog(),
(i) => Assert.StartsWith(". '", i));
}
@@ -198,11 +198,11 @@ public async Task CanLaunchScriptWithNoBreakpointsAsync()
{
string filePath = NewTestFile(GenerateScriptFromLoggingStatements("works"));
- await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(true);
+ await PsesDebugAdapterClient.LaunchScript(filePath, Started);
- ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
+ ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments());
Assert.NotNull(configDoneResponse);
- Assert.Collection(await GetLog().ConfigureAwait(true),
+ Assert.Collection(await GetLog(),
(i) => Assert.Equal("works", i));
}
@@ -218,7 +218,7 @@ public async Task CanSetBreakpointsAsync()
"after breakpoint"
));
- await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(true);
+ await PsesDebugAdapterClient.LaunchScript(filePath, Started);
// {"command":"setBreakpoints","arguments":{"source":{"name":"dfsdfg.ps1","path":"/Users/tyleonha/Code/PowerShell/Misc/foo/dfsdfg.ps1"},"lines":[2],"breakpoints":[{"line":2}],"sourceModified":false},"type":"request","seq":3}
SetBreakpointsResponse setBreakpointsResponse = await PsesDebugAdapterClient.SetBreakpoints(new SetBreakpointsArguments
@@ -226,24 +226,24 @@ public async Task CanSetBreakpointsAsync()
Source = new Source { Name = Path.GetFileName(filePath), Path = filePath },
Breakpoints = new SourceBreakpoint[] { new SourceBreakpoint { Line = 2 } },
SourceModified = false,
- }).ConfigureAwait(true);
+ });
Breakpoint breakpoint = setBreakpointsResponse.Breakpoints.First();
Assert.True(breakpoint.Verified);
Assert.Equal(filePath, breakpoint.Source.Path, ignoreCase: s_isWindows);
Assert.Equal(2, breakpoint.Line);
- ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
+ ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments());
Assert.NotNull(configDoneResponse);
- Assert.Collection(await GetLog().ConfigureAwait(true),
+ Assert.Collection(await GetLog(),
(i) => Assert.Equal("before breakpoint", i));
File.Delete(s_testOutputPath);
ContinueResponse continueResponse = await PsesDebugAdapterClient.RequestContinue(
- new ContinueArguments { ThreadId = 1 }).ConfigureAwait(true);
+ new ContinueArguments { ThreadId = 1 });
Assert.NotNull(continueResponse);
- Assert.Collection(await GetLog().ConfigureAwait(true),
+ Assert.Collection(await GetLog(),
(i) => Assert.Equal("at breakpoint", i),
(i) => Assert.Equal("after breakpoint", i));
}
@@ -274,24 +274,24 @@ public async Task CanStepPastSystemWindowsForms()
"Write-Host $form"
}));
- await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(true);
+ await PsesDebugAdapterClient.LaunchScript(filePath, Started);
SetFunctionBreakpointsResponse setBreakpointsResponse = await PsesDebugAdapterClient.SetFunctionBreakpoints(
new SetFunctionBreakpointsArguments
{
Breakpoints = new FunctionBreakpoint[]
{ new FunctionBreakpoint { Name = "Write-Host", } }
- }).ConfigureAwait(true);
+ });
Breakpoint breakpoint = setBreakpointsResponse.Breakpoints.First();
Assert.True(breakpoint.Verified);
- ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
+ ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments());
Assert.NotNull(configDoneResponse);
- await Task.Delay(5000).ConfigureAwait(true);
+ await Task.Delay(5000);
VariablesResponse variablesResponse = await PsesDebugAdapterClient.RequestVariables(
- new VariablesArguments { VariablesReference = 1 }).ConfigureAwait(true);
+ new VariablesArguments { VariablesReference = 1 });
Variable form = variablesResponse.Variables.FirstOrDefault(v => v.Name == "$form");
Assert.NotNull(form);
@@ -312,15 +312,15 @@ public async Task CanLaunchScriptWithCommentedLastLineAsync()
// PsesLaunchRequestArguments.Script, which is then assigned to
// DebugStateService.ScriptToLaunch in that handler, and finally used by the
// ConfigurationDoneHandler in LaunchScriptAsync.
- await PsesDebugAdapterClient.LaunchScript(script, Started).ConfigureAwait(true);
+ await PsesDebugAdapterClient.LaunchScript(script, Started);
- ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
+ ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments());
Assert.NotNull(configDoneResponse);
// We can check that the script was invoked as expected, which is to dot-source a script
// block with the contents surrounded by newlines. While we can't check that the last
// line was a curly brace by itself, we did check that the contents ended with a
// comment, so if this output exists then the bug did not recur.
- Assert.Collection(await GetLog().ConfigureAwait(true),
+ Assert.Collection(await GetLog(),
(i) => Assert.Equal(". {", i),
(i) => Assert.Equal("", i));
}
@@ -342,9 +342,9 @@ public async Task CanRunPesterTestFile()
using CancellationTokenSource cts = new(5000);
while (!File.Exists(pesterLog) && !cts.Token.IsCancellationRequested)
{
- await Task.Delay(1000).ConfigureAwait(true);
+ await Task.Delay(1000);
}
- await Task.Delay(15000).ConfigureAwait(true);
+ await Task.Delay(15000);
_output.WriteLine(File.ReadAllText(pesterLog));
*/
@@ -360,9 +360,9 @@ public async Task CanRunPesterTestFile()
}
}", isPester: true);
- await PsesDebugAdapterClient.LaunchScript($"Invoke-Pester -Script '{pesterTest}'", Started).ConfigureAwait(true);
- await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
- Assert.Collection(await GetLog().ConfigureAwait(true), (i) => Assert.Equal("pester", i));
+ await PsesDebugAdapterClient.LaunchScript($"Invoke-Pester -Script '{pesterTest}'", Started);
+ await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments());
+ Assert.Collection(await GetLog(), (i) => Assert.Equal("pester", i));
}
}
}
diff --git a/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs b/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs
index e58d1e550..9017eab4f 100644
--- a/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs
+++ b/test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs
@@ -45,7 +45,7 @@ public async Task InitializeAsync()
{
LoggerFactory factory = new();
_psesProcess = new PsesStdioProcess(factory, IsDebugAdapterTests);
- await _psesProcess.Start().ConfigureAwait(false);
+ await _psesProcess.Start();
DirectoryInfo testDir =
Directory.CreateDirectory(Path.Combine(s_binDir, Path.GetRandomFileName()));
@@ -79,7 +79,7 @@ public async Task InitializeAsync()
}
});
- await PsesLanguageClient.Initialize(CancellationToken.None).ConfigureAwait(false);
+ await PsesLanguageClient.Initialize(CancellationToken.None);
// Make sure Script Analysis is enabled because we'll need it in the tests.
// This also makes sure the configuration is set to default values.
@@ -97,8 +97,8 @@ public async Task InitializeAsync()
public async Task DisposeAsync()
{
- await PsesLanguageClient.Shutdown().ConfigureAwait(false);
- await _psesProcess.Stop().ConfigureAwait(false);
+ await PsesLanguageClient.Shutdown();
+ await _psesProcess.Stop();
PsesLanguageClient?.Dispose();
}
}
diff --git a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
index 1a227278d..3c1e8c1df 100644
--- a/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
+++ b/test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
@@ -91,7 +91,7 @@ private async Task WaitForDiagnosticsAsync()
throw new InvalidDataException("No diagnostics showed up after 20s.");
}
- await Task.Delay(1000).ConfigureAwait(true);
+ await Task.Delay(1000);
}
}
@@ -101,7 +101,7 @@ public async Task CanSendPowerShellGetVersionRequestAsync()
PowerShellVersion details
= await PsesLanguageClient
.SendRequest("powerShell/getVersion", new GetVersionParams())
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
if (PwshExe == "powershell")
{
@@ -122,16 +122,16 @@ function CanSendWorkspaceSymbolRequest {
}
");
- Container symbols = await PsesLanguageClient
+ Container symbols = await PsesLanguageClient
.SendRequest(
"workspace/symbol",
new WorkspaceSymbolParams
{
Query = "CanSendWorkspaceSymbolRequest"
})
- .Returning>(CancellationToken.None).ConfigureAwait(true);
+ .Returning>(CancellationToken.None);
- SymbolInformation symbol = Assert.Single(symbols);
+ WorkspaceSymbol symbol = Assert.Single(symbols);
Assert.Equal("function CanSendWorkspaceSymbolRequest ()", symbol.Name);
}
@@ -142,7 +142,7 @@ public async Task CanReceiveDiagnosticsFromFileOpenAsync()
"Windows PowerShell doesn't trust PSScriptAnalyzer by default so it won't load.");
NewTestFile("$a = 4");
- await WaitForDiagnosticsAsync().ConfigureAwait(true);
+ await WaitForDiagnosticsAsync();
Diagnostic diagnostic = Assert.Single(Diagnostics);
Assert.Equal("PSUseDeclaredVarsMoreThanAssignments", diagnostic.Code);
@@ -152,7 +152,7 @@ public async Task CanReceiveDiagnosticsFromFileOpenAsync()
public async Task WontReceiveDiagnosticsFromFileOpenThatIsNotPowerShellAsync()
{
NewTestFile("$a = 4", languageId: "plaintext");
- await Task.Delay(2000).ConfigureAwait(true);
+ await Task.Delay(2000);
Assert.Empty(Diagnostics);
}
@@ -164,7 +164,7 @@ public async Task CanReceiveDiagnosticsFromFileChangedAsync()
"Windows PowerShell doesn't trust PSScriptAnalyzer by default so it won't load.");
string filePath = NewTestFile("$a = 4");
- await WaitForDiagnosticsAsync().ConfigureAwait(true);
+ await WaitForDiagnosticsAsync();
Diagnostics.Clear();
PsesLanguageClient.SendNotification("textDocument/didChange", new DidChangeTextDocumentParams
@@ -192,7 +192,7 @@ public async Task CanReceiveDiagnosticsFromFileChangedAsync()
}
});
- await WaitForDiagnosticsAsync().ConfigureAwait(true);
+ await WaitForDiagnosticsAsync();
if (Diagnostics.Count > 1)
{
StringBuilder errorBuilder = new StringBuilder().AppendLine("Multiple diagnostics found when there should be only 1:");
@@ -234,7 +234,7 @@ public async Task CanReceiveDiagnosticsFromConfigurationChangeAsync()
string filePath = NewTestFile("$a = 4");
// Wait a bit to make sure no diagnostics came through
- await Task.Delay(2000).ConfigureAwait(true);
+ await Task.Delay(2000);
Assert.Empty(Diagnostics);
// Restore default configuration
@@ -261,7 +261,7 @@ public async Task CanReceiveDiagnosticsFromConfigurationChangeAsync()
}
});
- await WaitForDiagnosticsAsync().ConfigureAwait(true);
+ await WaitForDiagnosticsAsync();
Diagnostic diagnostic = Assert.Single(Diagnostics);
Assert.Equal("PSUseDeclaredVarsMoreThanAssignments", diagnostic.Code);
@@ -289,7 +289,7 @@ await PsesLanguageClient
Uri = new Uri(scriptPath)
}
})
- .Returning>(CancellationToken.None).ConfigureAwait(true);
+ .Returning>(CancellationToken.None);
Assert.Collection(foldingRanges.OrderBy(f => f.StartLine),
range1 =>
@@ -336,7 +336,7 @@ public async Task CanSendFormattingRequestAsync()
InsertSpaces = false
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
TextEdit textEdit = Assert.Single(textEdits);
@@ -385,7 +385,7 @@ public async Task CanSendRangeFormattingRequestAsync()
InsertSpaces = false
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
TextEdit textEdit = Assert.Single(textEdits);
@@ -415,17 +415,27 @@ await PsesLanguageClient
Uri = new Uri(scriptPath)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Collection(symbolInformationOrDocumentSymbols,
symInfoOrDocSym =>
{
- Range range = symInfoOrDocSym.SymbolInformation.Location.Range;
-
- Assert.Equal(1, range.Start.Line);
- Assert.Equal(9, range.Start.Character);
- Assert.Equal(3, range.End.Line);
- Assert.Equal(1, range.End.Character);
+ Assert.True(symInfoOrDocSym.IsDocumentSymbol);
+ Assert.NotNull(symInfoOrDocSym.DocumentSymbol);
+ DocumentSymbol symbol = symInfoOrDocSym.DocumentSymbol;
+
+ Assert.Equal(symbol.Name, "function CanSendDocumentSymbolRequest ()");
+ Assert.Equal(symbol.Kind, SymbolKind.Function);
+
+ Assert.Equal(1, symbol.Range.Start.Line);
+ Assert.Equal(0, symbol.Range.Start.Character);
+ Assert.Equal(3, symbol.Range.End.Line);
+ Assert.Equal(1, symbol.Range.End.Character);
+
+ Assert.Equal(1, symbol.SelectionRange.Start.Line);
+ Assert.Equal(9, symbol.SelectionRange.Start.Character);
+ Assert.Equal(1, symbol.SelectionRange.End.Line);
+ Assert.Equal(37, symbol.SelectionRange.End.Character);
});
}
@@ -459,7 +469,7 @@ function CanSendReferencesRequest {
IncludeDeclaration = false
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Collection(locations,
location =>
@@ -497,7 +507,7 @@ await PsesLanguageClient
Character = 1
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Collection(documentHighlights.OrderBy(i => i.Range.Start.Line),
documentHighlight1 =>
@@ -548,7 +558,7 @@ await PsesLanguageClient
.SendRequest(
"powerShell/getPSHostProcesses",
new GetPSHostProcessesParams())
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
}
finally
{
@@ -591,7 +601,7 @@ await PsesLanguageClient
{
ProcessId = $"{process.Id}"
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
}
finally
{
@@ -641,7 +651,7 @@ public async Task CanSendPesterLegacyCodeLensRequestAsync()
Uri = new Uri(filePath)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Collection(codeLenses,
codeLens1 =>
@@ -707,7 +717,7 @@ public async Task CanSendPesterCodeLensRequestAsync()
Uri = new Uri(filePath)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Collection(codeLenses,
codeLens =>
@@ -816,7 +826,7 @@ public async Task NoMessageIfPesterCodeLensDisabled()
Uri = new Uri(filePath)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Empty(codeLenses);
}
@@ -842,7 +852,7 @@ function CanSendReferencesCodeLensRequest {
Uri = new Uri(filePath)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
CodeLens codeLens = Assert.Single(codeLenses);
@@ -854,7 +864,7 @@ function CanSendReferencesCodeLensRequest {
CodeLens codeLensResolveResult = await PsesLanguageClient
.SendRequest("codeLens/resolve", codeLens)
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Equal("1 reference", codeLensResolveResult.Command.Title);
}
@@ -889,7 +899,7 @@ class ChildClass : MyBaseClass, System.IDisposable {
Uri = new Uri(filePath)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Collection(codeLenses.OrderBy(i => i.Range.Start.Line),
codeLens =>
@@ -913,7 +923,7 @@ class ChildClass : MyBaseClass, System.IDisposable {
CodeLens baseClassCodeLens = codeLenses.OrderBy(i => i.Range.Start.Line).First();
CodeLens codeLensResolveResult = await PsesLanguageClient
.SendRequest("codeLens/resolve", baseClassCodeLens)
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Equal("4 references", codeLensResolveResult.Command.Title);
}
@@ -946,7 +956,7 @@ enum MyEnum {
Uri = new Uri(filePath)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
CodeLens codeLens = Assert.Single(codeLenses);
@@ -958,7 +968,7 @@ enum MyEnum {
CodeLens codeLensResolveResult = await PsesLanguageClient
.SendRequest("codeLens/resolve", codeLens)
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Equal("3 references", codeLensResolveResult.Command.Title);
}
@@ -970,7 +980,7 @@ public async Task CanSendCodeActionRequestAsync()
"Windows PowerShell doesn't trust PSScriptAnalyzer by default so it won't load.");
string filePath = NewTestFile("gci");
- await WaitForDiagnosticsAsync().ConfigureAwait(true);
+ await WaitForDiagnosticsAsync();
CommandOrCodeActionContainer commandOrCodeActions =
await PsesLanguageClient
@@ -998,7 +1008,7 @@ await PsesLanguageClient
Diagnostics = new Container(Diagnostics)
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Collection(commandOrCodeActions,
command =>
@@ -1040,7 +1050,7 @@ public async Task CanSendCompletionAndCompletionResolveRequestAsync()
CompletionItem updatedCompletionItem = await PsesLanguageClient
.SendRequest("completionItem/resolve", completionItem)
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Contains("Writes customized output to a host", updatedCompletionItem.Documentation.String);
}
@@ -1085,7 +1095,7 @@ await PsesLanguageClient
{
Expression = "Import-Module Microsoft.PowerShell.Archive -Prefix Slow"
})
- .ReturningVoid(CancellationToken.None).ConfigureAwait(true);
+ .ReturningVoid(CancellationToken.None);
string filePath = NewTestFile("Expand-SlowArch");
@@ -1104,7 +1114,7 @@ await PsesLanguageClient
CompletionItem updatedCompletionItem = await PsesLanguageClient
.SendRequest("completionItem/resolve", completionItem)
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Contains("Extracts files from a specified archive", updatedCompletionItem.Documentation.String);
}
@@ -1123,7 +1133,7 @@ public async Task CanSendHoverRequestAsync()
Uri = DocumentUri.FromFileSystemPath(filePath)
},
Position = new Position(line: 0, character: 1)
- }).ConfigureAwait(true);
+ });
Assert.True(hover.Contents.HasMarkedStrings);
Assert.Collection(hover.Contents.MarkedStrings,
@@ -1155,7 +1165,7 @@ public async Task CanSendSignatureHelpRequestAsync()
Character = 10
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Contains("Get-Date", signatureHelp.Signatures.First().Label);
}
@@ -1180,7 +1190,7 @@ await PsesLanguageClient
TextDocument = new TextDocumentIdentifier { Uri = new Uri(scriptPath) },
Position = new Position { Line = 5, Character = 2 }
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
LocationOrLocationLink locationOrLocationLink =
Assert.Single(locationOrLocationLinks);
@@ -1205,7 +1215,7 @@ await PsesLanguageClient
{
IncludeInstalledModules = true
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.Contains(getProjectTemplatesResponse.Templates, t => t.Title is "AddPSScriptAnalyzerSettings");
Assert.Contains(getProjectTemplatesResponse.Templates, t => t.Title is "New PowerShell Manifest Module");
@@ -1244,7 +1254,7 @@ await PsesLanguageClient
Character = 0
}
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
Assert.NotEmpty(commentHelpRequestResult.Content);
Assert.Contains("myParam", commentHelpRequestResult.Content[7]);
@@ -1261,7 +1271,7 @@ await PsesLanguageClient
{
Expression = "Get-ChildItem"
})
- .Returning(CancellationToken.None).ConfigureAwait(true);
+ .Returning(CancellationToken.None);
// These always gets returned so this test really just makes sure we get _any_ response.
Assert.Equal("", evaluateResponseBody.Result);
@@ -1274,7 +1284,7 @@ public async Task CanSendGetCommandRequestAsync()
List