Skip to content

Commit 9d6526b

Browse files
committed
Fix CA2007 (missing .ConfigureAwait(false))
1 parent ea09dff commit 9d6526b

File tree

16 files changed

+101
-102
lines changed

16 files changed

+101
-102
lines changed

src/PowerShellEditorServices.VSCode/CustomViews/CustomViewBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ await languageServer.SendRequestAsync(
3838
Title = this.Title,
3939
ViewType = this.ViewType,
4040
}
41-
);
41+
).ConfigureAwait(false);
4242
}
4343

4444
public async Task Show(ViewColumn viewColumn)
@@ -50,7 +50,7 @@ await languageServer.SendRequestAsync(
5050
Id = this.Id,
5151
ViewColumn = viewColumn
5252
}
53-
);
53+
).ConfigureAwait(false);
5454
}
5555

5656
public async Task Close()
@@ -61,7 +61,7 @@ await languageServer.SendRequestAsync(
6161
{
6262
Id = this.Id,
6363
}
64-
);
64+
).ConfigureAwait(false);
6565
}
6666
}
6767
}

src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ await languageServer.SendRequestAsync(
3030
Id = this.Id,
3131
HtmlContent = new HtmlContent { BodyContent = htmlBodyContent }
3232
}
33-
);
33+
).ConfigureAwait(false);
3434
}
3535

3636
public async Task SetContentAsync(HtmlContent htmlContent)
@@ -50,7 +50,7 @@ await languageServer.SendRequestAsync(
5050
Id = this.Id,
5151
HtmlContent = validatedContent
5252
}
53-
);
53+
).ConfigureAwait(false);
5454
}
5555

5656
public async Task AppendContentAsync(string appendedHtmlBodyContent)
@@ -62,7 +62,7 @@ await languageServer.SendRequestAsync(
6262
Id = this.Id,
6363
AppendedHtmlBodyContent = appendedHtmlBodyContent
6464
}
65-
);
65+
).ConfigureAwait(false);
6666
}
6767

6868
private string[] GetUriPaths(string[] filePaths)

src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentViewsFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task<IHtmlContentView> CreateHtmlContentViewAsync(string viewTitle)
2121
viewTitle,
2222
languageServer);
2323

24-
await htmlView.CreateAsync();
24+
await htmlView.CreateAsync().ConfigureAwait(false);
2525
this.AddView(htmlView);
2626

2727
return htmlView;

src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public async Task<string> PromptInputAsync(string message)
116116
new ShowInputPromptRequest
117117
{
118118
Name = message,
119-
}).Returning<ShowInputPromptResponse>(CancellationToken.None);
119+
}).Returning<ShowInputPromptResponse>(CancellationToken.None).ConfigureAwait(false);
120120

121121
if (response.PromptCancelled)
122122
{
@@ -142,7 +142,7 @@ public async Task<IReadOnlyList<string>> PromptMultipleSelectionAsync(string mes
142142
Message = message,
143143
Choices = choiceDetails,
144144
DefaultChoices = defaultChoiceIndexes?.ToArray(),
145-
}).Returning<ShowChoicePromptResponse>(CancellationToken.None);
145+
}).Returning<ShowChoicePromptResponse>(CancellationToken.None).ConfigureAwait(false);
146146

147147
if (response.PromptCancelled)
148148
{
@@ -168,7 +168,7 @@ public async Task<string> PromptSelectionAsync(string message, IReadOnlyList<Pro
168168
Message = message,
169169
Choices = choiceDetails,
170170
DefaultChoices = defaultChoiceIndex > -1 ? new[] { defaultChoiceIndex } : null,
171-
}).Returning<ShowChoicePromptResponse>(CancellationToken.None);
171+
}).Returning<ShowChoicePromptResponse>(CancellationToken.None).ConfigureAwait(false);
172172

173173
if (response.PromptCancelled)
174174
{

src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public async Task<List<Breakpoint>> GetBreakpointsAsync()
4747
// Legacy behavior
4848
PSCommand psCommand = new PSCommand();
4949
psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Get-PSBreakpoint");
50-
IEnumerable<Breakpoint> breakpoints = await _powerShellContextService.ExecuteCommandAsync<Breakpoint>(psCommand);
50+
IEnumerable<Breakpoint> breakpoints = await _powerShellContextService.ExecuteCommandAsync<Breakpoint>(psCommand).ConfigureAwait(false);
5151
return breakpoints.ToList();
5252
}
5353

@@ -133,7 +133,7 @@ public async Task<IEnumerable<BreakpointDetails>> SetBreakpointsAsync(string esc
133133
if (psCommand != null)
134134
{
135135
IEnumerable<Breakpoint> setBreakpoints =
136-
await _powerShellContextService.ExecuteCommandAsync<Breakpoint>(psCommand);
136+
await _powerShellContextService.ExecuteCommandAsync<Breakpoint>(psCommand).ConfigureAwait(false);
137137
configuredBreakpoints.AddRange(
138138
setBreakpoints.Select(BreakpointDetails.Create));
139139
}
@@ -210,7 +210,7 @@ public async Task<IEnumerable<CommandBreakpointDetails>> SetCommandBreakpoints(I
210210
if (psCommand != null)
211211
{
212212
IEnumerable<Breakpoint> setBreakpoints =
213-
await _powerShellContextService.ExecuteCommandAsync<Breakpoint>(psCommand);
213+
await _powerShellContextService.ExecuteCommandAsync<Breakpoint>(psCommand).ConfigureAwait(false);
214214
configuredBreakpoints.AddRange(
215215
setBreakpoints.Select(CommandBreakpointDetails.Create));
216216
}
@@ -301,7 +301,7 @@ public async Task RemoveBreakpointsAsync(IEnumerable<Breakpoint> breakpoints)
301301
psCommand.AddCommand(@"Microsoft.PowerShell.Utility\Remove-PSBreakpoint");
302302
psCommand.AddParameter("Id", breakpoints.Select(b => b.Id).ToArray());
303303

304-
await _powerShellContextService.ExecuteCommandAsync<object>(psCommand);
304+
await _powerShellContextService.ExecuteCommandAsync<object>(psCommand).ConfigureAwait(false);
305305
}
306306
}
307307

