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/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 89220fff7..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") { @@ -129,7 +129,7 @@ function CanSendWorkspaceSymbolRequest { { Query = "CanSendWorkspaceSymbolRequest" }) - .Returning>(CancellationToken.None).ConfigureAwait(true); + .Returning>(CancellationToken.None); 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,7 +415,7 @@ await PsesLanguageClient Uri = new Uri(scriptPath) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); Assert.Collection(symbolInformationOrDocumentSymbols, symInfoOrDocSym => @@ -469,7 +469,7 @@ function CanSendReferencesRequest { IncludeDeclaration = false } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); Assert.Collection(locations, location => @@ -507,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 => @@ -558,7 +558,7 @@ await PsesLanguageClient .SendRequest( "powerShell/getPSHostProcesses", new GetPSHostProcessesParams()) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); } finally { @@ -601,7 +601,7 @@ await PsesLanguageClient { ProcessId = $"{process.Id}" }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); } finally { @@ -651,7 +651,7 @@ public async Task CanSendPesterLegacyCodeLensRequestAsync() Uri = new Uri(filePath) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); Assert.Collection(codeLenses, codeLens1 => @@ -717,7 +717,7 @@ public async Task CanSendPesterCodeLensRequestAsync() Uri = new Uri(filePath) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); Assert.Collection(codeLenses, codeLens => @@ -826,7 +826,7 @@ public async Task NoMessageIfPesterCodeLensDisabled() Uri = new Uri(filePath) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); Assert.Empty(codeLenses); } @@ -852,7 +852,7 @@ function CanSendReferencesCodeLensRequest { Uri = new Uri(filePath) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); CodeLens codeLens = Assert.Single(codeLenses); @@ -864,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); } @@ -899,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 => @@ -923,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); } @@ -956,7 +956,7 @@ enum MyEnum { Uri = new Uri(filePath) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); CodeLens codeLens = Assert.Single(codeLenses); @@ -968,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); } @@ -980,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 @@ -1008,7 +1008,7 @@ await PsesLanguageClient Diagnostics = new Container(Diagnostics) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); Assert.Collection(commandOrCodeActions, command => @@ -1050,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); } @@ -1095,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"); @@ -1114,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); } @@ -1133,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, @@ -1165,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); } @@ -1190,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); @@ -1215,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"); @@ -1254,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]); @@ -1271,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); @@ -1284,7 +1284,7 @@ public async Task CanSendGetCommandRequestAsync() List pSCommandMessages = await PsesLanguageClient .SendRequest("powerShell/getCommand", new GetCommandParams()) - .Returning>(CancellationToken.None).ConfigureAwait(true); + .Returning>(CancellationToken.None); Assert.NotEmpty(pSCommandMessages); // There should be at least 20 commands or so. @@ -1305,7 +1305,7 @@ await PsesLanguageClient { Text = "gci" }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); Assert.Equal("Get-ChildItem", expandAliasResult.Text); } @@ -1327,7 +1327,7 @@ await PsesLanguageClient Uri = new Uri(scriptPath) } }) - .Returning(CancellationToken.None).ConfigureAwait(true); + .Returning(CancellationToken.None); // More information about how this data is generated can be found at // https://github.com/microsoft/vscode-extension-samples/blob/5ae1f7787122812dcc84e37427ca90af5ee09f14/semantic-tokens-sample/vscode.proposed.d.ts#L71 diff --git a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs index 294901362..b6a1aa48d 100644 --- a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs @@ -171,21 +171,21 @@ private Task> GetConfirmedBreakpoints(ScriptFile s public async Task DebuggerAcceptsInlineScript() { await debugService.SetCommandBreakpointsAsync( - new[] { CommandBreakpointDetails.Create("Get-Random") }).ConfigureAwait(true); + new[] { CommandBreakpointDetails.Create("Get-Random") }); Task> executeTask = psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Get-Random -SetSeed 42 -Maximum 100"), CancellationToken.None); AssertDebuggerStopped("", 1); - await Task.Run(debugService.Continue).ConfigureAwait(true); - Assert.Equal(17, (await executeTask.ConfigureAwait(true))[0]); + await Task.Run(debugService.Continue); + Assert.Equal(17, (await executeTask)[0]); - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); Assert.Equal(StackFrameDetails.NoFileScriptPath, stackFrames[0].ScriptPath); // NOTE: This assertion will fail if any error occurs. Notably this happens in testing // when the assembly path changes and the commands definition file can't be found. - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.GlobalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.GlobalScopeName); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$Error"); Assert.NotNull(var); Assert.True(var.IsExpandable); @@ -205,7 +205,7 @@ public async Task DebuggerAcceptsScriptArgs(string[] args) { IReadOnlyList breakpoints = await debugService.SetLineBreakpointsAsync( oddPathScriptFile, - new[] { BreakpointDetails.Create(oddPathScriptFile.FilePath, 3) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(oddPathScriptFile.FilePath, 3) }); Assert.Single(breakpoints); Assert.Collection(breakpoints, (breakpoint) => @@ -220,7 +220,7 @@ public async Task DebuggerAcceptsScriptArgs(string[] args) AssertDebuggerStopped(oddPathScriptFile.FilePath, 3); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$Param1"); Assert.NotNull(var); @@ -231,7 +231,7 @@ public async Task DebuggerAcceptsScriptArgs(string[] args) Assert.NotNull(var); Assert.True(var.IsExpandable); - VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None); // 2 variables plus "Raw View" Assert.Equal(3, childVars.Length); Assert.Equal("\"Bar\"", childVars[0].ValueString); @@ -243,13 +243,13 @@ public async Task DebuggerAcceptsScriptArgs(string[] args) Assert.True(var.IsExpandable); // NOTE: $args are no longer found in AutoVariables but CommandVariables instead. - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); - variables = await debugService.GetVariables(stackFrames[0].CommandVariables.Id, CancellationToken.None).ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); + variables = await debugService.GetVariables(stackFrames[0].CommandVariables.Id, CancellationToken.None); var = Array.Find(variables, v => v.Name == "$args"); Assert.NotNull(var); Assert.True(var.IsExpandable); - childVars = await debugService.GetVariables(var.Id, CancellationToken.None).ConfigureAwait(true); + childVars = await debugService.GetVariables(var.Id, CancellationToken.None); Assert.Equal(2, childVars.Length); Assert.Equal("\"Extra1\"", childVars[0].ValueString); } @@ -261,19 +261,19 @@ public async Task DebuggerSetsAndClearsFunctionBreakpoints() new[] { CommandBreakpointDetails.Create("Write-Host"), CommandBreakpointDetails.Create("Get-Date") - }).ConfigureAwait(true); + }); Assert.Equal(2, breakpoints.Count); Assert.Equal("Write-Host", breakpoints[0].Name); Assert.Equal("Get-Date", breakpoints[1].Name); breakpoints = await debugService.SetCommandBreakpointsAsync( - new[] { CommandBreakpointDetails.Create("Get-Host") }).ConfigureAwait(true); + new[] { CommandBreakpointDetails.Create("Get-Host") }); Assert.Equal("Get-Host", Assert.Single(breakpoints).Name); breakpoints = await debugService.SetCommandBreakpointsAsync( - Array.Empty()).ConfigureAwait(true); + Array.Empty()); Assert.Empty(breakpoints); } @@ -282,12 +282,12 @@ public async Task DebuggerSetsAndClearsFunctionBreakpoints() public async Task DebuggerStopsOnFunctionBreakpoints() { IReadOnlyList breakpoints = await debugService.SetCommandBreakpointsAsync( - new[] { CommandBreakpointDetails.Create("Write-Host") }).ConfigureAwait(true); + new[] { CommandBreakpointDetails.Create("Write-Host") }); Task _ = ExecuteDebugFileAsync(); AssertDebuggerStopped(debugScriptFile.FilePath, 6); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Verify the function breakpoint broke at Write-Host and $i is 1 VariableDetailsBase i = Array.Find(variables, v => v.Name == "$i"); @@ -296,10 +296,10 @@ public async Task DebuggerStopsOnFunctionBreakpoints() Assert.Equal("1", i.ValueString); // The function breakpoint should fire the next time through the loop. - await Task.Run(debugService.Continue).ConfigureAwait(true); + await Task.Run(debugService.Continue); AssertDebuggerStopped(debugScriptFile.FilePath, 6); - variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Verify the function breakpoint broke at Write-Host and $i is 1 i = Array.Find(variables, v => v.Name == "$i"); @@ -317,9 +317,9 @@ await debugService.SetLineBreakpointsAsync( new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 5), BreakpointDetails.Create(debugScriptFile.FilePath, 10) - }).ConfigureAwait(true); + }); - IReadOnlyList confirmedBreakpoints = await GetConfirmedBreakpoints(debugScriptFile).ConfigureAwait(true); + IReadOnlyList confirmedBreakpoints = await GetConfirmedBreakpoints(debugScriptFile); Assert.Equal(2, confirmedBreakpoints.Count); Assert.Equal(5, breakpoints[0].LineNumber); @@ -327,17 +327,17 @@ await debugService.SetLineBreakpointsAsync( breakpoints = await debugService.SetLineBreakpointsAsync( debugScriptFile, - new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 2) }).ConfigureAwait(true); - confirmedBreakpoints = await GetConfirmedBreakpoints(debugScriptFile).ConfigureAwait(true); + new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 2) }); + confirmedBreakpoints = await GetConfirmedBreakpoints(debugScriptFile); Assert.Single(confirmedBreakpoints); Assert.Equal(2, breakpoints[0].LineNumber); await debugService.SetLineBreakpointsAsync( debugScriptFile, - Array.Empty()).ConfigureAwait(true); + Array.Empty()); - IReadOnlyList remainingBreakpoints = await GetConfirmedBreakpoints(debugScriptFile).ConfigureAwait(true); + IReadOnlyList remainingBreakpoints = await GetConfirmedBreakpoints(debugScriptFile); Assert.Empty(remainingBreakpoints); } @@ -349,11 +349,11 @@ await debugService.SetLineBreakpointsAsync( new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 5), BreakpointDetails.Create(debugScriptFile.FilePath, 7) - }).ConfigureAwait(true); + }); Task _ = ExecuteDebugFileAsync(); AssertDebuggerStopped(debugScriptFile.FilePath, 5); - await Task.Run(debugService.Continue).ConfigureAwait(true); + await Task.Run(debugService.Continue); AssertDebuggerStopped(debugScriptFile.FilePath, 7); } @@ -367,12 +367,12 @@ await debugService.SetLineBreakpointsAsync( debugScriptFile, new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 7, null, $"$i -eq {breakpointValue1} -or $i -eq {breakpointValue2}"), - }).ConfigureAwait(true); + }); Task _ = ExecuteDebugFileAsync(); AssertDebuggerStopped(debugScriptFile.FilePath, 7); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Verify the breakpoint only broke at the condition ie. $i -eq breakpointValue1 VariableDetailsBase i = Array.Find(variables, v => v.Name == "$i"); @@ -382,10 +382,10 @@ await debugService.SetLineBreakpointsAsync( // The conditional breakpoint should not fire again, until the value of // i reaches breakpointValue2. - await Task.Run(debugService.Continue).ConfigureAwait(true); + await Task.Run(debugService.Continue); AssertDebuggerStopped(debugScriptFile.FilePath, 7); - variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Verify the breakpoint only broke at the condition ie. $i -eq breakpointValue1 i = Array.Find(variables, v => v.Name == "$i"); @@ -403,12 +403,12 @@ await debugService.SetLineBreakpointsAsync( debugScriptFile, new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 6, null, null, $"{hitCount}"), - }).ConfigureAwait(true); + }); Task _ = ExecuteDebugFileAsync(); AssertDebuggerStopped(debugScriptFile.FilePath, 6); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Verify the breakpoint only broke at the condition ie. $i -eq breakpointValue1 VariableDetailsBase i = Array.Find(variables, v => v.Name == "$i"); @@ -424,12 +424,12 @@ public async Task DebuggerStopsOnConditionalAndHitConditionBreakpoint() await debugService.SetLineBreakpointsAsync( debugScriptFile, - new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 6, null, "$i % 2 -eq 0", $"{hitCount}") }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 6, null, "$i % 2 -eq 0", $"{hitCount}") }); Task _ = ExecuteDebugFileAsync(); AssertDebuggerStopped(debugScriptFile.FilePath, 6); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Verify the breakpoint only broke at the condition ie. $i -eq breakpointValue1 VariableDetailsBase i = Array.Find(variables, v => v.Name == "$i"); @@ -454,7 +454,7 @@ await debugService.SetLineBreakpointsAsync( // BreakpointDetails.Create(debugScriptFile.FilePath, 5), BreakpointDetails.Create(debugScriptFile.FilePath, 10, column: null, condition: "$i -ez 100") - }).ConfigureAwait(true); + }); Assert.Single(breakpoints); // Assert.Equal(5, breakpoints[0].LineNumber); @@ -476,7 +476,7 @@ await debugService.SetLineBreakpointsAsync( new[] { BreakpointDetails.Create(debugScriptFile.FilePath, 5, column: null, condition: "$i == 100"), BreakpointDetails.Create(debugScriptFile.FilePath, 7, column: null, condition: "$i > 100") - }).ConfigureAwait(true); + }); Assert.Equal(2, breakpoints.Count); Assert.Equal(5, breakpoints[0].LineNumber); @@ -492,11 +492,11 @@ await debugService.SetLineBreakpointsAsync( [Fact] public async Task DebuggerBreaksWhenRequested() { - IReadOnlyList confirmedBreakpoints = await GetConfirmedBreakpoints(debugScriptFile).ConfigureAwait(true); + IReadOnlyList confirmedBreakpoints = await GetConfirmedBreakpoints(debugScriptFile); Assert.Empty(confirmedBreakpoints); Task _ = ExecuteDebugFileAsync(); // NOTE: This must be run on a separate thread so the async event handlers can fire. - await Task.Run(debugService.Break).ConfigureAwait(true); + await Task.Run(debugService.Break); AssertDebuggerPaused(); } @@ -505,13 +505,13 @@ public async Task DebuggerRunsCommandsWhileStopped() { Task _ = ExecuteDebugFileAsync(); // NOTE: This must be run on a separate thread so the async event handlers can fire. - await Task.Run(debugService.Break).ConfigureAwait(true); + await Task.Run(debugService.Break); AssertDebuggerPaused(); // Try running a command from outside the pipeline thread Task> executeTask = psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Get-Random -SetSeed 42 -Maximum 100"), CancellationToken.None); - Assert.Equal(17, (await executeTask.ConfigureAwait(true))[0]); + Assert.Equal(17, (await executeTask)[0]); } // Regression test asserting that the PSDebugContext variable is available when running the @@ -522,13 +522,13 @@ public async Task DebuggerRunsCommandsWhileStopped() public async Task DebugContextAvailableInPrompt() { await debugService.SetCommandBreakpointsAsync( - new[] { CommandBreakpointDetails.Create("Write-Host") }).ConfigureAwait(true); + new[] { CommandBreakpointDetails.Create("Write-Host") }); ScriptFile testScript = GetDebugScript("PSDebugContextTest.ps1"); Task _ = ExecuteScriptFileAsync(testScript.FilePath); AssertDebuggerStopped(testScript.FilePath, 11); - VariableDetails prompt = await debugService.EvaluateExpressionAsync("prompt", false, CancellationToken.None).ConfigureAwait(true); + VariableDetails prompt = await debugService.EvaluateExpressionAsync("prompt", false, CancellationToken.None); Assert.Equal("\"True > \"", prompt.ValueString); } @@ -545,7 +545,7 @@ public async Task DebuggerBreaksInUntitledScript() Assert.True(workspace.TryGetFile(scriptPath, out ScriptFile _)); await debugService.SetCommandBreakpointsAsync( - new[] { CommandBreakpointDetails.Create("Write-Output") }).ConfigureAwait(true); + new[] { CommandBreakpointDetails.Create("Write-Output") }); ConfigurationDoneHandler configurationDoneHandler = new( NullLoggerFactory.Instance, null, debugService, null, null, psesHost, workspace, null, psesHost); @@ -553,7 +553,7 @@ await debugService.SetCommandBreakpointsAsync( Task _ = configurationDoneHandler.LaunchScriptAsync(scriptPath); AssertDebuggerStopped(scriptPath, 1); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.CommandVariablesName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.CommandVariablesName); VariableDetailsBase myInvocation = Array.Find(variables, v => v.Name == "$MyInvocation"); Assert.NotNull(myInvocation); Assert.True(myInvocation.IsExpandable); @@ -561,7 +561,7 @@ await debugService.SetCommandBreakpointsAsync( // Here we're asserting that our hacky workaround to support breakpoints in untitled // scripts is working, namely that we're actually dot-sourcing our first argument, which // should be a cached script block. See the `LaunchScriptAsync` for more info. - VariableDetailsBase[] myInvocationChildren = await debugService.GetVariables(myInvocation.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] myInvocationChildren = await debugService.GetVariables(myInvocation.Id, CancellationToken.None); VariableDetailsBase myInvocationLine = Array.Find(myInvocationChildren, v => v.Name == "Line"); Assert.Equal("\". $args[0]\"", myInvocationLine.ValueString); } @@ -571,11 +571,11 @@ public async Task RecordsF5CommandInPowerShellHistory() { ConfigurationDoneHandler configurationDoneHandler = new( NullLoggerFactory.Instance, null, debugService, null, null, psesHost, workspace, null, psesHost); - await configurationDoneHandler.LaunchScriptAsync(debugScriptFile.FilePath).ConfigureAwait(true); + await configurationDoneHandler.LaunchScriptAsync(debugScriptFile.FilePath); IReadOnlyList historyResult = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("(Get-History).CommandLine"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // Check the PowerShell history Assert.Equal(". '" + debugScriptFile.FilePath + "'", Assert.Single(historyResult)); @@ -591,13 +591,13 @@ public async Task RecordsF8CommandInHistory() EvaluateHandler evaluateHandler = new(psesHost); EvaluateResponseBody evaluateResponseBody = await evaluateHandler.Handle( new EvaluateRequestArguments { Expression = script, Context = "repl" }, - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // TODO: Right now this response is hard-coded, maybe it should change? Assert.Equal("", evaluateResponseBody.Result); IReadOnlyList historyResult = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("(Get-History).CommandLine"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // Check the PowerShell history Assert.Equal(script, Assert.Single(historyResult)); @@ -611,11 +611,11 @@ public async Task OddFilePathsLaunchCorrectly() { ConfigurationDoneHandler configurationDoneHandler = new( NullLoggerFactory.Instance, null, debugService, null, null, psesHost, workspace, null, psesHost); - await configurationDoneHandler.LaunchScriptAsync(oddPathScriptFile.FilePath).ConfigureAwait(true); + await configurationDoneHandler.LaunchScriptAsync(oddPathScriptFile.FilePath); IReadOnlyList historyResult = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("(Get-History).CommandLine"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // Check the PowerShell history Assert.Equal(". " + PSCommandHelpers.EscapeScriptFilePath(oddPathScriptFile.FilePath), Assert.Single(historyResult)); @@ -626,12 +626,12 @@ public async Task DebuggerVariableStringDisplaysCorrectly() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 8) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 8) }); Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$strVar"); Assert.NotNull(var); @@ -644,12 +644,12 @@ public async Task DebuggerGetsVariables() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 21) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 21) }); Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); // TODO: Add checks for correct value strings as well VariableDetailsBase strVar = Array.Find(variables, v => v.Name == "$strVar"); @@ -660,7 +660,7 @@ await debugService.SetLineBreakpointsAsync( Assert.NotNull(objVar); Assert.True(objVar.IsExpandable); - VariableDetailsBase[] objChildren = await debugService.GetVariables(objVar.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] objChildren = await debugService.GetVariables(objVar.Id, CancellationToken.None); // Two variables plus "Raw View" Assert.Equal(3, objChildren.Length); @@ -668,14 +668,14 @@ await debugService.SetLineBreakpointsAsync( Assert.NotNull(arrVar); Assert.True(arrVar.IsExpandable); - VariableDetailsBase[] arrChildren = await debugService.GetVariables(arrVar.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] arrChildren = await debugService.GetVariables(arrVar.Id, CancellationToken.None); Assert.Equal(5, arrChildren.Length); VariableDetailsBase classVar = Array.Find(variables, v => v.Name == "$classVar"); Assert.NotNull(classVar); Assert.True(classVar.IsExpandable); - VariableDetailsBase[] classChildren = await debugService.GetVariables(classVar.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] classChildren = await debugService.GetVariables(classVar.Id, CancellationToken.None); Assert.Equal(2, classChildren.Length); VariableDetailsBase trueVar = Array.Find(variables, v => v.Name == "$trueVar"); @@ -694,50 +694,50 @@ public async Task DebuggerSetsVariablesNoConversion() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 14) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 14) }); Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); VariableScope[] scopes = debugService.GetVariableScopes(0); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Test set of a local string variable (not strongly typed) const string newStrValue = "\"Goodbye\""; VariableScope localScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.LocalScopeName); - string setStrValue = await debugService.SetVariableAsync(localScope.Id, "$strVar", newStrValue).ConfigureAwait(true); + string setStrValue = await debugService.SetVariableAsync(localScope.Id, "$strVar", newStrValue); Assert.Equal(newStrValue, setStrValue); // Test set of script scope int variable (not strongly typed) VariableScope scriptScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.ScriptScopeName); const string newIntValue = "49"; const string newIntExpr = "7 * 7"; - string setIntValue = await debugService.SetVariableAsync(scriptScope.Id, "$scriptInt", newIntExpr).ConfigureAwait(true); + string setIntValue = await debugService.SetVariableAsync(scriptScope.Id, "$scriptInt", newIntExpr); Assert.Equal(newIntValue, setIntValue); // Test set of global scope int variable (not strongly typed) VariableScope globalScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.GlobalScopeName); const string newGlobalIntValue = "4242"; - string setGlobalIntValue = await debugService.SetVariableAsync(globalScope.Id, "$MaximumHistoryCount", newGlobalIntValue).ConfigureAwait(true); + string setGlobalIntValue = await debugService.SetVariableAsync(globalScope.Id, "$MaximumHistoryCount", newGlobalIntValue); Assert.Equal(newGlobalIntValue, setGlobalIntValue); // The above just tests that the debug service returns the correct new value string. // Let's step the debugger and make sure the values got set to the new values. - await Task.Run(debugService.StepOver).ConfigureAwait(true); + await Task.Run(debugService.StepOver); AssertDebuggerStopped(variableScriptFile.FilePath); // Test set of a local string variable (not strongly typed) - variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.LocalScopeName); VariableDetailsBase strVar = Array.Find(variables, v => v.Name == "$strVar"); Assert.Equal(newStrValue, strVar.ValueString); // Test set of script scope int variable (not strongly typed) - variables = await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.ScriptScopeName); VariableDetailsBase intVar = Array.Find(variables, v => v.Name == "$scriptInt"); Assert.Equal(newIntValue, intVar.ValueString); // Test set of global scope int variable (not strongly typed) - variables = await GetVariables(VariableContainerDetails.GlobalScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.GlobalScopeName); VariableDetailsBase intGlobalVar = Array.Find(variables, v => v.Name == "$MaximumHistoryCount"); Assert.Equal(newGlobalIntValue, intGlobalVar.ValueString); } @@ -747,53 +747,53 @@ public async Task DebuggerSetsVariablesWithConversion() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 14) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 14) }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); VariableScope[] scopes = debugService.GetVariableScopes(0); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); // Test set of a local string variable (not strongly typed but force conversion) const string newStrValue = "\"False\""; const string newStrExpr = "$false"; VariableScope localScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.LocalScopeName); - string setStrValue = await debugService.SetVariableAsync(localScope.Id, "$strVar2", newStrExpr).ConfigureAwait(true); + string setStrValue = await debugService.SetVariableAsync(localScope.Id, "$strVar2", newStrExpr); Assert.Equal(newStrValue, setStrValue); // Test set of script scope bool variable (strongly typed) VariableScope scriptScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.ScriptScopeName); const string newBoolValue = "$true"; const string newBoolExpr = "1"; - string setBoolValue = await debugService.SetVariableAsync(scriptScope.Id, "$scriptBool", newBoolExpr).ConfigureAwait(true); + string setBoolValue = await debugService.SetVariableAsync(scriptScope.Id, "$scriptBool", newBoolExpr); Assert.Equal(newBoolValue, setBoolValue); // Test set of global scope ActionPreference variable (strongly typed) VariableScope globalScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.GlobalScopeName); const string newGlobalValue = "Continue"; const string newGlobalExpr = "'Continue'"; - string setGlobalValue = await debugService.SetVariableAsync(globalScope.Id, "$VerbosePreference", newGlobalExpr).ConfigureAwait(true); + string setGlobalValue = await debugService.SetVariableAsync(globalScope.Id, "$VerbosePreference", newGlobalExpr); Assert.Equal(newGlobalValue, setGlobalValue); // The above just tests that the debug service returns the correct new value string. // Let's step the debugger and make sure the values got set to the new values. - await Task.Run(debugService.StepOver).ConfigureAwait(true); + await Task.Run(debugService.StepOver); AssertDebuggerStopped(variableScriptFile.FilePath); // Test set of a local string variable (not strongly typed but force conversion) - variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.LocalScopeName); VariableDetailsBase strVar = Array.Find(variables, v => v.Name == "$strVar2"); Assert.Equal(newStrValue, strVar.ValueString); // Test set of script scope bool variable (strongly typed) - variables = await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.ScriptScopeName); VariableDetailsBase boolVar = Array.Find(variables, v => v.Name == "$scriptBool"); Assert.Equal(newBoolValue, boolVar.ValueString); // Test set of global scope ActionPreference variable (strongly typed) - variables = await GetVariables(VariableContainerDetails.GlobalScopeName).ConfigureAwait(true); + variables = await GetVariables(VariableContainerDetails.GlobalScopeName); VariableDetailsBase globalVar = Array.Find(variables, v => v.Name == "$VerbosePreference"); Assert.Equal(newGlobalValue, globalVar.ValueString); } @@ -803,14 +803,14 @@ public async Task DebuggerVariableEnumDisplaysCorrectly() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 15) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 15) }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); - VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None).ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); + VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$enumVar"); Assert.NotNull(var); @@ -823,21 +823,21 @@ public async Task DebuggerVariableHashtableDisplaysCorrectly() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 11) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 11) }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); - VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None).ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); + VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$assocArrVar"); Assert.NotNull(var); Assert.Equal("[Hashtable: 2]", var.ValueString); Assert.True(var.IsExpandable); - VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None); // 2 variables plus "Raw View" Assert.Equal(3, childVars.Length); @@ -856,14 +856,14 @@ public async Task DebuggerVariableNullStringDisplaysCorrectly() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 16) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 16) }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); - VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None).ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); + VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None); VariableDetailsBase nullStringVar = Array.Find(variables, v => v.Name == "$nullString"); Assert.NotNull(nullStringVar); @@ -876,21 +876,21 @@ public async Task DebuggerVariablePSObjectDisplaysCorrectly() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 17) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 17) }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); - VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None).ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); + VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None); VariableDetailsBase psObjVar = Array.Find(variables, v => v.Name == "$psObjVar"); Assert.NotNull(psObjVar); Assert.True("@{Age=75; Name=John}".Equals(psObjVar.ValueString) || "@{Name=John; Age=75}".Equals(psObjVar.ValueString)); Assert.True(psObjVar.IsExpandable); - VariableDetailsBase[] childVars = await debugService.GetVariables(psObjVar.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] childVars = await debugService.GetVariables(psObjVar.Id, CancellationToken.None); IDictionary dictionary = childVars.ToDictionary(v => v.Name, v => v.ValueString); Assert.Equal(2, dictionary.Count); Assert.Contains("Age", dictionary.Keys); @@ -903,14 +903,14 @@ await debugService.SetLineBreakpointsAsync( public async Task DebuggerEnumerableShowsRawView() { CommandBreakpointDetails breakpoint = CommandBreakpointDetails.Create("__BreakDebuggerEnumerableShowsRawView"); - await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }).ConfigureAwait(true); + await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(commandBreakpointDetails: breakpoint); VariableDetailsBase simpleArrayVar = Array.Find( - await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true), + await GetVariables(VariableContainerDetails.ScriptScopeName), v => v.Name == "$simpleArray"); Assert.NotNull(simpleArrayVar); VariableDetailsBase rawDetailsView = Array.Find( @@ -960,14 +960,14 @@ await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true public async Task DebuggerDictionaryShowsRawView() { CommandBreakpointDetails breakpoint = CommandBreakpointDetails.Create("__BreakDebuggerDictionaryShowsRawView"); - await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }).ConfigureAwait(true); + await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(commandBreakpointDetails: breakpoint); VariableDetailsBase simpleDictionaryVar = Array.Find( - await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true), + await GetVariables(VariableContainerDetails.ScriptScopeName), v => v.Name == "$simpleDictionary"); Assert.NotNull(simpleDictionaryVar); VariableDetailsBase rawDetailsView = Array.Find( @@ -1023,14 +1023,14 @@ await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true public async Task DebuggerDerivedDictionaryPropertyInRawView() { CommandBreakpointDetails breakpoint = CommandBreakpointDetails.Create("__BreakDebuggerDerivedDictionaryPropertyInRawView"); - await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }).ConfigureAwait(true); + await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(commandBreakpointDetails: breakpoint); VariableDetailsBase sortedDictionaryVar = Array.Find( - await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true), + await GetVariables(VariableContainerDetails.ScriptScopeName), v => v.Name == "$sortedDictionary"); Assert.NotNull(sortedDictionaryVar); VariableDetailsBase[] simpleDictionaryChildren = sortedDictionaryVar.GetChildren(NullLogger.Instance); @@ -1072,21 +1072,21 @@ public async Task DebuggerVariablePSCustomObjectDisplaysCorrectly() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 18) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 18) }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); - VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None).ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); + VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$psCustomObjVar"); Assert.NotNull(var); Assert.Equal("@{Name=Paul; Age=73}", var.ValueString); Assert.True(var.IsExpandable); - VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None); Assert.Equal(2, childVars.Length); Assert.Equal("Name", childVars[0].Name); Assert.Equal("\"Paul\"", childVars[0].ValueString); @@ -1101,21 +1101,21 @@ public async Task DebuggerVariableProcessObjectDisplaysCorrectly() { await debugService.SetLineBreakpointsAsync( variableScriptFile, - new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 19) }).ConfigureAwait(true); + new[] { BreakpointDetails.Create(variableScriptFile.FilePath, 19) }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(variableScriptFile.FilePath); - StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true); - VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None).ConfigureAwait(true); + StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync(); + VariableDetailsBase[] variables = await debugService.GetVariables(stackFrames[0].AutoVariables.Id, CancellationToken.None); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$procVar"); Assert.NotNull(var); Assert.StartsWith("System.Diagnostics.Process", var.ValueString); Assert.True(var.IsExpandable); - VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None); Assert.Contains(childVars, i => i.Name is "Name"); Assert.Contains(childVars, i => i.Name is "Handles"); #if CoreCLR @@ -1130,15 +1130,15 @@ await debugService.SetLineBreakpointsAsync( public async Task DebuggerVariableFileObjectDisplaysCorrectly() { await debugService.SetCommandBreakpointsAsync( - new[] { CommandBreakpointDetails.Create("Write-Host") }).ConfigureAwait(true); + new[] { CommandBreakpointDetails.Create("Write-Host") }); ScriptFile testScript = GetDebugScript("GetChildItemTest.ps1"); Task _ = ExecuteScriptFileAsync(testScript.FilePath); AssertDebuggerStopped(testScript.FilePath, 2); - VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName).ConfigureAwait(true); + VariableDetailsBase[] variables = await GetVariables(VariableContainerDetails.LocalScopeName); VariableDetailsBase var = Array.Find(variables, v => v.Name == "$file"); - VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] childVars = await debugService.GetVariables(var.Id, CancellationToken.None); Assert.Contains(childVars, i => i.Name is "PSPath"); Assert.Contains(childVars, i => i.Name is "PSProvider" && i.ValueString is @"Microsoft.PowerShell.Core\FileSystem"); Assert.Contains(childVars, i => i.Name is "Exists" && i.ValueString is "$true"); @@ -1150,17 +1150,17 @@ await debugService.SetCommandBreakpointsAsync( public async Task DebuggerToStringShouldMarshallToPipeline() { CommandBreakpointDetails breakpoint = CommandBreakpointDetails.Create("__BreakDebuggerToStringShouldMarshallToPipeline"); - await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }).ConfigureAwait(true); + await debugService.SetCommandBreakpointsAsync(new[] { breakpoint }); // Execute the script and wait for the breakpoint to be hit Task _ = ExecuteVariableScriptFileAsync(); AssertDebuggerStopped(commandBreakpointDetails: breakpoint); - VariableDetailsBase[] vars = await GetVariables(VariableContainerDetails.ScriptScopeName).ConfigureAwait(true); + VariableDetailsBase[] vars = await GetVariables(VariableContainerDetails.ScriptScopeName); VariableDetailsBase customToStrings = Array.Find(vars, i => i.Name is "$CustomToStrings"); Assert.True(customToStrings.IsExpandable); Assert.Equal("[System.Object[]]", customToStrings.Type); - VariableDetailsBase[] childVars = await debugService.GetVariables(customToStrings.Id, CancellationToken.None).ConfigureAwait(true); + VariableDetailsBase[] childVars = await debugService.GetVariables(customToStrings.Id, CancellationToken.None); // Check everything but the last variable (which is "Raw View") Assert.Equal(1001, childVars.Length); // 1000 custom variables plus "Raw View" Assert.All(childVars.Take(childVars.Length - 1), i => diff --git a/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs b/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs index 613202094..a740f6fd6 100644 --- a/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs +++ b/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs @@ -69,18 +69,18 @@ await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript( "function Invoke-Extension { $global:extensionValue = 5 }; " + $"Register-EditorCommand -Name {commandName} -DisplayName \"{commandDisplayName}\" -Function Invoke-Extension"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.NotNull(commandAdded); Assert.Equal(commandName, commandAdded.Name); Assert.Equal(commandDisplayName, commandAdded.DisplayName); // Invoke the command - await extensionCommandService.InvokeCommandAsync(commandName, editorContext).ConfigureAwait(true); + await extensionCommandService.InvokeCommandAsync(commandName, editorContext); // Assert the expected value PSCommand psCommand = new PSCommand().AddScript("$global:extensionValue"); - IEnumerable results = await psesHost.ExecutePSCommandAsync(psCommand, CancellationToken.None).ConfigureAwait(true); + IEnumerable results = await psesHost.ExecutePSCommandAsync(psCommand, CancellationToken.None); Assert.Equal(5, results.FirstOrDefault()); } @@ -107,7 +107,7 @@ await psesHost.ExecutePSCommandAsync( .AddParameter("Name", commandName) .AddParameter("DisplayName", commandDisplayName) .AddParameter("ScriptBlock", ScriptBlock.Create("$global:extensionValue = 10")), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.NotNull(commandAdded); Assert.Equal(commandName, commandAdded.Name); @@ -115,11 +115,11 @@ await psesHost.ExecutePSCommandAsync( // Invoke the command. // TODO: What task was this cancelling? - await extensionCommandService.InvokeCommandAsync("test.scriptblock", editorContext).ConfigureAwait(true); + await extensionCommandService.InvokeCommandAsync("test.scriptblock", editorContext); // Assert the expected value PSCommand psCommand = new PSCommand().AddScript("$global:extensionValue"); - IEnumerable results = await psesHost.ExecutePSCommandAsync(psCommand, CancellationToken.None).ConfigureAwait(true); + IEnumerable results = await psesHost.ExecutePSCommandAsync(psCommand, CancellationToken.None); Assert.Equal(10, results.FirstOrDefault()); } @@ -138,7 +138,7 @@ await psesHost.ExecutePSCommandAsync( "function Invoke-Extension { Write-Output \"Extension output!\" }; " + $"Register-EditorCommand -Name {commandName} -DisplayName \"Old function extension\" -Function Invoke-Extension; " + $"Register-EditorCommand -Name {commandName} -DisplayName \"{commandDisplayName}\" -Function Invoke-Extension"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // Wait for the add and update events Assert.NotNull(updatedCommand); @@ -170,12 +170,12 @@ await psesHost.ExecutePSCommandAsync( .AddParameter("Name", commandName) .AddParameter("DisplayName", commandDisplayName) .AddParameter("ScriptBlock", ScriptBlock.Create("Write-Output \"Extension output!\"")), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // Remove the command and wait for the remove event await psesHost.ExecutePSCommandAsync( new PSCommand().AddCommand("Unregister-EditorCommand").AddParameter("Name", commandName), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.NotNull(removedCommand); Assert.Equal(commandName, removedCommand.Name); @@ -183,7 +183,7 @@ await psesHost.ExecutePSCommandAsync( // Ensure that the command has been unregistered await Assert.ThrowsAsync( - () => extensionCommandService.InvokeCommandAsync("test.scriptblock", editorContext)).ConfigureAwait(true); + () => extensionCommandService.InvokeCommandAsync("test.scriptblock", editorContext)); } [Fact] @@ -193,7 +193,7 @@ public async Task CannotRemovePSEditorVariable() () => psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Remove-Variable psEditor -ErrorAction Stop"), CancellationToken.None) - ).ConfigureAwait(true); + ); Assert.Equal( "The running command stopped because the preference variable \"ErrorActionPreference\" or common parameter is set to Stop: Cannot remove variable psEditor because it is constant or read-only. If the variable is read-only, try the operation again specifying the Force option.", diff --git a/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs b/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs index d47afa38e..abbd2c96e 100644 --- a/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs +++ b/test/PowerShellEditorServices.Test/Language/CompletionHandlerTests.cs @@ -56,7 +56,7 @@ private Task GetCompletionResultsAsync(ScriptRegion scriptReg [Fact] public async Task CompletesCommandInFile() { - (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteCommandInFile.SourceDetails).ConfigureAwait(true); + (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteCommandInFile.SourceDetails); CompletionItem actual = Assert.Single(results); Assert.Equal(CompleteCommandInFile.ExpectedCompletion, actual); } @@ -64,7 +64,7 @@ public async Task CompletesCommandInFile() [Fact] public async Task CompletesCommandFromModule() { - (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteCommandFromModule.SourceDetails).ConfigureAwait(true); + (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteCommandFromModule.SourceDetails); CompletionItem actual = Assert.Single(results); // NOTE: The tooltip varies across PowerShell and OS versions, so we ignore it. Assert.Equal(CompleteCommandFromModule.ExpectedCompletion, actual with { Detail = "" }); @@ -75,7 +75,7 @@ public async Task CompletesCommandFromModule() public async Task CompletesTypeName() { Skip.If(VersionUtils.PSEdition == "Desktop", "Windows PowerShell has trouble with this test right now."); - (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteTypeName.SourceDetails).ConfigureAwait(true); + (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteTypeName.SourceDetails); CompletionItem actual = Assert.Single(results); if (VersionUtils.IsNetCore) { @@ -96,7 +96,7 @@ public async Task CompletesTypeName() public async Task CompletesNamespace() { Skip.If(VersionUtils.PSEdition == "Desktop", "Windows PowerShell has trouble with this test right now."); - (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteNamespace.SourceDetails).ConfigureAwait(true); + (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteNamespace.SourceDetails); CompletionItem actual = Assert.Single(results); Assert.Equal(CompleteNamespace.ExpectedCompletion, actual); } @@ -104,7 +104,7 @@ public async Task CompletesNamespace() [Fact] public async Task CompletesVariableInFile() { - (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteVariableInFile.SourceDetails).ConfigureAwait(true); + (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteVariableInFile.SourceDetails); CompletionItem actual = Assert.Single(results); Assert.Equal(CompleteVariableInFile.ExpectedCompletion, actual); } @@ -112,7 +112,7 @@ public async Task CompletesVariableInFile() [Fact] public async Task CompletesAttributeValue() { - (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteAttributeValue.SourceDetails).ConfigureAwait(true); + (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteAttributeValue.SourceDetails); // NOTE: Since the completions come through un-ordered from PowerShell, their SortText // (which has an index prepended from the original order) will mis-match our assumed // order; hence we ignore it. @@ -125,7 +125,7 @@ public async Task CompletesAttributeValue() [Fact] public async Task CompletesFilePath() { - (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteFilePath.SourceDetails).ConfigureAwait(true); + (_, IEnumerable results) = await GetCompletionResultsAsync(CompleteFilePath.SourceDetails); Assert.NotEmpty(results); CompletionItem actual = results.First(); // Paths are system dependent so we ignore the text and just check the type and range. diff --git a/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs b/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs index 100b1ee8e..f078d8d42 100644 --- a/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs @@ -99,14 +99,14 @@ private async Task> GetDefinitions(ScriptRegion scr Assert.NotNull(symbol); IEnumerable symbols = - await symbolsService.GetDefinitionOfSymbolAsync(scriptFile, symbol).ConfigureAwait(true); + await symbolsService.GetDefinitionOfSymbolAsync(scriptFile, symbol); return symbols.OrderBy((i) => i.ScriptRegion.ToRange().Start); } private async Task GetDefinition(ScriptRegion scriptRegion) { - IEnumerable definitions = await GetDefinitions(scriptRegion).ConfigureAwait(true); + IEnumerable definitions = await GetDefinitions(scriptRegion); return definitions.FirstOrDefault(); } @@ -122,7 +122,7 @@ private async Task> GetReferences(ScriptRegion scri Assert.NotNull(symbol); IEnumerable symbols = - await symbolsService.ScanForReferencesOfSymbolAsync(symbol).ConfigureAwait(true); + await symbolsService.ScanForReferencesOfSymbolAsync(symbol); return symbols.OrderBy((i) => i.ScriptRegion.ToRange().Start); } @@ -149,7 +149,7 @@ private IEnumerable FindSymbolsInFile(ScriptRegion scriptRegion public async Task FindsParameterHintsOnCommand() { // TODO: Fix signatures to use parameters, not sets. - ParameterSetSignatures signatures = await GetParamSetSignatures(FindsParameterSetsOnCommandData.SourceDetails).ConfigureAwait(true); + ParameterSetSignatures signatures = await GetParamSetSignatures(FindsParameterSetsOnCommandData.SourceDetails); Assert.NotNull(signatures); Assert.Equal("Get-Process", signatures.CommandName); Assert.Equal(6, signatures.Signatures.Length); @@ -158,7 +158,7 @@ public async Task FindsParameterHintsOnCommand() [Fact] public async Task FindsCommandForParamHintsWithSpaces() { - ParameterSetSignatures signatures = await GetParamSetSignatures(FindsParameterSetsOnCommandWithSpacesData.SourceDetails).ConfigureAwait(true); + ParameterSetSignatures signatures = await GetParamSetSignatures(FindsParameterSetsOnCommandWithSpacesData.SourceDetails); Assert.NotNull(signatures); Assert.Equal("Write-Host", signatures.CommandName); Assert.Single(signatures.Signatures); @@ -167,7 +167,7 @@ public async Task FindsCommandForParamHintsWithSpaces() [Fact] public async Task FindsFunctionDefinition() { - SymbolReference symbol = await GetDefinition(FindsFunctionDefinitionData.SourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsFunctionDefinitionData.SourceDetails); Assert.Equal("fn My-Function", symbol.Id); Assert.Equal("function My-Function ($myInput)", symbol.Name); Assert.Equal(SymbolType.Function, symbol.Type); @@ -183,9 +183,9 @@ public async Task FindsFunctionDefinitionForAlias() // being defined in the runspace. await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Set-Alias -Name My-Alias -Value My-Function"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); - SymbolReference symbol = await GetDefinition(FindsFunctionDefinitionOfAliasData.SourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsFunctionDefinitionOfAliasData.SourceDetails); Assert.Equal("function My-Function ($myInput)", symbol.Name); Assert.Equal(SymbolType.Function, symbol.Type); AssertIsRegion(symbol.NameRegion, 1, 10, 1, 21); @@ -196,7 +196,7 @@ await psesHost.ExecutePSCommandAsync( [Fact] public async Task FindsReferencesOnFunction() { - IEnumerable symbols = await GetReferences(FindsReferencesOnFunctionData.SourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnFunctionData.SourceDetails); Assert.Collection(symbols, (i) => { @@ -246,7 +246,7 @@ public async Task FindsReferenceAcrossMultiRootWorkspace() }).ToList(); SymbolReference symbol = new("fn Get-Process", SymbolType.Function); - IEnumerable symbols = await symbolsService.ScanForReferencesOfSymbolAsync(symbol).ConfigureAwait(true); + IEnumerable symbols = await symbolsService.ScanForReferencesOfSymbolAsync(symbol); Assert.Collection(symbols.OrderBy(i => i.FilePath), i => Assert.EndsWith("VariableTest.ps1", i.FilePath), i => Assert.EndsWith("ParamHints.ps1", i.FilePath), @@ -259,9 +259,9 @@ public async Task FindsReferencesOnFunctionIncludingAliases() // TODO: Same as in FindsFunctionDefinitionForAlias. await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Set-Alias -Name My-Alias -Value My-Function"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); - IEnumerable symbols = await GetReferences(FindsReferencesOnFunctionData.SourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnFunctionData.SourceDetails); Assert.Collection(symbols, (i) => AssertIsRegion(i.NameRegion, 1, 10, 1, 21), @@ -280,7 +280,7 @@ await psesHost.ExecutePSCommandAsync( [Fact] public async Task FindsFunctionDefinitionInWorkspace() { - IEnumerable symbols = await GetDefinitions(FindsFunctionDefinitionInWorkspaceData.SourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetDefinitions(FindsFunctionDefinitionInWorkspaceData.SourceDetails); SymbolReference symbol = Assert.Single(symbols); Assert.Equal("fn My-Function", symbol.Id); Assert.Equal("function My-Function ($myInput)", symbol.Name); @@ -291,7 +291,7 @@ public async Task FindsFunctionDefinitionInWorkspace() [Fact] public async Task FindsVariableDefinition() { - IEnumerable definitions = await GetDefinitions(FindsVariableDefinitionData.SourceDetails).ConfigureAwait(true); + IEnumerable definitions = await GetDefinitions(FindsVariableDefinitionData.SourceDetails); SymbolReference symbol = Assert.Single(definitions); // Even though it's re-assigned Assert.Equal("var things", symbol.Id); Assert.Equal("$things", symbol.Name); @@ -303,7 +303,7 @@ public async Task FindsVariableDefinition() [Fact] public async Task FindsTypedVariableDefinition() { - IEnumerable definitions = await GetDefinitions(FindsTypedVariableDefinitionData.SourceDetails).ConfigureAwait(true); + IEnumerable definitions = await GetDefinitions(FindsTypedVariableDefinitionData.SourceDetails); SymbolReference symbol = Assert.Single(definitions); Assert.Equal("var hello", symbol.Id); Assert.Equal("$hello", symbol.Name); @@ -315,7 +315,7 @@ public async Task FindsTypedVariableDefinition() [Fact] public async Task FindsReferencesOnVariable() { - IEnumerable symbols = await GetReferences(FindsReferencesOnVariableData.SourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnVariableData.SourceDetails); Assert.Collection(symbols, (i) => { @@ -402,7 +402,7 @@ public void FindsOccurrencesOnParameter() public async Task FindsReferencesOnCommandWithAlias() { // NOTE: This doesn't use GetOccurrences as it's testing for aliases. - IEnumerable symbols = await GetReferences(FindsReferencesOnBuiltInCommandWithAliasData.SourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnBuiltInCommandWithAliasData.SourceDetails); Assert.Collection(symbols.Where( (i) => i.FilePath .EndsWith(FindsReferencesOnBuiltInCommandWithAliasData.SourceDetails.File)), @@ -415,7 +415,7 @@ public async Task FindsReferencesOnCommandWithAlias() [Fact] public async Task FindsClassDefinition() { - SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.ClassSourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.ClassSourceDetails); Assert.Equal("type SuperClass", symbol.Id); Assert.Equal("class SuperClass { }", symbol.Name); Assert.Equal(SymbolType.Class, symbol.Type); @@ -426,7 +426,7 @@ public async Task FindsClassDefinition() [Fact] public async Task FindsReferencesOnClass() { - IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.ClassSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.ClassSourceDetails); Assert.Collection(symbols, (i) => { @@ -449,7 +449,7 @@ public async Task FindsReferencesOnClass() [Fact] public async Task FindsEnumDefinition() { - SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.EnumSourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.EnumSourceDetails); Assert.Equal("type MyEnum", symbol.Id); Assert.Equal("enum MyEnum { }", symbol.Name); Assert.Equal(SymbolType.Enum, symbol.Type); @@ -460,7 +460,7 @@ public async Task FindsEnumDefinition() [Fact] public async Task FindsReferencesOnEnum() { - IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.EnumSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.EnumSourceDetails); Assert.Collection(symbols, (i) => { @@ -497,7 +497,7 @@ public async Task FindsReferencesOnEnum() [Fact] public async Task FindsTypeExpressionDefinition() { - SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.TypeExpressionSourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.TypeExpressionSourceDetails); AssertIsRegion(symbol.NameRegion, 39, 6, 39, 12); Assert.Equal("type MyEnum", symbol.Id); Assert.Equal("enum MyEnum { }", symbol.Name); @@ -507,7 +507,7 @@ public async Task FindsTypeExpressionDefinition() [Fact] public async Task FindsReferencesOnTypeExpression() { - IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.TypeExpressionSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.TypeExpressionSourceDetails); Assert.Collection(symbols, (i) => { @@ -530,7 +530,7 @@ public async Task FindsReferencesOnTypeExpression() [Fact] public async Task FindsTypeConstraintDefinition() { - SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.TypeConstraintSourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.TypeConstraintSourceDetails); AssertIsRegion(symbol.NameRegion, 39, 6, 39, 12); Assert.Equal("type MyEnum", symbol.Id); Assert.Equal("enum MyEnum { }", symbol.Name); @@ -540,7 +540,7 @@ public async Task FindsTypeConstraintDefinition() [Fact] public async Task FindsReferencesOnTypeConstraint() { - IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.TypeConstraintSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.TypeConstraintSourceDetails); Assert.Collection(symbols, (i) => { @@ -596,7 +596,7 @@ public void FindsOccurrencesOnTypeConstraint() [Fact] public async Task FindsConstructorDefinition() { - IEnumerable symbols = await GetDefinitions(FindsTypeSymbolsDefinitionData.ConstructorSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetDefinitions(FindsTypeSymbolsDefinitionData.ConstructorSourceDetails); Assert.Collection(symbols, (i) => { @@ -613,14 +613,14 @@ public async Task FindsConstructorDefinition() Assert.True(i.IsDeclaration); }); - Assert.Equal(symbols, await GetReferences(FindsReferencesOnTypeSymbolsData.ConstructorSourceDetails).ConfigureAwait(true)); + Assert.Equal(symbols, await GetReferences(FindsReferencesOnTypeSymbolsData.ConstructorSourceDetails)); Assert.Equal(symbols, GetOccurrences(FindsOccurrencesOnTypeSymbolsData.ConstructorSourceDetails)); } [Fact] public async Task FindsMethodDefinition() { - IEnumerable symbols = await GetDefinitions(FindsTypeSymbolsDefinitionData.MethodSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetDefinitions(FindsTypeSymbolsDefinitionData.MethodSourceDetails); Assert.Collection(symbols, (i) => { @@ -648,7 +648,7 @@ public async Task FindsMethodDefinition() [Fact] public async Task FindsReferencesOnMethod() { - IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.MethodSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.MethodSourceDetails); Assert.Collection(symbols, (i) => Assert.Equal("string MyClassMethod([string]$param1, $param2, [int]$param3)", i.Name), (i) => Assert.Equal("string MyClassMethod([MyEnum]$param1)", i.Name), @@ -668,7 +668,7 @@ public async Task FindsReferencesOnMethod() [Fact] public async Task FindsPropertyDefinition() { - SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.PropertySourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.PropertySourceDetails); Assert.Equal("prop SomePropWithDefault", symbol.Id); Assert.Equal("[string] $SomePropWithDefault", symbol.Name); Assert.Equal(SymbolType.Property, symbol.Type); @@ -678,7 +678,7 @@ public async Task FindsPropertyDefinition() [Fact] public async Task FindsReferencesOnProperty() { - IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.PropertySourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.PropertySourceDetails); Assert.Collection(symbols, (i) => { @@ -720,7 +720,7 @@ public void FindsOccurrencesOnProperty() [Fact] public async Task FindsEnumMemberDefinition() { - SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.EnumMemberSourceDetails).ConfigureAwait(true); + SymbolReference symbol = await GetDefinition(FindsTypeSymbolsDefinitionData.EnumMemberSourceDetails); Assert.Equal("prop Second", symbol.Id); // Doesn't include [MyEnum]:: because that'd be redundant in the outline. Assert.Equal("Second", symbol.Name); @@ -728,7 +728,7 @@ public async Task FindsEnumMemberDefinition() Assert.True(symbol.IsDeclaration); AssertIsRegion(symbol.NameRegion, 41, 5, 41, 11); - symbol = await GetDefinition(FindsReferencesOnTypeSymbolsData.EnumMemberSourceDetails).ConfigureAwait(true); + symbol = await GetDefinition(FindsReferencesOnTypeSymbolsData.EnumMemberSourceDetails); Assert.Equal("prop First", symbol.Id); Assert.Equal("First", symbol.Name); Assert.Equal(SymbolType.EnumMember, symbol.Type); @@ -739,7 +739,7 @@ public async Task FindsEnumMemberDefinition() [Fact] public async Task FindsReferencesOnEnumMember() { - IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.EnumMemberSourceDetails).ConfigureAwait(true); + IEnumerable symbols = await GetReferences(FindsReferencesOnTypeSymbolsData.EnumMemberSourceDetails); Assert.Collection(symbols, (i) => { @@ -768,7 +768,7 @@ public async Task FindsDetailsForBuiltInCommand() GetScriptFile(FindsDetailsForBuiltInCommandData.SourceDetails), FindsDetailsForBuiltInCommandData.SourceDetails.StartLineNumber, FindsDetailsForBuiltInCommandData.SourceDetails.StartColumnNumber, - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Equal("Gets the processes that are running on the local computer.", symbolDetails.Documentation); } @@ -907,7 +907,7 @@ public void FindsSymbolsWithNewLineInFile() AssertIsRegion(symbol.ScriptRegion, 27, 5, 27, 10); } - [Fact(Skip="DSC symbols don't work yet.")] + [Fact(Skip = "DSC symbols don't work yet.")] public void FindsSymbolsInDSCFile() { Skip.If(!s_isWindows, "DSC only works properly on Windows."); diff --git a/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs b/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs index ca3f3ae04..b34bbe650 100644 --- a/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs +++ b/test/PowerShellEditorServices.Test/Services/Symbols/PSScriptAnalyzerTests.cs @@ -51,8 +51,7 @@ public async Task CanLoadPSScriptAnalyzerAsync() { ScriptFileMarker[] violations = await analysisService .AnalysisEngine - .AnalyzeScriptAsync(script) - .ConfigureAwait(true); + .AnalyzeScriptAsync(script); Assert.Collection(violations, (actual) => @@ -72,14 +71,12 @@ public async Task DoesNotDuplicateScriptMarkersAsync() ScriptFile[] scriptFiles = { scriptFile }; await analysisService - .DelayThenInvokeDiagnosticsAsync(scriptFiles, CancellationToken.None) - .ConfigureAwait(true); + .DelayThenInvokeDiagnosticsAsync(scriptFiles, CancellationToken.None); Assert.Single(scriptFile.DiagnosticMarkers); // This is repeated to test that the markers are not duplicated. await analysisService - .DelayThenInvokeDiagnosticsAsync(scriptFiles, CancellationToken.None) - .ConfigureAwait(true); + .DelayThenInvokeDiagnosticsAsync(scriptFiles, CancellationToken.None); Assert.Single(scriptFile.DiagnosticMarkers); } @@ -91,8 +88,7 @@ public async Task DoesNotClearParseErrorsAsync() ScriptFile[] scriptFiles = { scriptFile }; await analysisService - .DelayThenInvokeDiagnosticsAsync(scriptFiles, CancellationToken.None) - .ConfigureAwait(true); + .DelayThenInvokeDiagnosticsAsync(scriptFiles, CancellationToken.None); Assert.Collection(scriptFile.DiagnosticMarkers, (actual) => diff --git a/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs b/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs index 1e141bbc9..d489704f4 100644 --- a/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs +++ b/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs @@ -40,7 +40,7 @@ public async Task CanExecutePSCommand() Assert.True(psesHost.IsRunning); PSCommand command = new PSCommand().AddScript("$a = \"foo\"; $a"); Task> task = psesHost.ExecutePSCommandAsync(command, CancellationToken.None); - IReadOnlyList result = await task.ConfigureAwait(true); + IReadOnlyList result = await task; Assert.Equal("foo", result[0]); } @@ -50,7 +50,7 @@ public async Task CanHandleThrow() await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("throw"), CancellationToken.None, - new PowerShellExecutionOptions { ThrowOnError = false }).ConfigureAwait(true); + new PowerShellExecutionOptions { ThrowOnError = false }); } [Fact] @@ -74,14 +74,14 @@ public async Task CanQueueParallelPSCommands() CancellationToken.None); // Wait for all of the executes to complete. - await Task.WhenAll(taskOne, taskTwo, taskThree, resultTask).ConfigureAwait(true); + await Task.WhenAll(taskOne, taskTwo, taskThree, resultTask); // Sanity checks Assert.Equal(RunspaceState.Opened, psesHost.Runspace.RunspaceStateInfo.State); // 100 + 200 = 300, then divided by 100 is 3. We are ensuring that // the commands were executed in the sequence they were called. - Assert.Equal(3, (await resultTask.ConfigureAwait(true))[0]); + Assert.Equal(3, (await resultTask)[0]); } [Fact] @@ -93,7 +93,7 @@ public async Task CanCancelExecutionWithToken() return psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Start-Sleep 10"), cancellationSource.Token); - }).ConfigureAwait(true); + }); } [Fact] @@ -107,7 +107,7 @@ public async Task CanCancelExecutionWithMethod() // Wait until our task has started. Thread.Sleep(2000); psesHost.CancelCurrentTask(); - await Assert.ThrowsAsync(() => executeTask).ConfigureAwait(true); + await Assert.ThrowsAsync(() => executeTask); Assert.True(executeTask.IsCanceled); } @@ -126,7 +126,7 @@ await psesHost.ExecuteDelegateAsync( pwsh.LoadProfiles(emptyProfilePaths); Assert.Empty(pwsh.Commands.Commands); }, - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); } // NOTE: Tests where we call functions that use PowerShell runspaces are slightly more @@ -142,13 +142,13 @@ public async Task CanHandleBrokenPrompt() return psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("function prompt { throw }; prompt"), CancellationToken.None); - }).ConfigureAwait(true); + }); string prompt = await psesHost.ExecuteDelegateAsync( nameof(psesHost.GetPrompt), executionOptions: null, (_, _) => psesHost.GetPrompt(CancellationToken.None), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Equal(PsesInternalHost.DefaultPrompt, prompt); } @@ -158,13 +158,13 @@ public async Task CanHandleUndefinedPrompt() { Assert.Empty(await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Remove-Item function:prompt; Get-Item function:prompt -ErrorAction Ignore"), - CancellationToken.None).ConfigureAwait(true)); + CancellationToken.None)); string prompt = await psesHost.ExecuteDelegateAsync( nameof(psesHost.GetPrompt), executionOptions: null, (_, _) => psesHost.GetPrompt(CancellationToken.None), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Equal(PsesInternalHost.DefaultPrompt, prompt); } @@ -174,11 +174,11 @@ public async Task CanRunOnIdleTask() { IReadOnlyList task = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("$handled = $false; Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -MaxTriggerCount 1 -Action { $global:handled = $true }"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); IReadOnlyList handled = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("$handled"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Collection(handled, Assert.False); @@ -186,14 +186,14 @@ await psesHost.ExecuteDelegateAsync( nameof(psesHost.OnPowerShellIdle), executionOptions: null, (_, _) => psesHost.OnPowerShellIdle(CancellationToken.None), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // TODO: Why is this racy? Thread.Sleep(2000); handled = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("$handled"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Collection(handled, Assert.True); } @@ -208,7 +208,7 @@ public async Task CanLoadPSReadLine() pwsh, (EngineIntrinsics)pwsh.Runspace.SessionStateProxy.GetVariable("ExecutionContext"), out IReadLine readLine), - CancellationToken.None).ConfigureAwait(true)); + CancellationToken.None)); } // This test asserts that we do not mess up the console encoding, which leads to native @@ -218,7 +218,7 @@ public async Task ExecutesNativeCommandsCorrectly() { await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("\"protocol=https`nhost=myhost.com`nusername=john`npassword=doe`n`n\" | git.exe credential approve; if ($LastExitCode) { throw }"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); } [Theory] @@ -228,11 +228,11 @@ await psesHost.ExecutePSCommandAsync( public async Task CanHandleBadInitialWorkingDirectory(string path) { string cwd = Environment.CurrentDirectory; - await psesHost.SetInitialWorkingDirectoryAsync(path, CancellationToken.None).ConfigureAwait(true); + await psesHost.SetInitialWorkingDirectoryAsync(path, CancellationToken.None); IReadOnlyList getLocation = await psesHost.ExecutePSCommandAsync( new PSCommand().AddCommand("Get-Location"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Collection(getLocation, (d) => Assert.Equal(cwd, d, ignoreCase: true)); } } @@ -258,7 +258,7 @@ public async Task CanResolveAndLoadProfilesForHostId() // Ensure that the $PROFILE variable is a string with the value of CurrentUserCurrentHost. IReadOnlyList profileVariable = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("$PROFILE"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Collection(profileVariable, (p) => Assert.Equal(PsesHostFactory.TestProfilePaths.CurrentUserCurrentHost, p)); @@ -266,7 +266,7 @@ public async Task CanResolveAndLoadProfilesForHostId() // Ensure that all the profile paths are set in the correct note properties. IReadOnlyList profileProperties = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("$PROFILE | Get-Member -Type NoteProperty"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Collection(profileProperties, (p) => Assert.Equal($"string AllUsersAllHosts={PsesHostFactory.TestProfilePaths.AllUsersAllHosts}", p, ignoreCase: true), @@ -277,7 +277,7 @@ public async Task CanResolveAndLoadProfilesForHostId() // Ensure that the profile was loaded. The profile also checks that $PROFILE was defined. IReadOnlyList profileLoaded = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Assert-ProfileLoaded"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Collection(profileLoaded, Assert.True); } @@ -292,14 +292,14 @@ await psesHost.ExecuteDelegateAsync( nameof(psesHost.OnPowerShellIdle), executionOptions: null, (_, _) => psesHost.OnPowerShellIdle(CancellationToken.None), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); // TODO: Why is this racy? Thread.Sleep(2000); IReadOnlyList handled = await psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("$handledInProfile"), - CancellationToken.None).ConfigureAwait(true); + CancellationToken.None); Assert.Collection(handled, Assert.True); }