src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public async Task<BreakpointDetails[]> SetLineBreakpointsAsync(
190190
return await dscBreakpoints.SetLineBreakpointsAsync(
191191
this.powerShellContext,
192192
escapedScriptPath,
193-
breakpoints);
193+
breakpoints).ConfigureAwait(false);
194194
}
195195

196196
/// <summary>
@@ -208,7 +208,9 @@ public async Task<CommandBreakpointDetails[]> SetCommandBreakpointsAsync(
208208
if (clearExisting)
209209
{
210210
// Flatten dictionary values into one list and remove them all.
211-
await _breakpointService.RemoveBreakpointsAsync((await _breakpointService.GetBreakpointsAsync()).Where( i => i is CommandBreakpoint)).ConfigureAwait(false);
211+
await _breakpointService.RemoveBreakpointsAsync(
212+
(await _breakpointService.GetBreakpointsAsync().ConfigureAwait(false))
213+
.Where( i => i is CommandBreakpoint)).ConfigureAwait(false);
212214
}
213215

214216
if (breakpoints.Length > 0)

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ await _powerShellContextService.ExecuteScriptStringAsync(
264264

265265
await _powerShellContextService.ExecuteScriptStringAsync(
266266
$"Enter-PSHostProcess -Id {processId}",
267-
errorMessages);
267+
errorMessages).ConfigureAwait(false);
268268

269269
if (errorMessages.Length > 0)
270270
{
@@ -280,7 +280,7 @@ await _powerShellContextService.ExecuteScriptStringAsync(
280280

281281
await _powerShellContextService.ExecuteScriptStringAsync(
282282
$"Enter-PSHostProcess -CustomPipeName {request.CustomPipeName}",
283-
errorMessages);
283+
errorMessages).ConfigureAwait(false);
284284

285285
if (errorMessages.Length > 0)
286286
{
@@ -307,7 +307,7 @@ await _powerShellContextService.ExecuteScriptStringAsync(
307307
.AddCommand("Microsoft.PowerShell.Utility\\Get-Runspace")
308308
.AddParameter("Name", request.RunspaceName)
309309
.AddCommand("Microsoft.PowerShell.Utility\\Select-Object")
310-
.AddParameter("ExpandProperty", "Id"));
310+
.AddParameter("ExpandProperty", "Id")).ConfigureAwait(false);
311311
foreach (var id in ids)
312312
{
313313
_debugStateService.RunspaceId = id;
@@ -396,12 +396,12 @@ private async Task OnExecutionCompletedAsync(Task executeTask)
396396
{
397397
try
398398
{
399-
await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSHostProcess");
399+
await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSHostProcess").ConfigureAwait(false);
400400

401401
if (_debugStateService.IsRemoteAttach &&
402402
_powerShellContextService.CurrentRunspace.Location == RunspaceLocation.Remote)
403403
{
404-
await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSSession");
404+
await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSSession").ConfigureAwait(false);
405405
}
406406
}
407407
catch (Exception e)

src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetVersionHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private enum PowerShellProcessArchitecture
7777
private async Task CheckPackageManagement()
7878
{
7979
PSCommand getModule = new PSCommand().AddCommand("Get-Module").AddParameter("ListAvailable").AddParameter("Name", "PackageManagement");
80-
foreach (PSModuleInfo module in await _powerShellContextService.ExecuteCommandAsync<PSModuleInfo>(getModule))
80+
foreach (PSModuleInfo module in await _powerShellContextService.ExecuteCommandAsync<PSModuleInfo>(getModule).ConfigureAwait(false))
8181
{
8282
// The user has a good enough version of PackageManagement
8383
if (module.Version >= s_desiredPackageManagementVersion)
@@ -109,7 +109,7 @@ private async Task CheckPackageManagement()
109109
Title = "Not now"
110110
}
111111
}
112-
});
112+
}).ConfigureAwait(false);
113113

114114
// If the user chose "Not now" ignore it for the rest of the session.
115115
if (messageAction?.Title == takeActionText)

test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task InitializeAsync()
4141
{
4242
var factory = new LoggerFactory();
4343
_psesProcess = new PsesStdioProcess(factory, true);
44-
await _psesProcess.Start();
44+
await _psesProcess.Start().ConfigureAwait(false);
4545

4646
var initialized = new TaskCompletionSource<bool>();
4747
PsesDebugAdapterClient = DebugAdapterClient.Create(options =>

test/PowerShellEditorServices.Test.E2E/LSPTestsFixures.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task InitializeAsync()
4343
{
4444
var factory = new LoggerFactory();
4545
_psesProcess = new PsesStdioProcess(factory, IsDebugAdapterTests);
46-
await _psesProcess.Start();
46+
await _psesProcess.Start().ConfigureAwait(false);
4747

4848
Diagnostics = new List<Diagnostic>();
4949
TelemetryEvents = new List<PsesTelemetryEvent>();

0 commit comments

Comments
 (0)